Skip to content

Commit

Permalink
Обновление на новый парсер с antlr 4.13.1
Browse files Browse the repository at this point in the history
  • Loading branch information
theshadowco committed Apr 16, 2024
1 parent 30f1c3e commit 146db27
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,4 @@ bsl-language-server_*.zip
/.idea/misc.xml
*.log
*.hprof
/.idea/material_theme_project_new.xml
5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ dependencies {
api("org.eclipse.lsp4j", "org.eclipse.lsp4j.websocket.jakarta", "0.21.0")

// 1c-syntax
api("io.github.1c-syntax", "bsl-parser", "0.24.0") {
exclude("com.tunnelvisionlabs", "antlr4-annotations")
api("io.github.1c-syntax", "bsl-parser", "0.25.0") {
exclude("com.ibm.icu", "*")
exclude("org.antlr", "ST4")
exclude("org.abego.treelayout", "org.abego.treelayout.core")
Expand All @@ -85,7 +84,7 @@ dependencies {
api("io.github.1c-syntax", "mdclasses", "0.13.0-rc.2")
api("io.github.1c-syntax", "bsl-common-library", "0.5.1")
api("io.github.1c-syntax", "supportconf", "0.14.0")
api("io.github.1c-syntax", "bsl-parser-core", "0.1.0")
api("io.github.1c-syntax", "bsl-parser-core", "0.2.0")

// JLanguageTool
implementation("org.languagetool", "languagetool-core", languageToolVersion){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.github._1c_syntax.bsl.languageserver.utils.Trees;
import com.github._1c_syntax.bsl.parser.BSLParser;
import lombok.RequiredArgsConstructor;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.RuleNode;
import org.antlr.v4.runtime.tree.TerminalNode;
import org.apache.commons.lang3.tuple.Pair;
Expand Down Expand Up @@ -154,13 +155,14 @@ private Optional<RuleNode> getRefContextInsideDefAssign(Reference defRef, Refere
final var assignment = defNode
.map(TerminalNode::getParent)
.filter(BSLParser.LValueContext.class::isInstance)
.map(RuleNode::getParent)
.map(ParseTree::getParent)
.filter(BSLParser.AssignmentContext.class::isInstance)
.map(BSLParser.AssignmentContext.class::cast);

return assignment.flatMap(assignContext ->
Trees.findTerminalNodeContainsPosition(assignContext, nextRef.getSelectionRange().getStart()))
.map(TerminalNode::getParent);
.map(TerminalNode::getParent)
.map(RuleNode.class::cast);
}

private static boolean isVarNameOnlyIntoExpression(RuleNode refContext) {
Expand All @@ -170,7 +172,7 @@ private static boolean isVarNameOnlyIntoExpression(RuleNode refContext) {
.filter(node -> node.getChildCount() == 1)
.map(RuleNode::getParent)
.filter(BSLParser.MemberContext.class::isInstance)
.map(RuleNode::getParent)
.map(ParseTree::getParent)
.filter(expression -> expression.getChildCount() == 1)
.filter(BSLParser.ExpressionContext.class::isInstance)
.isPresent();
Expand Down

0 comments on commit 146db27

Please sign in to comment.