Skip to content
Open
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
9 changes: 8 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@
"@typescript-eslint/no-non-null-assertion": "error",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"no-control-regex": "off"
"no-control-regex": "off",
"@typescript-eslint/consistent-type-imports": [
"error",
{
"prefer": "type-imports",
"fixStyle": "separate-type-imports"
}
]
},
"overrides": [
{
Expand Down
16 changes: 9 additions & 7 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 @@ -113,7 +113,7 @@
"glob": "13.0.6",
"husky": "9.1.7",
"lint-staged": "^17.0.0",
"mocha": "11.6.0",
"mocha": "11.8.0",
"node-gyp": "^13.0.0",
"prettier": "3.9.6",
"react": "19.2.8",
Expand Down
2 changes: 1 addition & 1 deletion src/gherkin/extractStepTexts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { walkGherkinDocument } from '@cucumber/gherkin-utils'
import { GherkinDocument } from '@cucumber/messages'
import type { GherkinDocument } from '@cucumber/messages'

export function extractStepTexts(
gherkinDocument: GherkinDocument,
Expand Down
6 changes: 4 additions & 2 deletions src/gherkin/parseGherkinDocument.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { AstBuilder, Errors, GherkinClassicTokenMatcher, Parser } from '@cucumber/gherkin'
import { GherkinDocument, IdGenerator } from '@cucumber/messages'
import type { Errors } from '@cucumber/gherkin'
import { AstBuilder, GherkinClassicTokenMatcher, Parser } from '@cucumber/gherkin'
import type { GherkinDocument } from '@cucumber/messages'
import { IdGenerator } from '@cucumber/messages'

const uuidFn = IdGenerator.uuid()

Expand Down
4 changes: 2 additions & 2 deletions src/index/bruteForceIndex.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Suggestion } from '../suggestions/types.js'
import { Index } from './types'
import type { Suggestion } from '../suggestions/types.js'
import type { Index } from './types'

/**
* A brute force (not very performant or fuzzy-search capable) index that matches permutation expressions with string.includes()
Expand Down
4 changes: 2 additions & 2 deletions src/index/fuseIndex.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Fuse from 'fuse.js'

import { Suggestion } from '../suggestions/types.js'
import { Index } from './types.js'
import type { Suggestion } from '../suggestions/types.js'
import type { Index } from './types.js'

type Doc = {
text: string
Expand Down
4 changes: 2 additions & 2 deletions src/index/jsSearchIndex.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Search } from 'js-search'

import { Suggestion } from '../suggestions/types.js'
import { Index } from './types.js'
import type { Suggestion } from '../suggestions/types.js'
import type { Index } from './types.js'

type Doc = {
id: number
Expand Down
2 changes: 1 addition & 1 deletion src/index/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* @param text a text to search for
* @return results in the form of suggestions
*/
import { Suggestion } from '../suggestions/types.js'
import type { Suggestion } from '../suggestions/types.js'

export type Index = (text: string) => readonly Suggestion[]
9 changes: 3 additions & 6 deletions src/language/ExpressionBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import {
ExpressionFactory,
ParameterType,
ParameterTypeRegistry,
} from '@cucumber/cucumber-expressions'
import type { ParameterType } from '@cucumber/cucumber-expressions'
import { ExpressionFactory, ParameterTypeRegistry } from '@cucumber/cucumber-expressions'

import { createLocationLink, makeParameterType, sortLinks } from './helpers.js'
import { SourceAnalyzer } from './SourceAnalyzer.js'
import {
import type {
ExpressionBuilderResult,
ExpressionLink,
LanguageName,
Expand Down
6 changes: 3 additions & 3 deletions src/language/SourceAnalyzer.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { RegExps, StringOrRegExp } from '@cucumber/cucumber-expressions'
import { LocationLink } from 'vscode-languageserver-types'
import type { RegExps, StringOrRegExp } from '@cucumber/cucumber-expressions'
import type { LocationLink } from 'vscode-languageserver-types'

import { createLocationLink, makeParameterType, syntaxNode } from './helpers.js'
import { getLanguage } from './languages.js'
import {
import type {
Language,
LanguageName,
ParameterTypeLink,
Expand Down
4 changes: 2 additions & 2 deletions src/language/csharpLanguage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { StringOrRegExp } from '@cucumber/cucumber-expressions'
import type { StringOrRegExp } from '@cucumber/cucumber-expressions'

import { childrenToString, NO_QUOTES } from './helpers.js'
import { Language, TreeSitterSyntaxNode } from './types.js'
import type { Language, TreeSitterSyntaxNode } from './types.js'

export const csharpLanguage: Language = {
toParameterTypeName(node: TreeSitterSyntaxNode) {
Expand Down
4 changes: 2 additions & 2 deletions src/language/goLanguage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { StringOrRegExp } from '@cucumber/cucumber-expressions'
import type { StringOrRegExp } from '@cucumber/cucumber-expressions'

import { unsupportedOperation } from './helpers.js'
import { Language, TreeSitterSyntaxNode } from './types.js'
import type { Language, TreeSitterSyntaxNode } from './types.js'

export const goLanguage: Language = {
toParameterTypeName: unsupportedOperation,
Expand Down
8 changes: 5 additions & 3 deletions src/language/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { ParameterType, RegExps } from '@cucumber/cucumber-expressions'
import { DocumentUri, LocationLink, Range } from 'vscode-languageserver-types'
import type { RegExps } from '@cucumber/cucumber-expressions'
import { ParameterType } from '@cucumber/cucumber-expressions'
import type { DocumentUri, LocationLink } from 'vscode-languageserver-types'
import { Range } from 'vscode-languageserver-types'

import { Link, NodePredicate, TreeSitterQueryMatch, TreeSitterSyntaxNode } from './types'
import type { Link, NodePredicate, TreeSitterQueryMatch, TreeSitterSyntaxNode } from './types'

export function syntaxNode(match: TreeSitterQueryMatch, name: string): TreeSitterSyntaxNode | null {
const nodes = syntaxNodes(match, name)
Expand Down
2 changes: 1 addition & 1 deletion src/language/javaLanguage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language, TreeSitterSyntaxNode } from './types.js'
import type { Language, TreeSitterSyntaxNode } from './types.js'

export const javaLanguage: Language = {
toParameterTypeName(node) {
Expand Down
2 changes: 1 addition & 1 deletion src/language/javascriptLanguage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { tsxLanguage } from './tsxLanguage.js'
import { Language } from './types.js'
import type { Language } from './types.js'

export const javascriptLanguage: Language = {
...tsxLanguage,
Expand Down
2 changes: 1 addition & 1 deletion src/language/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { rubyLanguage } from './rubyLanguage.js'
import { rustLanguage } from './rustLanguage.js'
import { scalaLanguage } from './scalaLanguage.js'
import { tsxLanguage } from './tsxLanguage.js'
import { Language, LanguageName } from './types.js'
import type { Language, LanguageName } from './types.js'

const languageByName: Record<LanguageName, Language> = {
java: javaLanguage,
Expand Down
2 changes: 1 addition & 1 deletion src/language/phpLanguage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { unsupportedOperation } from './helpers.js'
import { Language } from './types.js'
import type { Language } from './types.js'

export const phpLanguage: Language = {
toParameterTypeName: unsupportedOperation,
Expand Down
4 changes: 2 additions & 2 deletions src/language/pythonLanguage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RegExps, StringOrRegExp } from '@cucumber/cucumber-expressions'
import type { RegExps, StringOrRegExp } from '@cucumber/cucumber-expressions'

import { Language, TreeSitterSyntaxNode } from './types.js'
import type { Language, TreeSitterSyntaxNode } from './types.js'

export const pythonLanguage: Language = {
toParameterTypeName(node: TreeSitterSyntaxNode): string {
Expand Down
6 changes: 3 additions & 3 deletions src/language/rubyLanguage.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { StringOrRegExp } from '@cucumber/cucumber-expressions'
import { RegExps } from '@cucumber/cucumber-expressions/dist/cjs/src/ParameterType'
import type { StringOrRegExp } from '@cucumber/cucumber-expressions'
import type { RegExps } from '@cucumber/cucumber-expressions/dist/cjs/src/ParameterType'

import { childrenToString, filter, NO_QUOTES } from './helpers.js'
import { Language, NodePredicate, TreeSitterSyntaxNode } from './types.js'
import type { Language, NodePredicate, TreeSitterSyntaxNode } from './types.js'

export const rubyLanguage: Language = {
toParameterTypeName(node) {
Expand Down
2 changes: 1 addition & 1 deletion src/language/rustLanguage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language, TreeSitterSyntaxNode } from './types.js'
import type { Language, TreeSitterSyntaxNode } from './types.js'

export const rustLanguage: Language = {
toParameterTypeName(node) {
Expand Down
2 changes: 1 addition & 1 deletion src/language/scalaLanguage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language, TreeSitterSyntaxNode } from './types.js'
import type { Language, TreeSitterSyntaxNode } from './types.js'

export const scalaLanguage: Language = {
toParameterTypeName(node) {
Expand Down
6 changes: 3 additions & 3 deletions src/language/tsxLanguage.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { StringOrRegExp } from '@cucumber/cucumber-expressions'
import { RegExps } from '@cucumber/cucumber-expressions'
import type { StringOrRegExp } from '@cucumber/cucumber-expressions'
import type { RegExps } from '@cucumber/cucumber-expressions'

import { childrenToString, filter, NO_QUOTES } from './helpers.js'
import { NO_EXPRESSION } from './SourceAnalyzer.js'
import { Language, TreeSitterSyntaxNode } from './types.js'
import type { Language, TreeSitterSyntaxNode } from './types.js'

export const tsxLanguage: Language = {
toParameterTypeName(node) {
Expand Down
6 changes: 3 additions & 3 deletions src/language/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
import type {
Expression,
ParameterType,
ParameterTypeRegistry,
StringOrRegExp,
} from '@cucumber/cucumber-expressions'
import { RegExps } from '@cucumber/cucumber-expressions/dist/cjs/src/ParameterType'
import { DocumentUri, LocationLink } from 'vscode-languageserver-types'
import type { RegExps } from '@cucumber/cucumber-expressions/dist/cjs/src/ParameterType'
import type { DocumentUri, LocationLink } from 'vscode-languageserver-types'

export type ParameterTypeName =
| 'int'
Expand Down
7 changes: 4 additions & 3 deletions src/messages/MessagesBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import type { Expression } from '@cucumber/cucumber-expressions'
import {
Expression,
ExpressionFactory,
ParameterType,
ParameterTypeRegistry,
} from '@cucumber/cucumber-expressions'
import { Envelope, StepDefinitionPatternType } from '@cucumber/messages'
import type { Envelope } from '@cucumber/messages'
import { StepDefinitionPatternType } from '@cucumber/messages'

import { extractStepTexts } from '../gherkin/extractStepTexts.js'
import { buildSuggestions } from '../suggestions/buildSuggestions.js'
import { Suggestion } from '../suggestions/types.js'
import type { Suggestion } from '../suggestions/types.js'

export type MessagesBuilderResult = {
suggestions: readonly Suggestion[]
Expand Down
9 changes: 4 additions & 5 deletions src/service/getGenerateSnippetCodeAction.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { CucumberExpressionGenerator, ParameterTypeRegistry } from '@cucumber/cucumber-expressions'
import type { ParameterTypeRegistry } from '@cucumber/cucumber-expressions'
import { CucumberExpressionGenerator } from '@cucumber/cucumber-expressions'
import type { CodeAction, Diagnostic, LocationLink } from 'vscode-languageserver-types'
import {
CodeAction,
CodeActionKind,
CreateFile,
Diagnostic,
LocationLink,
TextDocumentEdit,
TextEdit,
VersionedTextDocumentIdentifier,
} from 'vscode-languageserver-types'

import { getLanguage } from '../language/languages.js'
import { LanguageName } from '../language/types.js'
import type { LanguageName } from '../language/types.js'
import { diagnosticCodeUndefinedStep } from './constants.js'
import { stepDefinitionSnippet } from './snippet/stepDefinitionSnippet.js'

Expand Down
10 changes: 3 additions & 7 deletions src/service/getGherkinCompletionItems.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import {
CompletionItem,
CompletionItemKind,
InsertTextFormat,
Position,
} from 'vscode-languageserver-types'
import type { CompletionItem, Position } from 'vscode-languageserver-types'
import { CompletionItemKind, InsertTextFormat } from 'vscode-languageserver-types'

import { Index } from '../index/index.js'
import type { Index } from '../index/index.js'
import { getStepRange } from './helpers.js'
import { lspCompletionSnippet } from './snippet/lspCompletionSnippet.js'

Expand Down
7 changes: 4 additions & 3 deletions src/service/getGherkinDiagnostics.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Expression } from '@cucumber/cucumber-expressions'
import type { Expression } from '@cucumber/cucumber-expressions'
import { dialects, Errors } from '@cucumber/gherkin'
import { walkGherkinDocument } from '@cucumber/gherkin-utils'
import * as messages from '@cucumber/messages'
import { Diagnostic, DiagnosticSeverity } from 'vscode-languageserver-types'
import type * as messages from '@cucumber/messages'
import type { Diagnostic } from 'vscode-languageserver-types'
import { DiagnosticSeverity } from 'vscode-languageserver-types'

import { parseGherkinDocument } from '../gherkin/parseGherkinDocument.js'
import { CONTAINS_PARAMETERS, diagnosticCodeUndefinedStep } from './constants.js'
Expand Down
5 changes: 3 additions & 2 deletions src/service/getGherkinDocumentFeatureSymbol.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { walkGherkinDocument } from '@cucumber/gherkin-utils'
import * as messages from '@cucumber/messages'
import { DocumentSymbol, Position, Range, SymbolKind } from 'vscode-languageserver-types'
import type * as messages from '@cucumber/messages'
import type { DocumentSymbol } from 'vscode-languageserver-types'
import { Position, Range, SymbolKind } from 'vscode-languageserver-types'

import { parseGherkinDocument } from '../gherkin/parseGherkinDocument.js'

Expand Down
2 changes: 1 addition & 1 deletion src/service/getGherkinFormattingEdits.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { pretty } from '@cucumber/gherkin-utils'
import { TextEdit } from 'vscode-languageserver-types'
import type { TextEdit } from 'vscode-languageserver-types'

import { parseGherkinDocument } from '../gherkin/parseGherkinDocument.js'

Expand Down
7 changes: 4 additions & 3 deletions src/service/getGherkinSemanticTokens.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Expression } from '@cucumber/cucumber-expressions'
import type { Expression } from '@cucumber/cucumber-expressions'
import { walkGherkinDocument } from '@cucumber/gherkin-utils'
import * as messages from '@cucumber/messages'
import { SemanticTokens, SemanticTokenTypes } from 'vscode-languageserver-types'
import type * as messages from '@cucumber/messages'
import type { SemanticTokens } from 'vscode-languageserver-types'
import { SemanticTokenTypes } from 'vscode-languageserver-types'

import { parseGherkinDocument } from '../gherkin/parseGherkinDocument.js'

Expand Down
4 changes: 2 additions & 2 deletions src/service/getStepDefinitionLocationLinks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LocationLink, Position } from 'vscode-languageserver-types'
import type { LocationLink, Position } from 'vscode-languageserver-types'

import { ExpressionLink } from '../language/types.js'
import type { ExpressionLink } from '../language/types.js'
import { getStepRange } from './helpers.js'

export function getStepDefinitionLocationLinks(
Expand Down
3 changes: 2 additions & 1 deletion src/service/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { walkGherkinDocument } from '@cucumber/gherkin-utils'
import { Position, Range } from 'vscode-languageserver-types'
import type { Position } from 'vscode-languageserver-types'
import { Range } from 'vscode-languageserver-types'

import { parseGherkinDocument } from '../gherkin/parseGherkinDocument.js'

Expand Down
2 changes: 1 addition & 1 deletion src/service/snippet/lspCompletionSnippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @param expression the expression to generate the snippet from
*/
import { SuggestionSegments } from '../../suggestions/types.js'
import type { SuggestionSegments } from '../../suggestions/types.js'

export function lspCompletionSnippet(segments: SuggestionSegments): string {
let n = 1
Expand Down
Loading