Setup CodeActions and add quickfix for missing inputs (#254)
* Setup CodeActions and add quickfix for missing inputs * PR feedback * Update languageservice/src/code-actions/quickfix/add-missing-inputs.ts Co-authored-by: Salman Chishti <[email protected]> * Fix indentSize detection for code actions after rebase - Add indentSize to MissingInputsDiagnosticData interface - Pass indentSize parameter from validate.ts to validateActionReference - Detect indentSize from workflow structure (jobs key to first child) - Fall back to detecting from with: block children when available * update typescript * formatting * linting * Gate missing inputs quickfix behind feature flag * Address PR review: rename files, move position calculation to quickfix - Rename index.ts files to follow repo patterns: - code-actions/index.ts → code-actions/code-actions.ts - code-actions/quickfix/index.ts → quickfix/quickfix-providers.ts - Move position calculation from validation to quickfix: - MissingInputsDiagnosticData now passes raw token ranges - Quickfix computes insertion position and indentation at code action time - detectIndentSize moved from validate.ts to validate-action-reference.ts * wip * Remove pointless comment --------- Co-authored-by: Salman Chishti <[email protected]>
This commit is contained in:
co-authored by
Salman Chishti
parent
67dd4fbd61
commit
0fe31c6656
@@ -1,8 +1,18 @@
|
||||
import {documentLinks, getInlayHints, hover, validate, ValidationConfig} from "@actions/languageservice";
|
||||
import {
|
||||
documentLinks,
|
||||
getCodeActions,
|
||||
getInlayHints,
|
||||
hover,
|
||||
validate,
|
||||
ValidationConfig
|
||||
} from "@actions/languageservice";
|
||||
import {registerLogger, setLogLevel} from "@actions/languageservice/log";
|
||||
import {clearCache, clearCacheEntry} from "@actions/languageservice/utils/workflow-cache";
|
||||
import {Octokit} from "@octokit/rest";
|
||||
import {
|
||||
CodeAction,
|
||||
CodeActionKind,
|
||||
CodeActionParams,
|
||||
CompletionItem,
|
||||
Connection,
|
||||
DocumentLink,
|
||||
@@ -79,7 +89,10 @@ export function initConnection(connection: Connection) {
|
||||
documentLinkProvider: {
|
||||
resolveProvider: false
|
||||
},
|
||||
inlayHintProvider: true
|
||||
inlayHintProvider: true,
|
||||
codeActionProvider: {
|
||||
codeActionKinds: [CodeActionKind.QuickFix]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -177,6 +190,17 @@ export function initConnection(connection: Connection) {
|
||||
});
|
||||
});
|
||||
|
||||
connection.onCodeAction((params: CodeActionParams): CodeAction[] => {
|
||||
const document = getDocument(documents, params.textDocument);
|
||||
return getCodeActions({
|
||||
uri: params.textDocument.uri,
|
||||
documentContent: document.getText(),
|
||||
diagnostics: params.context.diagnostics,
|
||||
only: params.context.only,
|
||||
featureFlags
|
||||
});
|
||||
});
|
||||
|
||||
// Make the text document manager listen on the connection
|
||||
// for open, change and close text document events
|
||||
documents.listen(connection);
|
||||
|
||||
Reference in New Issue
Block a user