forked from ballerina-platform/ballerina-lang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve Task ballerina-platform#45 - Introduce Operation context
- Loading branch information
1 parent
9a877e6
commit 427f1e4
Showing
50 changed files
with
611 additions
and
424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
modules/langserver-core/src/main/java/org/ballerinalang/langserver/DocumentServiceKeys.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (c) 2017, 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.langserver; | ||
|
||
import org.antlr.v4.runtime.ParserRuleContext; | ||
import org.antlr.v4.runtime.TokenStream; | ||
import org.antlr.v4.runtime.Vocabulary; | ||
import org.ballerinalang.langserver.completions.PossibleToken; | ||
import org.eclipse.lsp4j.TextDocumentPositionParams; | ||
import org.wso2.ballerinalang.compiler.semantics.model.SymbolTable; | ||
import org.wso2.ballerinalang.compiler.util.CompilerContext; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Text Document Service context keys for the completion operation context | ||
* @since 0.95.5 | ||
*/ | ||
public class DocumentServiceKeys { | ||
public static final LanguageServerContext.Key<TextDocumentPositionParams> POSITION_KEY | ||
= new LanguageServerContext.Key<>(); | ||
public static final LanguageServerContext.Key<String> FILE_NAME_KEY | ||
= new LanguageServerContext.Key<>(); | ||
public static final LanguageServerContext.Key<CompilerContext> COMPILER_CONTEXT_KEY | ||
= new LanguageServerContext.Key<>(); | ||
public static final LanguageServerContext.Key<ParserRuleContext> PARSER_RULE_CONTEXT_KEY | ||
= new LanguageServerContext.Key<>(); | ||
public static final LanguageServerContext.Key<List<PossibleToken>> POSSIBLE_TOKENS_KEY | ||
= new LanguageServerContext.Key<>(); | ||
public static final LanguageServerContext.Key<TokenStream> TOKEN_STREAM_KEY | ||
= new LanguageServerContext.Key<>(); | ||
public static final LanguageServerContext.Key<Vocabulary> VOCABULARY_KEY | ||
= new LanguageServerContext.Key<>(); | ||
public static final LanguageServerContext.Key<Integer> TOKEN_INDEX_KEY | ||
= new LanguageServerContext.Key<>(); | ||
public static final LanguageServerContext.Key<SymbolTable> SYMBOL_TABLE_KEY | ||
= new LanguageServerContext.Key<>(); | ||
} |
48 changes: 48 additions & 0 deletions
48
...les/langserver-core/src/main/java/org/ballerinalang/langserver/LanguageServerContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) 2017, 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.langserver; | ||
|
||
/** | ||
* Ballerina Language server context. | ||
* @since 0.95.5 | ||
*/ | ||
public interface LanguageServerContext { | ||
|
||
/** | ||
* Add new Context property. | ||
* @param key Property Key | ||
* @param value Property value | ||
* @param <V> Key Type | ||
*/ | ||
<V> void put(Key<V> key, V value); | ||
|
||
/** | ||
* Get property by Key. | ||
* @param key Property Key | ||
* @param <V> Key Type | ||
* @return {@link Object} Property | ||
*/ | ||
<V> V get(Key<V> key); | ||
|
||
/** | ||
* @param <K> | ||
* @since 0.95.5 | ||
*/ | ||
class Key<K> { | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...angserver-core/src/main/java/org/ballerinalang/langserver/TextDocumentServiceContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (c) 2017, 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.langserver; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Language server context for text document server. | ||
* @since 0.95.5 | ||
*/ | ||
public class TextDocumentServiceContext implements LanguageServerContext { | ||
|
||
private Map<Key<?>, Object> props = new HashMap<>(); | ||
|
||
@Override | ||
public <V> void put(Key<V> key, V value) { | ||
props.put(key, value); | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
public <V> V get(Key<V> key) { | ||
return (V) props.get(key); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 37 additions & 33 deletions
70
.../src/main/java/org/ballerinalang/langserver/completions/BallerinaCustomErrorStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.