mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
PR feedback
This commit is contained in:
parent
3df79d5238
commit
682f81257d
@ -9,7 +9,7 @@ namespace ts {
|
||||
errorCode: string;
|
||||
sourceFile: SourceFile;
|
||||
span: TextSpan;
|
||||
checker: TypeChecker;
|
||||
program: Program;
|
||||
newLineCharacter: string;
|
||||
}
|
||||
|
||||
@ -27,24 +27,22 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
export class CodeFixProvider {
|
||||
public static getSupportedErrorCodes() {
|
||||
return Object.keys(codeFixes);
|
||||
}
|
||||
export function getSupportedErrorCodes() {
|
||||
return Object.keys(codeFixes);
|
||||
}
|
||||
|
||||
public getFixes(context: CodeFixContext): CodeAction[] {
|
||||
const fixes = codeFixes[context.errorCode];
|
||||
let allActions: CodeAction[] = [];
|
||||
export function getFixes(context: CodeFixContext): CodeAction[] {
|
||||
const fixes = codeFixes[context.errorCode];
|
||||
let allActions: CodeAction[] = [];
|
||||
|
||||
forEach(fixes, f => {
|
||||
const actions = f.getCodeActions(context);
|
||||
if (actions && actions.length > 0) {
|
||||
allActions = allActions.concat(actions);
|
||||
}
|
||||
});
|
||||
forEach(fixes, f => {
|
||||
const actions = f.getCodeActions(context);
|
||||
if (actions && actions.length > 0) {
|
||||
allActions = allActions.concat(actions);
|
||||
}
|
||||
});
|
||||
|
||||
return allActions;
|
||||
}
|
||||
return allActions;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -695,7 +695,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getSupportedCodeFixes() {
|
||||
return codefix.CodeFixProvider.getSupportedErrorCodes();
|
||||
return codefix.getSupportedErrorCodes();
|
||||
}
|
||||
|
||||
// Cache host information about script Should be refreshed
|
||||
@ -918,7 +918,6 @@ namespace ts {
|
||||
documentRegistry: DocumentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory())): LanguageService {
|
||||
|
||||
const syntaxTreeCache: SyntaxTreeCache = new SyntaxTreeCache(host);
|
||||
const codeFixProvider: codefix.CodeFixProvider = new codefix.CodeFixProvider();
|
||||
let ruleProvider: formatting.RulesProvider;
|
||||
let program: Program;
|
||||
let lastProjectVersion: string;
|
||||
@ -1588,7 +1587,6 @@ namespace ts {
|
||||
function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): CodeAction[] {
|
||||
synchronizeHostData();
|
||||
const sourceFile = getValidSourceFile(fileName);
|
||||
const checker = program.getTypeChecker();
|
||||
let allFixes: CodeAction[] = [];
|
||||
|
||||
forEach(errorCodes, error => {
|
||||
@ -1596,11 +1594,11 @@ namespace ts {
|
||||
errorCode: error,
|
||||
sourceFile: sourceFile,
|
||||
span: { start, length: end - start },
|
||||
checker: checker,
|
||||
program: program,
|
||||
newLineCharacter: getNewLineOrDefaultFromHost(host)
|
||||
};
|
||||
|
||||
const fixes = codeFixProvider.getFixes(context);
|
||||
const fixes = codefix.getFixes(context);
|
||||
if (fixes) {
|
||||
allFixes = allFixes.concat(fixes);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user