-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from davelopez/improve_symbols_provider
Improve symbols provider
- Loading branch information
Showing
22 changed files
with
491 additions
and
146 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { SymbolKind } from "@gxwf/server-common/src/languageTypes"; | ||
import { SymbolsProviderBase } from "@gxwf/server-common/src/providers/symbolsProvider"; | ||
import { injectable } from "inversify"; | ||
|
||
@injectable() | ||
export class GxFormat2WorkflowSymbolsProvider extends SymbolsProviderBase { | ||
constructor() { | ||
super(); | ||
this.stepContainerNames = new Set(["inputs", "outputs", "steps"]); | ||
} | ||
|
||
protected override getSymbolKind(nodeType: string): SymbolKind { | ||
switch (nodeType) { | ||
case "doc": | ||
return SymbolKind.String; | ||
case "path": | ||
return SymbolKind.File; | ||
} | ||
return super.getSymbolKind(nodeType); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
server/gx-workflow-ls-format2/tests/integration/symbols.test.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,50 @@ | ||
import { DocumentSymbol } from "@gxwf/server-common/src/languageTypes"; | ||
|
||
import "reflect-metadata"; | ||
import { GxFormat2WorkflowSymbolsProvider } from "../../src/services/symbols"; | ||
import { createFormat2WorkflowDocument } from "../testHelpers"; | ||
|
||
describe("Format2 Workflow Symbols Provider", () => { | ||
let provider: GxFormat2WorkflowSymbolsProvider; | ||
beforeAll(() => { | ||
provider = new GxFormat2WorkflowSymbolsProvider(); | ||
}); | ||
|
||
function getSymbols(contents: string): DocumentSymbol[] { | ||
const documentContext = createFormat2WorkflowDocument(contents); | ||
return provider.getSymbols(documentContext); | ||
} | ||
|
||
it("should return symbols for a workflow", () => { | ||
const content = ` | ||
class: GalaxyWorkflow | ||
inputs: | ||
input_1: data | ||
input_2: | ||
type: File | ||
doc: This is the input 2 | ||
the_collection: | ||
type: collection | ||
doc: This is a collection | ||
input_int: integer | ||
text_param: | ||
optional: true | ||
default: text value | ||
restrictOnConnections: true | ||
type: text | ||
`; | ||
const symbols = getSymbols(content); | ||
expect(symbols.length).toBe(2); | ||
const classSymbol = symbols[0]; | ||
expect(classSymbol.name).toBe("class"); | ||
expect(classSymbol.detail).toBe("GalaxyWorkflow"); | ||
const inputsSymbol = symbols[1]; | ||
expect(inputsSymbol.name).toBe("inputs"); | ||
expect(inputsSymbol.children?.length).toBe(5); | ||
expect(inputsSymbol.children?.at(0)?.name).toBe("input_1"); | ||
expect(inputsSymbol.children?.at(1)?.name).toBe("input_2"); | ||
expect(inputsSymbol.children?.at(2)?.name).toBe("the_collection"); | ||
expect(inputsSymbol.children?.at(3)?.name).toBe("input_int"); | ||
expect(inputsSymbol.children?.at(4)?.name).toBe("text_param"); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { SymbolsProviderBase } from "@gxwf/server-common/src/providers/symbolsProvider"; | ||
import { PropertyASTNode } from "@gxwf/yaml-language-service/src/parser/astTypes"; | ||
import { injectable } from "inversify"; | ||
|
||
@injectable() | ||
export class NativeWorkflowSymbolsProvider extends SymbolsProviderBase { | ||
constructor() { | ||
super(); | ||
this.symbolNamesToIgnore = new Set([ | ||
"a_galaxy_workflow", | ||
"position", | ||
"uuid", | ||
"errors", | ||
"format-version", | ||
"version", | ||
]); | ||
this.stepContainerNames = new Set(["steps"]); | ||
} | ||
|
||
protected getSymbolName(property: PropertyASTNode): string { | ||
if (this.isStepProperty(property)) { | ||
return this.getNodeName(property.valueNode) ?? "unnamed"; | ||
} | ||
return super.getSymbolName(property); | ||
} | ||
} |
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,43 @@ | ||
import { NativeWorkflowSymbolsProvider } from "../../src/services/symbols"; | ||
import { createNativeWorkflowDocument } from "../testHelpers"; | ||
import { TestWorkflowProvider } from "../testWorkflowProvider"; | ||
|
||
describe("Native Format Symbols Provider", () => { | ||
let provider: NativeWorkflowSymbolsProvider; | ||
|
||
beforeEach(() => { | ||
provider = new NativeWorkflowSymbolsProvider(); | ||
}); | ||
|
||
it("should not provide symbols that must be ignored", () => { | ||
const ignoredSymbols = new Set(["a_galaxy_workflow", "position", "format-version", "version"]); | ||
const wfContent = TestWorkflowProvider.workflows.validation.withThreeSteps; | ||
const wfDocument = createNativeWorkflowDocument(wfContent); | ||
// The ignored nodes exist in the document | ||
ignoredSymbols.forEach((ignoredSymbol) => { | ||
const ignoredSymbolExists = wfContent.includes(ignoredSymbol); | ||
expect(ignoredSymbolExists).toBeTruthy(); | ||
}); | ||
// but they should not be included in the symbols | ||
const symbols = provider.getSymbols(wfDocument); | ||
expect(symbols).not.toBeNull(); | ||
symbols.forEach((symbol) => { | ||
expect(ignoredSymbols.has(symbol.name)).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
it("should provide symbols for all steps with names", () => { | ||
const wfContent = TestWorkflowProvider.workflows.validation.withThreeSteps; | ||
const wfDocument = createNativeWorkflowDocument(wfContent); | ||
const symbols = provider.getSymbols(wfDocument); | ||
expect(symbols).not.toBeNull(); | ||
const stepsSymbol = symbols.find((symbol) => symbol.name === "steps"); | ||
expect(stepsSymbol).toBeDefined(); | ||
expect(stepsSymbol?.children).toBeDefined(); | ||
expect(stepsSymbol?.children?.length).toBe(3); | ||
const stepNames = ["Input dataset", "Input dataset", "Concatenate datasets"]; | ||
stepsSymbol?.children?.forEach((step, i) => { | ||
expect(step.name).toBe(stepNames[i]); | ||
}); | ||
}); | ||
}); |
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
10 changes: 3 additions & 7 deletions
10
...ommon/src/providers/completionProvider.ts → ...common/src/providers/completionHandler.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
22 changes: 9 additions & 13 deletions
22
...ommon/src/providers/formattingProvider.ts → ...common/src/providers/formattingHandler.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
Oops, something went wrong.