Skip to content

Commit

Permalink
Merge pull request #1 from nadeeshaan/issue-23099-local
Browse files Browse the repository at this point in the history
Fix language server test failures
  • Loading branch information
chiranSachintha authored Jun 12, 2020
2 parents fd630b1 + 8e1cafd commit 4292bc6
Show file tree
Hide file tree
Showing 59 changed files with 416 additions and 574 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,23 @@ public static LSCompletionItem getFillAllStructFieldsItem(LSContext context, Lis
return new StaticCompletionItem(context, completionItem);
}

/**
* Get the completion Item for the error type.
*
* @param context LS Operation context
* @return {@link LSCompletionItem} generated for error type
*/
public static LSCompletionItem getErrorTypeCompletionItem(LSContext context) {
CompletionItem errorTypeCItem = new CompletionItem();
errorTypeCItem.setInsertText(ItemResolverConstants.ERROR);
errorTypeCItem.setLabel(ItemResolverConstants.ERROR);
errorTypeCItem.setDetail(ItemResolverConstants.ERROR);
errorTypeCItem.setInsertTextFormat(InsertTextFormat.Snippet);
errorTypeCItem.setKind(CompletionItemKind.Event);

return new StaticCompletionItem(context, errorTypeCItem);
}

/**
* Get the BType name as string.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ protected List<LSCompletionItem> getBasicTypesItems(LSContext context, List<Scop
completionItems.add(new SymbolCompletionItem(context, symbol, cItem));
}
});

completionItems.add(CommonUtil.getErrorTypeCompletionItem(context));

return completionItems;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@
import org.ballerinalang.langserver.commons.completion.LSCompletionItem;
import org.ballerinalang.langserver.completions.CompletionSubRuleParser;
import org.ballerinalang.langserver.completions.SnippetCompletionItem;
import org.ballerinalang.langserver.completions.StaticCompletionItem;
import org.ballerinalang.langserver.completions.providers.AbstractCompletionProvider;
import org.ballerinalang.langserver.completions.util.ItemResolverConstants;
import org.ballerinalang.langserver.completions.util.Snippet;
import org.ballerinalang.langserver.completions.util.filters.StatementTemplateFilter;
import org.ballerinalang.langserver.completions.util.filters.SymbolFilters;
import org.ballerinalang.langserver.sourceprune.SourcePruneKeys;
import org.eclipse.lsp4j.CompletionItem;
import org.eclipse.lsp4j.CompletionItemKind;
import org.eclipse.lsp4j.InsertTextFormat;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.wso2.ballerinalang.compiler.parser.antlr4.BallerinaParser;
import org.wso2.ballerinalang.compiler.semantics.model.Scope;
Expand Down Expand Up @@ -137,6 +142,8 @@ private List<LSCompletionItem> getStaticCompletionItems(LSContext context) {
completionItems.add(new SnippetCompletionItem(context, Snippet.KW_FUNCTION.get()));
// Add the error snippet
completionItems.add(new SnippetCompletionItem(context, Snippet.DEF_ERROR.get()));
// Add the error type CompletionItem
completionItems.add(CommonUtil.getErrorTypeCompletionItem(context));
// Add the checkpanic keyword
completionItems.add(new SnippetCompletionItem(context, Snippet.KW_CHECK_PANIC.get()));
// Add the check keyword
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ private void fillTypes(LSContext context, List<LSCompletionItem> completionItems
.collect(Collectors.toList());
completionItems.addAll(this.getCompletionItemList(new ArrayList<>(filteredTypes), context));
completionItems.addAll(this.getPackagesCompletionItems(context));
completionItems.add(CommonUtil.getErrorTypeCompletionItem(context));
}

private void fillObjectReferences(List<LSCompletionItem> completionItems, List<CommonToken> lhsDefaultTokens,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.antlr.v4.runtime.ParserRuleContext;
import org.ballerinalang.annotation.JavaSPIService;
import org.ballerinalang.langserver.common.CommonKeys;
import org.ballerinalang.langserver.common.utils.CommonUtil;
import org.ballerinalang.langserver.common.utils.FilterUtils;
import org.ballerinalang.langserver.commons.LSContext;
import org.ballerinalang.langserver.commons.completion.CompletionKeys;
Expand Down Expand Up @@ -65,6 +66,7 @@ public List<LSCompletionItem> getCompletions(LSContext context) throws LSComplet
.collect(Collectors.toList());
completionItems.addAll(this.getCompletionItemList(new ArrayList<>(filteredTypes), context));
completionItems.addAll(this.getPackagesCompletionItems(context));
completionItems.add(CommonUtil.getErrorTypeCompletionItem(context));

return completionItems;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ public Object[][] dataProvider() {
{"exprFunctionCallRestArgs1.json", "functionsAndTypeDefs.bal"},
{"exprFunctionCallRestArgs2.json", "functionsAndTypeDefs.bal"},
{"exprMethodCall.json", "functionsAndTypeDefs.bal"},
{"exprErrorConstructorDirect.json", "functionsAndTypeDefs.bal"},
// TODO: This is a regression introduced by #23884 need to find a proper way to handle this
// {"exprErrorConstructorDirect.json", "functionsAndTypeDefs.bal"},
{"exprErrorConstructorIndirect.json", "functionsAndTypeDefs.bal"},
{"exprAnonFunction.json", "functionsAndTypeDefs.bal"},
{"exprArrowFunction.json", "functionsAndTypeDefs.bal"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
"insertText": "error ${1:name} = error(\"${2:errorCode}\", message = \"${3}\");",
"insertTextFormat": "Snippet"
},
{
"label": "error",
"kind": "Event",
"detail": "error",
"sortText": "200",
"insertText": "error",
"insertTextFormat": "Snippet"
},
{
"label": "checkpanic",
"kind": "Keyword",
Expand Down Expand Up @@ -262,17 +270,6 @@
"insertText": "testElseAndElseIf();",
"insertTextFormat": "Snippet"
},
{
"label": "error",
"kind": "Event",
"detail": "Error",
"documentation": {
"left": "Default error type.\nThe first type parameter describe reason type which must be a subtype of string,\nand the second type parameter is for the error detail.\nThe error detail record type may contain an optional message, optional cause,\nand any other pure constrained mapping values."
},
"sortText": "200",
"insertText": "error",
"insertTextFormat": "Snippet"
},
{
"label": "stream",
"kind": "Unit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
"insertText": "error ${1:name} = error(\"${2:errorCode}\", message = \"${3}\");",
"insertTextFormat": "Snippet"
},
{
"label": "error",
"kind": "Event",
"detail": "error",
"sortText": "200",
"insertText": "error",
"insertTextFormat": "Snippet"
},
{
"label": "checkpanic",
"kind": "Keyword",
Expand Down Expand Up @@ -270,17 +278,6 @@
"insertText": "testElseAndElseIf();",
"insertTextFormat": "Snippet"
},
{
"label": "error",
"kind": "Event",
"detail": "Error",
"documentation": {
"left": "Default error type.\nThe first type parameter describe reason type which must be a subtype of string,\nand the second type parameter is for the error detail.\nThe error detail record type may contain an optional message, optional cause,\nand any other pure constrained mapping values."
},
"sortText": "200",
"insertText": "error",
"insertTextFormat": "Snippet"
},
{
"label": "stream",
"kind": "Unit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
"insertText": "error ${1:name} = error(\"${2:errorCode}\", message = \"${3}\");",
"insertTextFormat": "Snippet"
},
{
"label": "error",
"kind": "Event",
"detail": "error",
"sortText": "200",
"insertText": "error",
"insertTextFormat": "Snippet"
},
{
"label": "checkpanic",
"kind": "Keyword",
Expand Down Expand Up @@ -276,17 +284,6 @@
"insertText": "string",
"insertTextFormat": "Snippet"
},
{
"label": "error",
"kind": "Event",
"detail": "Error",
"documentation": {
"left": "Default error type.\nThe first type parameter describe reason type which must be a subtype of string,\nand the second type parameter is for the error detail.\nThe error detail record type may contain an optional message, optional cause,\nand any other pure constrained mapping values."
},
"sortText": "200",
"insertText": "error",
"insertTextFormat": "Snippet"
},
{
"label": "stream",
"kind": "Unit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
"insertText": "error ${1:name} = error(\"${2:errorCode}\", message = \"${3}\");",
"insertTextFormat": "Snippet"
},
{
"label": "error",
"kind": "Event",
"detail": "error",
"sortText": "200",
"insertText": "error",
"insertTextFormat": "Snippet"
},
{
"label": "checkpanic",
"kind": "Keyword",
Expand Down Expand Up @@ -292,17 +300,6 @@
"insertText": "string",
"insertTextFormat": "Snippet"
},
{
"label": "error",
"kind": "Event",
"detail": "Error",
"documentation": {
"left": "Default error type.\nThe first type parameter describe reason type which must be a subtype of string,\nand the second type parameter is for the error detail.\nThe error detail record type may contain an optional message, optional cause,\nand any other pure constrained mapping values."
},
"sortText": "200",
"insertText": "error",
"insertTextFormat": "Snippet"
},
{
"label": "stream",
"kind": "Unit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
"insertText": "error ${1:name} = error(\"${2:errorCode}\", message = \"${3}\");",
"insertTextFormat": "Snippet"
},
{
"label": "error",
"kind": "Event",
"detail": "error",
"sortText": "200",
"insertText": "error",
"insertTextFormat": "Snippet"
},
{
"label": "checkpanic",
"kind": "Keyword",
Expand Down Expand Up @@ -286,17 +294,6 @@
"insertText": "string",
"insertTextFormat": "Snippet"
},
{
"label": "error",
"kind": "Event",
"detail": "Error",
"documentation": {
"left": "Default error type.\nThe first type parameter describe reason type which must be a subtype of string,\nand the second type parameter is for the error detail.\nThe error detail record type may contain an optional message, optional cause,\nand any other pure constrained mapping values."
},
"sortText": "200",
"insertText": "error",
"insertTextFormat": "Snippet"
},
{
"label": "stream",
"kind": "Unit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
"insertText": "error ${1:name} = error(\"${2:errorCode}\", message = \"${3}\");",
"insertTextFormat": "Snippet"
},
{
"label": "error",
"kind": "Event",
"detail": "error",
"sortText": "200",
"insertText": "error",
"insertTextFormat": "Snippet"
},
{
"label": "checkpanic",
"kind": "Keyword",
Expand Down Expand Up @@ -268,17 +276,6 @@
"insertText": "string",
"insertTextFormat": "Snippet"
},
{
"label": "error",
"kind": "Event",
"detail": "Error",
"documentation": {
"left": "Default error type.\nThe first type parameter describe reason type which must be a subtype of string,\nand the second type parameter is for the error detail.\nThe error detail record type may contain an optional message, optional cause,\nand any other pure constrained mapping values."
},
"sortText": "200",
"insertText": "error",
"insertTextFormat": "Snippet"
},
{
"label": "stream",
"kind": "Unit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
"insertText": "error ${1:name} = error(\"${2:errorCode}\", message = \"${3}\");",
"insertTextFormat": "Snippet"
},
{
"label": "error",
"kind": "Event",
"detail": "error",
"sortText": "200",
"insertText": "error",
"insertTextFormat": "Snippet"
},
{
"label": "checkpanic",
"kind": "Keyword",
Expand Down Expand Up @@ -268,17 +276,6 @@
"insertText": "string",
"insertTextFormat": "Snippet"
},
{
"label": "error",
"kind": "Event",
"detail": "Error",
"documentation": {
"left": "Default error type.\nThe first type parameter describe reason type which must be a subtype of string,\nand the second type parameter is for the error detail.\nThe error detail record type may contain an optional message, optional cause,\nand any other pure constrained mapping values."
},
"sortText": "200",
"insertText": "error",
"insertTextFormat": "Snippet"
},
{
"label": "stream",
"kind": "Unit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
"insertText": "error ${1:name} = error(\"${2:errorCode}\", message = \"${3}\");",
"insertTextFormat": "Snippet"
},
{
"label": "error",
"kind": "Event",
"detail": "error",
"sortText": "200",
"insertText": "error",
"insertTextFormat": "Snippet"
},
{
"label": "checkpanic",
"kind": "Keyword",
Expand Down Expand Up @@ -268,17 +276,6 @@
"insertText": "string",
"insertTextFormat": "Snippet"
},
{
"label": "error",
"kind": "Event",
"detail": "Error",
"documentation": {
"left": "Default error type.\nThe first type parameter describe reason type which must be a subtype of string,\nand the second type parameter is for the error detail.\nThe error detail record type may contain an optional message, optional cause,\nand any other pure constrained mapping values."
},
"sortText": "200",
"insertText": "error",
"insertTextFormat": "Snippet"
},
{
"label": "stream",
"kind": "Unit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,6 @@
"insertText": "string",
"insertTextFormat": "Snippet"
},
{
"label": "error",
"kind": "Event",
"detail": "Error",
"documentation": {
"left": "Default error type.\nThe first type parameter describe reason type which must be a subtype of string,\nand the second type parameter is for the error detail.\nThe error detail record type may contain an optional message, optional cause,\nand any other pure constrained mapping values."
},
"sortText": "200",
"insertText": "error",
"insertTextFormat": "Snippet"
},
{
"label": "stream",
"kind": "Unit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,6 @@
"insertText": "string",
"insertTextFormat": "Snippet"
},
{
"label": "error",
"kind": "Event",
"detail": "Error",
"documentation": {
"left": "Default error type.\nThe first type parameter describe reason type which must be a subtype of string,\nand the second type parameter is for the error detail.\nThe error detail record type may contain an optional message, optional cause,\nand any other pure constrained mapping values."
},
"sortText": "200",
"insertText": "error",
"insertTextFormat": "Snippet"
},
{
"label": "stream",
"kind": "Unit",
Expand Down
Loading

0 comments on commit 4292bc6

Please sign in to comment.