Skip to content

Commit

Permalink
fix: fix db2 sql host variable hover over and go to definition eclips…
Browse files Browse the repository at this point in the history
…e-che4z#2310

Signed-off-by: ap891843 <aman.prashant@broadcom.com>
  • Loading branch information
ap891843 committed Jul 18, 2024
1 parent 4980657 commit b8f8395
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.eclipse.lsp.cobol.common.model.Locality;
import org.eclipse.lsp.cobol.common.model.tree.Node;
import org.eclipse.lsp.cobol.common.model.tree.variable.*;
import org.eclipse.lsp.cobol.common.utils.RangeUtils;
import org.eclipse.lsp.cobol.core.visitor.VisitorHelper;
import org.eclipse.lsp.cobol.implicitDialects.sql.node.*;
import org.eclipse.lsp4j.Location;
Expand Down Expand Up @@ -439,9 +438,9 @@ private List<Node> addVariableUsageNodes(ParserRuleContext ctx) {
if (Db2SqlVisitorHelper.isGroupName(name)) {
Locality locality =
VisitorHelper.buildNameRangeLocality(ctx, name, context.getExtendedDocument().getUri());
locality.setRange(
RangeUtils.shiftRangeWithPosition(
new Position(ctx.start.getLine() - 1, (hasColumn ? 1 : 0)), locality.getRange()));
// locality.setRange(
// RangeUtils.shiftRangeWithPosition(
// new Position(ctx.start.getLine() - 1, (hasColumn ? 1 : 0)), locality.getRange()));

return Db2SqlVisitorHelper.generateGroupNodes(name, locality);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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.sql;

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

public class TestSqlHostVariableVariableLocation {
public static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. hostvariales.\n"
+ " ENVIRONMENT DIVISION.\n"
+ " CONFIGURATION SECTION.\n"
+ " SPECIAL-NAMES.\n"
+ " INPUT-OUTPUT SECTION.\n"
+ " FILE-CONTROL.\n"
+ " DATA DIVISION.\n"
+ " FILE SECTION.\n"
+ " WORKING-STORAGE SECTION.\n"
+ " 01 {$*ASD}.\n"
+ " 05 {$*O-P-R} PIC X.\n"
+ " 01 {$*QWE}.\n"
+ " 05 {$*D-E-F} PIC X.\n"
+ " LINKAGE SECTION.\n"
+ " PROCEDURE DIVISION.\n"
+ " {@*MAIN-PROCESSING} SECTION.\n"
+ " {#*MAINLINE-PARAGRAPH}.\n"
+ " EXEC SQL\n"
+ " UPDATE QWE_STATUS\n"
+ " SET A_B_C = :{$QWE}.{$D-E-F}\n"
+ " WHERE TKN_UNIQUE_REFERENCE = :{$ASD}.{$O-P-R}\n"
+ " END-EXEC \n"
+ " STOP RUN.";

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

0 comments on commit b8f8395

Please sign in to comment.