|
|
@ -29,39 +29,51 @@ export class RemixCodeActionProvider implements monaco.languages.CodeActionProvi |
|
|
|
const cursorPosition = this.props.editorAPI.getHoverPosition({lineNumber: error.startLineNumber, column: error.startColumn}) |
|
|
|
const cursorPosition = this.props.editorAPI.getHoverPosition({lineNumber: error.startLineNumber, column: error.startColumn}) |
|
|
|
const nodeAtPosition = await this.props.plugin.call('codeParser', 'definitionAtPosition', cursorPosition) |
|
|
|
const nodeAtPosition = await this.props.plugin.call('codeParser', 'definitionAtPosition', cursorPosition) |
|
|
|
if (nodeAtPosition && nodeAtPosition.nodeType === "FunctionDefinition") { |
|
|
|
if (nodeAtPosition && nodeAtPosition.nodeType === "FunctionDefinition") { |
|
|
|
if (nodeAtPosition.parameters && nodeAtPosition.parameters && nodeAtPosition.parameters.length > 0) { |
|
|
|
if (nodeAtPosition.parameters) { |
|
|
|
const paramNodes = nodeAtPosition.parameters |
|
|
|
const paramNodes = nodeAtPosition.parameters |
|
|
|
const lastParamNode = paramNodes[paramNodes.length - 1] |
|
|
|
if (paramNodes.length) { |
|
|
|
const lastParamEndLoc = lastParamNode.loc.end |
|
|
|
const lastParamNode = paramNodes[paramNodes.length - 1] |
|
|
|
const lineContent = model.getLineContent(lastParamEndLoc.line) |
|
|
|
const lastParamEndLoc = lastParamNode.loc.end |
|
|
|
msg = lineContent.substring(0, lastParamEndLoc.column + 10) + fix.message + lineContent.substring(lastParamEndLoc.column + 10, lineContent.length) |
|
|
|
const lineContent = model.getLineContent(lastParamEndLoc.line) |
|
|
|
fix.range = { |
|
|
|
msg = lineContent.substring(0, lastParamEndLoc.column + 10) + fix.message + lineContent.substring(lastParamEndLoc.column + 10, lineContent.length) |
|
|
|
startLineNumber: lastParamEndLoc.line, |
|
|
|
fix.range = { |
|
|
|
endLineNumber: lastParamEndLoc.line, |
|
|
|
startLineNumber: lastParamEndLoc.line, |
|
|
|
startColumn: 0, |
|
|
|
endLineNumber: lastParamEndLoc.line, |
|
|
|
endColumn: error.startColumn + msg.length |
|
|
|
startColumn: 0, |
|
|
|
} |
|
|
|
endColumn: error.startColumn + msg.length |
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
const lineContent = model.getLineContent(nodeAtPosition.loc.start.line) |
|
|
|
|
|
|
|
const i = lineContent.indexOf('()') |
|
|
|
|
|
|
|
msg = lineContent.substring(0, i + 3) + fix.message + lineContent.substring(i + 3, lineContent.length) |
|
|
|
|
|
|
|
fix.range = { |
|
|
|
|
|
|
|
startLineNumber: nodeAtPosition.loc.start.line, |
|
|
|
|
|
|
|
endLineNumber: nodeAtPosition.loc.start.line, |
|
|
|
|
|
|
|
startColumn: 0, |
|
|
|
|
|
|
|
endColumn: error.startColumn + msg.length |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
actions.push({ |
|
|
|
actions.push({ |
|
|
|
title: fix.title, |
|
|
|
title: fix.title, |
|
|
|
diagnostics: [error], |
|
|
|
diagnostics: [error], |
|
|
|
kind: "quickfix", |
|
|
|
kind: "quickfix", |
|
|
|
edit: { |
|
|
|
edit: { |
|
|
|
edits: [ |
|
|
|
edits: [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
resource: model.uri, |
|
|
|
resource: model.uri, |
|
|
|
edit: { |
|
|
|
edit: { |
|
|
|
range: fix.range || error, |
|
|
|
range: fix.range || error, |
|
|
|
text: msg || fix.message |
|
|
|
text: msg || fix.message |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
} |
|
|
|
}, |
|
|
|
] |
|
|
|
isPreferred: true |
|
|
|
}, |
|
|
|
}) |
|
|
|
isPreferred: true |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|