-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: alter go to support in experimental parser (#2306)
- Loading branch information
Showing
4 changed files
with
56 additions
and
3 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
48 changes: 48 additions & 0 deletions
48
server/parser/src/test/java/org/eclipse/lsp/cobol/divisions/procedure/AlterGoToTest.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) 2024 Broadcom. | ||
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Broadcom, Inc. - initial API and implementation | ||
* | ||
*/ | ||
package org.eclipse.lsp.cobol.divisions.procedure; | ||
|
||
import org.eclipse.lsp.cobol.cst.ProgramUnit; | ||
import org.eclipse.lsp.cobol.cst.procedure.Paragraph; | ||
import org.eclipse.lsp.cobol.cst.procedure.ProcedureDivision; | ||
import org.eclipse.lsp.cobol.parser.hw.CobolParser; | ||
import org.eclipse.lsp.cobol.parser.hw.ParseResult; | ||
import org.eclipse.lsp.cobol.parser.hw.ParserSettings; | ||
import org.eclipse.lsp.cobol.parser.hw.lexer.CobolLexer; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
/** test alter go - to */ | ||
public class AlterGoToTest { | ||
@Test | ||
void test() { | ||
String source = " ID DIVISION. PROGRAM-ID. str1.\n" | ||
+ " PROCEDURE DIVISION.\n" | ||
+ " DISPLAY 'OUT'.\n" | ||
+ " PARAG2.\n" | ||
+ " GO TO.\n" | ||
+ " PARAG2.\n" | ||
+ " DISPLAY 'PARAG2'.\n"; | ||
ParseResult parseResult = new CobolParser(new CobolLexer(source), new ParserSettings()).parse(); | ||
assertTrue(parseResult.getDiagnostics().isEmpty()); | ||
ProgramUnit pu = (ProgramUnit) parseResult.getSourceUnit().getChildren().get(1); | ||
ProcedureDivision pd = (ProcedureDivision) pu.getChildren().get(1); | ||
assertEquals(1, pd.getChildren().stream().filter(Paragraph.class::isInstance).count()); | ||
assertEquals(source, parseResult.getSourceUnit().toText()); | ||
} | ||
|
||
} |
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