-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
157 additions
and
19 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
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
49 changes: 49 additions & 0 deletions
49
libs/language-server/capabilities/code-completion/src/lib/input-name-completion.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,49 @@ | ||
import { nxWorkspace } from '@nx-console/workspace'; | ||
import { | ||
ASTNode, | ||
CompletionItem, | ||
CompletionItemKind, | ||
TextDocument, | ||
} from 'vscode-json-languageservice'; | ||
import { createCompletionItem } from './create-completion-path-item'; | ||
|
||
export async function inputNameCompletion( | ||
workingPath: string | undefined, | ||
node: ASTNode, | ||
document: TextDocument, | ||
hasDependencyHat = false | ||
): Promise<CompletionItem[]> { | ||
if (!workingPath) { | ||
return []; | ||
} | ||
|
||
const inputNameCompletion: CompletionItem[] = []; | ||
|
||
const { workspace } = await nxWorkspace(workingPath); | ||
|
||
for (const inputName of Object.keys(workspace.namedInputs ?? {})) { | ||
if (hasDependencyHat) { | ||
inputNameCompletion.push( | ||
createCompletionItem( | ||
`^${inputName}`, | ||
'', | ||
node, | ||
document, | ||
CompletionItemKind.Property, | ||
`Base "${inputName}" on this project's dependencies` | ||
) | ||
); | ||
} | ||
inputNameCompletion.push( | ||
createCompletionItem( | ||
inputName, | ||
'', | ||
node, | ||
document, | ||
CompletionItemKind.Property | ||
) | ||
); | ||
} | ||
|
||
return inputNameCompletion; | ||
} |
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
2 changes: 1 addition & 1 deletion
2
libs/language-server/capabilities/code-completion/src/lib/tags-completion.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
56 changes: 56 additions & 0 deletions
56
libs/language-server/capabilities/code-completion/src/lib/targets-completion.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,56 @@ | ||
import { nxWorkspace } from '@nx-console/workspace'; | ||
import { | ||
ASTNode, | ||
CompletionItem, | ||
CompletionItemKind, | ||
TextDocument, | ||
} from 'vscode-json-languageservice'; | ||
import { createCompletionItem } from './create-completion-path-item'; | ||
|
||
export async function targetsCompletion( | ||
workingPath: string | undefined, | ||
node: ASTNode, | ||
document: TextDocument, | ||
hasDependencyHat = false | ||
): Promise<CompletionItem[]> { | ||
if (!workingPath) { | ||
return []; | ||
} | ||
|
||
const targetsCompletion: CompletionItem[] = []; | ||
const { workspace } = await nxWorkspace(workingPath); | ||
|
||
const targetNames = new Set<string>(); | ||
for (const project of Object.values(workspace.projects)) { | ||
for (const targetName of Object.keys(project.targets ?? {})) { | ||
targetNames.add(targetName); | ||
} | ||
} | ||
|
||
for (const targetName of targetNames) { | ||
if (hasDependencyHat) { | ||
targetsCompletion.push( | ||
createCompletionItem( | ||
`^${targetName}`, | ||
'', | ||
node, | ||
document, | ||
CompletionItemKind.Field, | ||
`Run all dependencies that have "${targetName}" as a target before this one` | ||
) | ||
); | ||
} | ||
targetsCompletion.push( | ||
createCompletionItem( | ||
targetName, | ||
'', | ||
node, | ||
document, | ||
CompletionItemKind.Field, | ||
`Run the "${targetName}" target before this one` | ||
) | ||
); | ||
} | ||
|
||
return targetsCompletion; | ||
} |
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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
export class NxWorkspaceRefresh { | ||
static type: 'nx/refreshWorkspace'; | ||
} | ||
import { RequestType, NotificationType } from 'vscode-languageserver/node'; | ||
import type { NxWorkspaceConfiguration } from '@nx-console/workspace'; | ||
|
||
export class NxWorkspace { | ||
static type: 'nx/workspace'; | ||
} | ||
export const NxWorkspaceRefreshNotification: NotificationType<void> = | ||
new NotificationType('nx/refreshWorkspace'); | ||
|
||
export const NxWorkspaceRequest: RequestType< | ||
void, | ||
NxWorkspaceConfiguration, | ||
unknown | ||
> = new RequestType('nx/workspace'); |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './lib/workspace'; | ||
export * from './lib/find-project-with-path'; | ||
export type { NxWorkspaceConfiguration } from './lib/get-nx-workspace-config'; |