From ff724e12225b727f4f98c5e04766f1134ac091fd Mon Sep 17 00:00:00 2001 From: Aman Prashant Date: Tue, 23 Jan 2024 13:56:22 +0100 Subject: [PATCH] feature: update dialect API to support Dialect based compiler directives Signed-off-by: Aman Prashant --- server/common/pom.xml | 2 +- .../lsp/cobol/common/dialects/CobolDialect.java | 13 +++++++++++-- .../common/model/tree/CompilerDirectiveNode.java | 12 ++++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/server/common/pom.xml b/server/common/pom.xml index b4f3a5a666..9d1e7c7313 100644 --- a/server/common/pom.xml +++ b/server/common/pom.xml @@ -21,7 +21,7 @@ 4.0.0 common org.eclipse.lsp.cobol - 1.0.3 + 1.0.4 8 diff --git a/server/common/src/main/java/org/eclipse/lsp/cobol/common/dialects/CobolDialect.java b/server/common/src/main/java/org/eclipse/lsp/cobol/common/dialects/CobolDialect.java index c16d5bddcb..3d33fbaa3c 100644 --- a/server/common/src/main/java/org/eclipse/lsp/cobol/common/dialects/CobolDialect.java +++ b/server/common/src/main/java/org/eclipse/lsp/cobol/common/dialects/CobolDialect.java @@ -17,15 +17,15 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import java.util.*; import org.eclipse.lsp.cobol.common.AnalysisConfig; import org.eclipse.lsp.cobol.common.ResultWithErrors; import org.eclipse.lsp.cobol.common.action.CodeActionProvider; import org.eclipse.lsp.cobol.common.copybook.CopybookModel; import org.eclipse.lsp.cobol.common.error.SyntaxError; +import org.eclipse.lsp.cobol.common.model.tree.CompilerDirectiveNode; import org.eclipse.lsp.cobol.common.processor.ProcessorDescription; -import java.util.*; - /** A COBOL dialect */ public interface CobolDialect { String FILLER = "\u200B"; @@ -132,4 +132,13 @@ default List getDialectCodeActionProviders() { default List getPredefinedCopybook(AnalysisConfig ctx) { return ImmutableList.of(); } + + /** + * Returns the list of {@link CompilerDirectiveNode} specific to the dialect + * @param context is a DialectProcessingContext class with all needed data for dialect processing + * @return a list of {@link CompilerDirectiveNode} + */ + default List getCompilerDirectives(DialectProcessingContext context) { + return ImmutableList.of(); + } } diff --git a/server/common/src/main/java/org/eclipse/lsp/cobol/common/model/tree/CompilerDirectiveNode.java b/server/common/src/main/java/org/eclipse/lsp/cobol/common/model/tree/CompilerDirectiveNode.java index 12472868a3..b4edb436d1 100644 --- a/server/common/src/main/java/org/eclipse/lsp/cobol/common/model/tree/CompilerDirectiveNode.java +++ b/server/common/src/main/java/org/eclipse/lsp/cobol/common/model/tree/CompilerDirectiveNode.java @@ -14,6 +14,7 @@ */ package org.eclipse.lsp.cobol.common.model.tree; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.eclipse.lsp.cobol.common.model.Locality; @@ -21,12 +22,19 @@ /** Node describing compiler directive in a cobol document. */ @Slf4j -@Deprecated +@EqualsAndHashCode(callSuper = true) +@Getter public class CompilerDirectiveNode extends Node { - @Getter private final String directiveText; + private final String directiveText; + private final String dialect; public CompilerDirectiveNode(Locality location, String directiveText) { + this(location, directiveText, "COBOL"); + } + + public CompilerDirectiveNode(Locality location, String directiveText, String dialect) { super(location, NodeType.COMPILER_DIRECTIVE); this.directiveText = directiveText; + this.dialect = dialect; } }