Skip to content

Commit

Permalink
Merge pull request #67 from cucumber/document-symbols
Browse files Browse the repository at this point in the history
Add support for document symbols
  • Loading branch information
aslakhellesoy authored Oct 10, 2022
2 parents cd38347 + 06dbbb0 commit 48f00c6
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- Fix rust snippet fn name to lowercase ([#103](https://github.com/cucumber/language-service/issues/103), [#104](https://github.com/cucumber/language-service/pull/104))

### Added
- Add support for [document symbols](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_documentSymbol) ([#98](https://github.com/cucumber/language-service/issues/98), [#106](https://github.com/cucumber/language-service/pull/106))
- (Java) Recognise regexps with `(?i)`, with the caveat that the resulting JavaScript `RegExp` is _not_ case insensitive ([#100](https://github.com/cucumber/language-service/issues/100), [#108](https://github.com/cucumber/language-service/pull/108))
- (TypeScript) Add support for template literals without subsitutions. ([#101](https://github.com/cucumber/language-service/issues/101), [#107](https://github.com/cucumber/language-service/pull/107))

## [1.0.0] - 2022-10-05
### Added
- Support for [Cucumber Rust](https://github.com/cucumber-rs/cucumber) ([#82](https://github.com/cucumber/language-service/issues/82), [#99](https://github.com/cucumber/language-service/pull/99))
Expand Down
77 changes: 66 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
},
"dependencies": {
"@cucumber/gherkin-utils": "^8.0.0",
"@cucumber/language-service": "^1.0.1",
"@cucumber/language-service": "^1.1.0",
"fast-glob": "3.2.12",
"source-map-support": "0.5.21",
"vscode-languageserver": "8.0.2",
Expand Down
16 changes: 16 additions & 0 deletions src/CucumberLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
getGenerateSnippetCodeAction,
getGherkinCompletionItems,
getGherkinDiagnostics,
getGherkinDocumentFeatureSymbol,
getGherkinFormattingEdits,
getGherkinSemanticTokens,
getStepDefinitionLocationLinks,
Expand Down Expand Up @@ -261,6 +262,18 @@ export class CucumberLanguageServer {
connection.console.info('onDefinition is disabled')
}

if (params.capabilities.textDocument?.documentSymbol) {
connection.onDocumentSymbol((params) => {
const doc = documents.get(params.textDocument.uri)
if (!doc) return []
const gherkinSource = doc.getText()
const symbol = getGherkinDocumentFeatureSymbol(gherkinSource)
return symbol ? [symbol] : null
})
} else {
connection.console.info('onDocumentSymbol is disabled')
}

return {
capabilities: this.capabilities(),
serverInfo: this.info(),
Expand Down Expand Up @@ -311,6 +324,9 @@ export class CucumberLanguageServer {
tokenModifiers: [],
},
},
documentSymbolProvider: {
label: 'Cucumber',
},
documentFormattingProvider: true,
definitionProvider: true,
}
Expand Down

0 comments on commit 48f00c6

Please sign in to comment.