Skip to content

Commit

Permalink
Merge branch 'eclipse-che4z:development' into feature/workspace/exten…
Browse files Browse the repository at this point in the history
…sion_folder
  • Loading branch information
KutluOzel-b authored May 13, 2024
2 parents 3fcb37f + 77d66cb commit a0c387c
Show file tree
Hide file tree
Showing 87 changed files with 1,405 additions and 861 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Supplier;

/**
* Extended Text contains information about original text and current text with the mapping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import lombok.experimental.UtilityClass;
import org.eclipse.lsp.cobol.common.model.Locality;
import org.eclipse.lsp.cobol.common.model.tree.CopyNode;
import org.eclipse.lsp.cobol.common.model.tree.Node;
import org.eclipse.lsp4j.Position;
import org.eclipse.lsp4j.Range;
Expand All @@ -37,6 +38,13 @@ public class RangeUtils {
*/
public static Optional<Node> findNodeByPosition(Node node, String uri, Position position) {
Node candidate = null;
if (isFromCopybook(uri, node)) {
if (node.getChildren().isEmpty()) {
return Optional.of(node);
}
candidate = node;
}

if (isInside(uri, position, node.getLocality())) {
if (node.getChildren().isEmpty()) {
return Optional.of(node);
Expand All @@ -53,6 +61,14 @@ public static Optional<Node> findNodeByPosition(Node node, String uri, Position
return candidate == null ? Optional.empty() : Optional.of(candidate);
}

private boolean isFromCopybook(String uri, Node node) {
if (!(node instanceof CopyNode)) {
return false;
}
CopyNode copyNode = (CopyNode) node;
return uri.equals(copyNode.getUri());
}

/**
* Test if one position is after the another position.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ options {tokenVocab = Db2SqlLexer; superClass = MessageServiceParser;}
startRule: .*? (execRule .*?) * EOF;
//startIncludeRule: .*? (includeStatement .*?)* EOF;

execRule: EXEC SQL sqlCode END_EXEC DOT_FS?
| EXEC SQL END_EXEC DOT_FS?
| EXEC SQLIMS sqlCode END_EXEC DOT_FS? // TODO: check when should this grammar be activated. Probably based on some compiler directives
execRule: EXEC SQL sqlCode END_EXEC
| EXEC SQL END_EXEC
| EXEC SQLIMS sqlCode END_EXEC // TODO: check when should this grammar be activated. Probably based on some compiler directives
| {notifyError("cobolParser.missingEndExec");} EXEC SQL sqlCode DOT_FS? EOF
| {notifyError("cobolParser.missingEndExec");} EXEC SQL;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,15 @@ public List<Node> visitParagraphs(ParagraphsContext ctx) {

@Override
public List<Node> visitProcedureDivisionBody(ProcedureDivisionBodyContext ctx) {
return addTreeNode(ctx, ProcedureDivisionBodyNode::new);

ParserRuleContext context = new ParserRuleContext();
context.start = ctx.getParent().start;
context.stop = ctx.stop;

List<Node> children = visitChildren(ctx);
return retrieveLocality(context)
.map(constructNode(ProcedureDivisionBodyNode::new, children))
.orElse(children);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.eclipse.lsp.cobol.common.error.SyntaxError;
import org.eclipse.lsp.cobol.common.mapping.ExtendedDocument;
import org.eclipse.lsp.cobol.common.model.Locality;
import org.eclipse.lsp.cobol.core.WarningRecognitionException;
import org.eclipse.lsp.cobol.parser.WarningRecognitionException;
import org.eclipse.lsp.cobol.core.semantics.CopybooksRepository;
import org.eclipse.lsp4j.Location;
import org.eclipse.lsp4j.Position;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import org.eclipse.lsp.cobol.common.pipeline.Stage;
import org.eclipse.lsp.cobol.core.strategy.CobolErrorStrategy;
import org.eclipse.lsp.cobol.core.visitor.ParserListener;
import org.eclipse.lsp.cobol.parser.AstBuilder;
import org.eclipse.lsp.cobol.parser.SplitParser;
import org.eclipse.lsp4j.Location;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import org.eclipse.lsp.cobol.common.pipeline.Stage;
import org.eclipse.lsp.cobol.core.strategy.CobolErrorStrategy;
import org.eclipse.lsp.cobol.core.visitor.ParserListener;
import org.eclipse.lsp.cobol.parser.AntlrCobolParser;
import org.eclipse.lsp.cobol.parser.AstBuilder;
import org.eclipse.lsp4j.Location;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public List<ProcessorDescription> getProcessors() {
new ImplicitDb2VariablesProcessor()),
new ProcessorDescription(
Db2DataAndProcedureDivisionNode.class,
ProcessingPhase.POST_DEFINITION,
ProcessingPhase.VALIDATION,
new Db2DataAndProcedureDivisionProcessor(messageService)),
new ProcessorDescription(
Db2DeclareVariableNode.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
import org.eclipse.lsp4j.Diagnostic;
import org.eclipse.lsp4j.DiagnosticSeverity;
import org.eclipse.lsp4j.Range;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

/**
* This test checks that the an asterisk out of indicator area before the COPY statement doesn't
* This test checks that the asterisk out of indicator area before the COPY statement doesn't
* break syntax analysis
*/
class TestAsteriskBeforeCopyDoesntBreakAnalysis {
Expand Down Expand Up @@ -60,7 +61,8 @@ void test() {
}

@Test
void testРц() {
@Disabled("Experimental parser")
void testEx() {

UseCaseEngine.runTest(
TEXT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@
PROCEDURE DIVISION.
EXEC CICS HANDLE ABEND
END-EXEC.
.
Original file line number Diff line number Diff line change
Expand Up @@ -533,5 +533,5 @@ cobolWord
;

dialectNodeFiller
: ZERO_WIDTH_SPACE+
: ZERO_WIDTH_SPACE+ DOT_FS? EOF?
;
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,5 @@ cobolWord
;

dialectNodeFiller
: ZERO_WIDTH_SPACE+
: ZERO_WIDTH_SPACE+ DOT_FS? EOF?
;
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@ procedureSection

sentence
: statement * (endClause | dialectStatement)
| dialectStatement
;

paragraph
Expand Down Expand Up @@ -2207,7 +2208,7 @@ literal
: NONNUMERICLITERAL | figurativeConstant | numericLiteral | booleanLiteral | charString | dialectLiteral | utfLiteral | hexadecimalUtfLiteral
;

dialectLiteral: dialectNodeFiller+;
dialectLiteral: dialectNodeFiller+ DOT_FS?;

utfLiteral: U_CHAR NONNUMERICLITERAL;

Expand Down Expand Up @@ -2244,7 +2245,7 @@ power
;

basis
: dialectNodeFiller | generalIdentifier | literal | LPARENCHAR arithmeticExpression RPARENCHAR
: (dialectNodeFiller DOT_FS?) | generalIdentifier | literal | LPARENCHAR arithmeticExpression RPARENCHAR
;

cobolWord
Expand All @@ -2263,7 +2264,7 @@ cobolKeywords
;

dialectNodeFiller
: ZERO_WIDTH_SPACE+
: ZERO_WIDTH_SPACE+ DOT_FS? EOF?
;

dot_fs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ COMMENTLINE : COMMENTTAG ~('\n' | '\r')* -> channel(COMMENTS);
WS : [ \t\f]+ -> channel(HIDDEN);
COMPILERLINE : DOUBLEMORETHANCHAR ~('\n' | '\r')* -> channel(HIDDEN);
// period full stopPosition
DOT : '.';
DOT_FS : '.' EOF?;

LEVEL_NUMBER : ([1-9])|([0][1-9])|([1234][0-9]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ paragraph

sentence
: statement * (endClause | dialectStatement)
| dialectStatement
;

conditionalStatementCall
Expand Down Expand Up @@ -1499,5 +1500,5 @@ cobolKeywords
;

dialectNodeFiller
: ZERO_WIDTH_SPACE+
: ZERO_WIDTH_SPACE+ DOT? EOF?
;
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* and DAF development standards
*
*/
package org.eclipse.lsp.cobol.test.codegen;
package org.eclipse.lsp.cobol.codegen;

import org.eclipse.lsp.cobol.test.codegen.snippets.ParagraphGenerator;
import org.eclipse.lsp.cobol.test.codegen.snippets.SectionGenerator;
import org.eclipse.lsp.cobol.test.codegen.snippets.SnippetGenerator;
import org.eclipse.lsp.cobol.codegen.snippets.ParagraphGenerator;
import org.eclipse.lsp.cobol.codegen.snippets.SectionGenerator;
import org.eclipse.lsp.cobol.codegen.snippets.SnippetGenerator;

import java.util.Random;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* and DAF development standards
*
*/
package org.eclipse.lsp.cobol.test.codegen;
package org.eclipse.lsp.cobol.codegen;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* and DAF development standards
*
*/
package org.eclipse.lsp.cobol.test.codegen;
package org.eclipse.lsp.cobol.codegen;

import org.eclipse.lsp.cobol.test.codegen.snippets.*;
import org.eclipse.lsp.cobol.codegen.snippets.*;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* and DAF development standards
*
*/
package org.eclipse.lsp.cobol.test.codegen;
package org.eclipse.lsp.cobol.codegen;

/**
* Types of id that was used in the program.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* and DAF development standards
*
*/
package org.eclipse.lsp.cobol.test.codegen.snippets;
package org.eclipse.lsp.cobol.codegen.snippets;

import org.eclipse.lsp.cobol.test.codegen.CobolCodeGenerator;
import org.eclipse.lsp.cobol.test.codegen.GeneratorContext;
import org.eclipse.lsp.cobol.codegen.GeneratorContext;
import org.eclipse.lsp.cobol.codegen.CobolCodeGenerator;

/**
* Display statement generator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* and DAF development standards
*
*/
package org.eclipse.lsp.cobol.test.codegen.snippets;
package org.eclipse.lsp.cobol.codegen.snippets;

import org.eclipse.lsp.cobol.test.codegen.CobolCodeGenerator;
import org.eclipse.lsp.cobol.test.codegen.GeneratorContext;
import org.eclipse.lsp.cobol.codegen.GeneratorContext;
import org.eclipse.lsp.cobol.codegen.CobolCodeGenerator;

/**
* Open statement generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* and DAF development standards
*
*/
package org.eclipse.lsp.cobol.test.codegen.snippets;
package org.eclipse.lsp.cobol.codegen.snippets;

import org.eclipse.lsp.cobol.test.codegen.GeneratorContext;
import org.eclipse.lsp.cobol.test.codegen.IdentifierType;
import org.eclipse.lsp.cobol.codegen.GeneratorContext;
import org.eclipse.lsp.cobol.codegen.IdentifierType;

/**
* Generates a PARAGRAPH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* and DAF development standards
*
*/
package org.eclipse.lsp.cobol.test.codegen.snippets;
package org.eclipse.lsp.cobol.codegen.snippets;

import org.eclipse.lsp.cobol.test.codegen.CobolCodeGenerator;
import org.eclipse.lsp.cobol.test.codegen.GeneratorContext;
import org.eclipse.lsp.cobol.test.codegen.IdentifierType;
import org.eclipse.lsp.cobol.codegen.GeneratorContext;
import org.eclipse.lsp.cobol.codegen.IdentifierType;
import org.eclipse.lsp.cobol.codegen.CobolCodeGenerator;

/**
* Generates a SECTION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* and DAF development standards
*
*/
package org.eclipse.lsp.cobol.test.codegen.snippets;
package org.eclipse.lsp.cobol.codegen.snippets;

import org.eclipse.lsp.cobol.test.codegen.GeneratorContext;
import org.eclipse.lsp.cobol.codegen.GeneratorContext;

/**
* Interface for statements and other generators.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.antlr.v4.runtime.Parser;
import org.antlr.v4.runtime.TokenStream;
import org.eclipse.lsp.cobol.common.message.MessageServiceProvider;
import org.eclipse.lsp.cobol.parser.WarningRecognitionException;

/**
* Provide the support of message externalization for Parser.
Expand Down
Loading

0 comments on commit a0c387c

Please sign in to comment.