Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repush lost changes #2292

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions clients/cobol-lsp-vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,35 +41,43 @@
"commands": [
{
"command": "cobol-lsp.cpy-manager.fetch-copybook",
"title": "Fetch copybook"
"category": "COBOL",
"title": "Fetch Copybook"
},
{
"command": "cobol-lsp.cpy-manager.goto-settings",
"title": "Open Copybook location settings"
"category": "COBOL",
"title": "Open Copybook Location Settings"
},
{
"command": "cobol-lsp.serverRuntime.goto-settings",
"title": "Open serverRuntime settings"
"category": "COBOL",
"title": "Open Server Runtime Settings"
},
{
"command": "cobol-lsp.dialects.goto-settings",
"title": "Open Dialects settings"
"category": "COBOL",
"title": "Open Dialect Settings"
},
{
"command": "cobol-lsp.commentLine.toggle",
"category": "COBOL",
"title": "Toggle COBOL Line Comment"
},
{
"command": "cobol-lsp.commentLine.comment",
"title": "Add Cobol Line Comment"
"category": "COBOL",
"title": "Add COBOL Line Comment"
},
{
"command": "cobol-lsp.commentLine.uncomment",
"category": "COBOL",
"title": "Remove COBOL Line Comment"
},
{
"command": "cobol-lsp.clear.downloaded.copybooks",
"title": "Clear downloaded copybooks"
"category": "COBOL",
"title": "Clear Downloaded Copybooks"
},
{
"command": "cobol-lsp.snippets.insertSnippets",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,20 @@
*/
package org.eclipse.lsp.cobol.dialects.hp;

import static org.eclipse.lsp.cobol.common.error.ErrorSeverity.ERROR;

import com.google.common.collect.ImmutableList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.eclipse.lsp.cobol.common.copybook.CopybookModel;
import org.eclipse.lsp.cobol.common.copybook.CopybookName;
import org.eclipse.lsp.cobol.common.copybook.CopybookService;
import org.eclipse.lsp.cobol.common.dialects.CobolLanguageId;
import org.eclipse.lsp.cobol.common.dialects.DialectOutcome;
import org.eclipse.lsp.cobol.common.dialects.DialectProcessingContext;
import org.eclipse.lsp.cobol.common.error.ErrorCodes;
Expand All @@ -36,13 +45,6 @@
import org.eclipse.lsp.cobol.core.engine.analysis.AnalysisContext;
import org.eclipse.lsp4j.Location;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

import static org.eclipse.lsp.cobol.common.error.ErrorSeverity.ERROR;

/**
* Resolving and inserting copybooks into the extended source stage
*/
Expand All @@ -57,12 +59,22 @@ public StageResult<DialectOutcome> run(AnalysisContext context, StageResult<Void
List<SyntaxError> errors = new LinkedList<>();

List<CopybookDescriptor> cbs = CopybookParser.parseAndCleanup(context.getExtendedDocument());
cbs.forEach(cb -> {
List<CopyNode> copybookNodes = insertHpCopybook(context.getDocumentUri(), context.getExtendedDocument(), cb, errors);
context.getDialectNodes().addAll(copybookNodes);
});

DialectOutcome outcome = new DialectOutcome(context.getDialectNodes(), DialectProcessingContext.builder().build());
cbs.forEach(
cb -> {
List<CopyNode> copybookNodes =
insertHpCopybook(context.getDocumentUri(), context.getExtendedDocument(), cb, errors);
context.getDialectNodes().addAll(copybookNodes);
});

DialectOutcome outcome =
new DialectOutcome(
Optional.ofNullable(context.getDialectNodes()).orElse(Collections.emptyList()),
DialectProcessingContext.builder()
.languageId(CobolLanguageId.HP_COBOL.getId())
.config(context.getConfig())
.programDocumentUri(context.getExtendedDocument().getUri())
.extendedDocument(context.getExtendedDocument())
.build());
return new StageResult<>(outcome);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/*
* 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.usecases.hpcobol;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.eclipse.lsp.cobol.common.dialects.CobolLanguageId;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.junit.jupiter.api.Test;

/** Sample test for HP Cobol language id. */
public class TestHPCobol {
public static final String TEXT =
"?SAVE ALL\n"
+ "?SAVEABEND\n"
+ "?SYMBOLS\n"
+ "?HEADING \"DUMMY MODULE TO SHOW USE of DOLLAR ZERO\"\n"
+ "\n"
+ " IDENTIFICATION DIVISION.\n"
+ "*************************\n"
+ "\n"
+ " PROGRAM-ID. AAABCD001.\n"
+ "\n"
+ "********************************************************************************\n"
+ "* *\n"
+ "* This is a dummy program for testing *\n"
+ "* *\n"
+ "********************************************************************************\n"
+ "\n"
+ "********************************************************************************\n"
+ "* PROGRAM HISTORY *\n"
+ "* *\n"
+ "* DEV/CR DATE INITS DESCRIPTION CIS Release *\n"
+ "* 030423 CT Initial version. 1.0 *\n"
+ "* 180523 CT Comment added for test 1.0 *\n"
+ "********************************************************************************\n"
+ "/\n"
+ " ENVIRONMENT DIVISION.\n"
+ "**********************\n"
+ "\n"
+ " CONFIGURATION SECTION.\n"
+ "\n"
+ " SOURCE-COMPUTER. TANDEM.\n"
+ " OBJECT-COMPUTER. TANDEM.\n"
+ "\n"
+ "\n"
+ "/\n"
+ " DATA DIVISION.\n"
+ "***************\n"
+ "\n"
+ "\n"
+ " WORKING-STORAGE SECTION.\n"
+ "\n"
+ "/\n"
+ "*LOCAL WORKING STORAGE\n"
+ "**********************\n"
+ "\n"
+ " 01 {$*W-RECEIVE-COUNT} PIC 9(04).\n"
+ " 01 {$*W-DOLLAR-ZERO-BUFFER-LENGTH} PIC 9(04) COMP.\n"
+ "\n"
+ "*MODULE LINKAGES.\n"
+ "*****************\n"
+ "\n"
+ " LINKAGE SECTION.\n"
+ "\n"
+ " PROCEDURE DIVISION.\n"
+ "********************\n"
+ "\n"
+ "\n"
+ " {@*MAIN-CONTROL} SECTION.\n"
+ " {#*MAIN-0}.\n"
+ "********************************************************************************\n"
+ "* *\n"
+ "* This section controls the overall processing within the module. *\n"
+ "* *\n"
+ "********************************************************************************\n"
+ "\n"
+ " PERFORM {@A-COMMON-INITIALISATION}\n"
+ "\n"
+ " PERFORM {@B-SPECIFIC-INITIALISATION}\n"
+ "\n"
+ " PERFORM {@C-PROCESS-REQUEST}\n"
+ " .\n"
+ " {#*MAIN-EXIT}.\n"
+ " EXIT PROGRAM.\n"
+ "/\n"
+ " {@*A-COMMON-INITIALISATION} SECTION.\n"
+ " {#*A-0}.\n"
+ "********************************************************************************\n"
+ "* *\n"
+ "* This section initialises standard control and event data. *\n"
+ "* *\n"
+ "********************************************************************************\n"
+ "\n"
+ " MOVE \"ABCDEFGHIJKLMNOQPRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWX\" TO {$W-DOLLAR-ZERO-BUFFER-LENGTH}\n"
+ " .\n"
+ "\n"
+ " {#*A-EXIT}.\n"
+ " EXIT.\n"
+ "/\n"
+ " {@*B-SPECIFIC-INITIALISATION} SECTION.\n"
+ " {#*B-0}.\n"
+ "********************************************************************************\n"
+ "* *\n"
+ "* This section is used to perform specific initialisation. *\n"
+ "* *\n"
+ "********************************************************************************\n"
+ "\n"
+ " CONTINUE\n"
+ " .\n"
+ " {#*B-EXIT}.\n"
+ " EXIT.\n"
+ "/\n"
+ " {@*C-PROCESS-REQUEST} SECTION.\n"
+ " {#*C-0}.\n"
+ "********************************************************************************\n"
+ "* *\n"
+ "* This section controls the processing of the request message received. *\n"
+ "* *\n"
+ "********************************************************************************\n"
+ "\n"
+ " CONTINUE\n"
+ " .\n"
+ " {#*C-EXIT}.\n"
+ " EXIT.\n"
+ "/\n"
+ "\n"
+ "********************************************************************************\n"
+ "* E N D O F P R O G R A M *\n"
+ "********************************************************************************";

@Test
void test() {
UseCaseEngine.runTest(TEXT, ImmutableList.of(), ImmutableMap.of(), CobolLanguageId.HP_COBOL);
}
}
Loading
Loading