-
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.
Feature support multiple lang id (#2256)
* feat: make cobol code layout configurable Signed-off-by: Aman Prashant <aman.prashant@broadcom.com> * feat: adjust editor rulers as per the layout settings Signed-off-by: Aman Prashant <aman.prashant@broadcom.com> * feat: introduce languageId to the language server engine Signed-off-by: Aman Prashant <aman.prashant@broadcom.com> * chore: resolve merge conflicts Signed-off-by: Aman Prashant <aman.prashant@broadcom.com> * build: increase UI coverage to pass build Signed-off-by: Aman Prashant <aman.prashant@broadcom.com> * build: fix tests Signed-off-by: Aman Prashant <aman.prashant@broadcom.com> * chore: add syntax files to the vsix Signed-off-by: Aman Prashant <aman.prashant@broadcom.com> * Enable HP Cobol copybooks * Prepare for code refactor * Remove unused import * Minor changes * Fix tests * Fix tests --------- Signed-off-by: Aman Prashant <aman.prashant@broadcom.com> Co-authored-by: Leonid Baranov <nurkambay@gmail.com>
- Loading branch information
Showing
95 changed files
with
2,656 additions
and
941 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
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
92 changes: 92 additions & 0 deletions
92
...nsion/src/__tests__/services/nativeLanguageClient/serverRuntimeCodeActionProvider.spec.ts
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,92 @@ | ||
/* | ||
* 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 | ||
*/ | ||
|
||
import * as vscode from "vscode"; | ||
import { Range } from "../../../__mocks__/vscode"; | ||
import { ServerRuntimeCodeActionProvider } from "../../../services/nativeLanguageClient/serverRuntimeCodeActionProvider"; | ||
|
||
jest.mock("../../../services/reporter/TelemetryService"); | ||
describe("Tests the server code actions", () => { | ||
it("checks that no code action is provided when diagnostics is empty", async () => { | ||
const codeActionProvider = new ServerRuntimeCodeActionProvider(); | ||
const { doc, context, token } = getCodeactionMockObjects([]); | ||
const codeActions = await codeActionProvider.provideCodeActions( | ||
doc, | ||
new Range(), | ||
context, | ||
token, | ||
); | ||
expect(codeActions.length).toBe(0); | ||
}); | ||
|
||
it("checks that no code action is provided when diagnostics is a syntax error and not a setup issue", async () => { | ||
const codeActionProvider = new ServerRuntimeCodeActionProvider(); | ||
const { doc, context, token } = getCodeactionMockObjects([ | ||
{ | ||
range: new Range(), | ||
message: "some syntax error", | ||
severity: 0, | ||
code: "syntax error", | ||
}, | ||
]); | ||
const codeActions = await codeActionProvider.provideCodeActions( | ||
doc, | ||
new Range(), | ||
context, | ||
token, | ||
); | ||
expect(codeActions.length).toBe(0); | ||
}); | ||
|
||
it("checks that code actions are provided when the diagnostics are related to the server type configuration", async () => { | ||
const codeActionProvider = new ServerRuntimeCodeActionProvider(); | ||
const { doc, context, token } = getCodeactionMockObjects([ | ||
{ | ||
range: new Range(), | ||
message: "server configuration error", | ||
severity: 0, | ||
code: "incompatible server type", | ||
}, | ||
]); | ||
(vscode.CodeActionKind as any) = { | ||
QuickFix: "quickfix", | ||
}; | ||
(vscode.CodeAction as any) = jest.fn(); | ||
const codeActions = await codeActionProvider.provideCodeActions( | ||
doc, | ||
new Range(), | ||
context, | ||
token, | ||
); | ||
expect(codeActions.length).toBe(2); | ||
}); | ||
}); | ||
|
||
function getCodeactionMockObjects(diagnostics: vscode.Diagnostic[]) { | ||
const doc = { | ||
uri: { fsPath: "ws-path" }, | ||
fileName: "test-file", | ||
lineAt: jest.fn().mockReturnValue({ text: "" }), | ||
} as any; | ||
const context = { | ||
triggerKind: 1, | ||
diagnostics: diagnostics, | ||
only: undefined, | ||
}; | ||
const token = { | ||
isCancellationRequested: false, | ||
onCancellationRequested: jest.fn(), | ||
}; | ||
return { doc, context, token }; | ||
} |
67 changes: 67 additions & 0 deletions
67
clients/cobol-lsp-vscode-extension/src/commands/UpdateCobolProgramRuler.ts
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,67 @@ | ||
// /* | ||
// * 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 | ||
// */ | ||
|
||
// import * as vscode from "vscode"; | ||
// import { SettingsService } from "../services/Settings"; | ||
// import { integer } from "vscode-languageclient"; | ||
|
||
// export interface LayoutStructure { | ||
// sequence_length?: integer; | ||
// indicator_length?: integer; | ||
// area_a_length?: integer; | ||
// area_b_length?: integer; | ||
// comment_area?: integer; | ||
// } | ||
|
||
// // export enum Layout { | ||
// // IBM = "IBM", | ||
// // HP = "HP" | ||
// // } | ||
|
||
// // export const layoutMappingObject: Record<string, LayoutStructure> = { | ||
// // [Layout.IBM]: { sequence_length: 6, indicator_length: 1, area_a_length: 4, area_b_length: 61, comment_area: 8 }, | ||
// // [Layout.HP]: { sequence_length: 0, indicator_length: 1, area_a_length: 4, area_b_length: 127, comment_area: 0 } | ||
// // } | ||
|
||
// // export function updateCobolEditorRuler() { | ||
// // const configuration = vscode.workspace.getConfiguration(); | ||
|
||
// // const rulers = SettingsService.getCobolProgramLayout(); | ||
// // const seqLen = rulers?.sequence_length ?? 6; | ||
// // const indcatorLen = rulers?.indicator_length ?? 1; | ||
// // const areaA = rulers?.area_a_length ?? 4; | ||
// // const areaB = rulers?.area_b_length ?? 61; | ||
// // const commentLen = rulers?.comment_area ?? 8; | ||
// // const rulerIndex = [ | ||
// // seqLen, | ||
// // seqLen + indcatorLen, | ||
// // seqLen + indcatorLen + areaA, | ||
// // seqLen + indcatorLen + areaA + areaB, | ||
// // seqLen + indcatorLen + areaA + areaB + commentLen, | ||
// // ]; | ||
// // const updatedRules = { | ||
// // ...(configuration.get("[cobol]") as { | ||
// // "editor.guides.indentation": integer; | ||
// // "editor.rulers": integer[]; | ||
// // "editor.wordSeparators": string; | ||
// // }), | ||
// // "editor.rulers": rulerIndex, | ||
// // }; | ||
// // configuration.update( | ||
// // "[cobol]", | ||
// // updatedRules, | ||
// // vscode.ConfigurationTarget.Workspace, | ||
// // true, | ||
// // ); | ||
// // } |
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
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
24 changes: 24 additions & 0 deletions
24
clients/cobol-lsp-vscode-extension/src/type/codeLayout.d.ts
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,24 @@ | ||
/* | ||
* 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 | ||
*/ | ||
|
||
/** | ||
* Type for a cobol code layout | ||
*/ | ||
interface LayoutStructure { | ||
sequence_length?: integer; | ||
indicator_length?: integer; | ||
area_a_length?: integer; | ||
area_b_length?: integer; | ||
comment_area?: integer; | ||
} |
Oops, something went wrong.