Repository navigation
Expand file tree
/
Copy pathexp.js
More file actions
213 lines (158 loc) · 15.7 KB
/
Copy pathexp.js
File metadata and controls
213 lines (158 loc) · 15.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
import createTSServerInstance from './utils/server.js';
import {FILES} from "./utils/testconfig.js";
const tsServer = createTSServerInstance(false);
await tsServer.init();
console.log('server intializeed');
for (let file of FILES) {
tsServer.openFile(file.filepath);
const definitonResp = await tsServer.getDefinition(file.filepath, file.definition.line, file.definition.offset);
console.log("resp+++", JSON.stringify(definitonResp));
const findReferencesResp = await tsServer.findReferences(file.filepath, file.reference.line, file.reference.offset);
console.log('find reference resp', JSON.stringify(findReferencesResp));
//await tsServer.killServer();
const quickInfoResp = await tsServer.getQuickInfo(file.filepath, file.quickInfo.line, file.quickInfo.offset);
console.log('quickInfoResp', JSON.stringify(quickInfoResp));
const findSourceDefinitionResp = await tsServer.findSourceDefinition(file.filepath, file.findSourceDefinition.line, file.findSourceDefinition.offset);
console.log('findSourceDefinitionResp', JSON.stringify(findSourceDefinitionResp));
const completionInfoResp = await tsServer.getCompletionInfo(file.filepath, file.getCompletionInfo.line, file.getCompletionInfo.offset);
console.log('completionInfoResp', JSON.stringify(completionInfoResp));
const getCompletionDetailsResp = await tsServer.getCompletionDetails(file.filepath, file.getCompletionDetails.line, file.getCompletionDetails.offset, completionInfoResp.body.entries[0].name);
console.log('getCompletionDetailsResp', JSON.stringify(getCompletionDetailsResp));
const getCompileOnSaveResp = await tsServer.getCompileOnSaveAffectedFileList(file.filepath);
console.log('getCompileOnSaveResp', JSON.stringify(getCompileOnSaveResp));
const compileOnSaveEmitFileResp = await tsServer.compileOnSaveEmitFile(file.filepath);
console.log('compileOnSaveEmitFileResp', JSON.stringify(compileOnSaveEmitFileResp));
const getDefinitionAndBoundSpanResp = await tsServer.getDefinitionAndBoundSpan(file.filepath, file.getDefinitionAndBoundSpan.line, file.getDefinitionAndBoundSpan.offset);
console.log('getDefinitionAndBoundSpanResp', JSON.stringify(getDefinitionAndBoundSpanResp));
const getImplementationsResp = await tsServer.getImplementations(file.filepath, file.getImplementations.line, file.getImplementations.offset);
console.log('getImplementationsResp', JSON.stringify(getImplementationsResp));
const formatResp = await tsServer.format(file.filepath, file.format.line, file.format.offset, file.format.endLine, file.format.endOffset);
console.log('formatResp', JSON.stringify(formatResp));
const formatOnKeyResp = await tsServer.formatOnKey(file.filepath, file.formatOnKey.line, file.formatOnKey.offset, file.formatOnKey.key);
console.log('formatOnKeyResp', JSON.stringify(formatOnKeyResp));
for (const sample of file.getErrors.files) {
await tsServer.openFile(sample);
}
// await tsServer.getErrors(file.getErrors.files, file.getErrors.delay);
//
// await tsServer.getErrorsForProject(file.getErrorsForProject.filePath, file.getErrorsForProject.delay);
await tsServer.openFile(file.getSemanticDiagnosticsSync.filePath);
const getSemanticDiagnosticsSyncResp = await tsServer.getSemanticDiagnosticsSync(file.getSemanticDiagnosticsSync.filePath, true);
console.log('getSemanticDiagnosticsSyncResp', JSON.stringify(getSemanticDiagnosticsSyncResp));
const getSyntacticDiagnosticsSyncResp = await tsServer.getSyntacticDiagnosticsSync(file.getSemanticDiagnosticsSync.filePath, true);
console.log('getSyntacticDiagnosticsSyncResp', JSON.stringify(getSyntacticDiagnosticsSyncResp));
const getSuggestionDiagnosticsSyncResp = await tsServer.getSuggestionDiagnosticsSync(file.getSuggestionDiagnosticsSync.filePath, true);
console.log('getSuggestionDiagnosticsSyncResp', JSON.stringify(getSuggestionDiagnosticsSyncResp));
const getNavBarResp = await tsServer.getNavBar(file.getNavBar.filePath);
console.log('getNavBarResp', JSON.stringify(getNavBarResp));
const navTorResp = await tsServer.navTo(file.navto.searchValue);
console.log('navTorResp', JSON.stringify(navTorResp));
const getNavTreeResp = await tsServer.getNavTree(file.getNavTree.filePath);
console.log('getNavTreeResp', JSON.stringify(getNavTreeResp));
const getNavTreeFullResp = await tsServer.getNavTree(file.getNavTreeFull.filePath);
console.log('getNavTreeFullResp', JSON.stringify(getNavTreeFullResp));
const documentHighlightsResp = await tsServer.documentHighlights(file.documentHighlights.filePath, file.documentHighlights.line, file.documentHighlights.offset, file.documentHighlights.filesToSearch);
console.log('documentHighlightsResp', JSON.stringify(documentHighlightsResp));
const reloadResp = await tsServer.reload(file.reload.filePath, file.reload.tempFilePath);
console.log('reloadResp', JSON.stringify(reloadResp));
const renameResp = await tsServer.rename(file.rename.filePath, file.rename.line, file.rename.offset, file.rename.findInComments, file.rename.findInStrings);
console.log('renameResp', JSON.stringify(renameResp));
await tsServer.saveto(file.saveto.filePath, file.saveto.tempFilePath);
const signatureHelpResp = await tsServer.signatureHelp(file.signatureHelp.filePath, file.signatureHelp.line, file.signatureHelp.offset, file.signatureHelp.triggerReason);
console.log('signatureHelpResp', JSON.stringify(signatureHelpResp));
const statusResp = await tsServer.status();
console.log('statusResp', JSON.stringify(statusResp));
const typeDefinitionResp = await tsServer.typeDefinition(file.typeDefinition.filePath, file.typeDefinition.line, file.typeDefinition.offset);
console.log('typeDefinitionResp', JSON.stringify(typeDefinitionResp));
const projectInfoResp = await tsServer.projectInfo(file.projectInfo.filePath, file.projectInfo.needFileNameList);
console.log('projectInfoResp', JSON.stringify(projectInfoResp));
await tsServer.reloadProjects();
const openExternalProjectResp = await tsServer.openExternalProject(file.openExternalProject.project);
console.log('openExternalProjectResp', JSON.stringify(openExternalProjectResp));
const openExternalProjectsResp = await tsServer.openExternalProjects(file.openExternalProjects.projects);
console.log('openExternalProjectsResp', JSON.stringify(openExternalProjectsResp));
const closeExternalProjectResp = await tsServer.closeExternalProject(file.openExternalProject.project.projectFileName);
console.log('closeExternalProjectResp ', JSON.stringify(closeExternalProjectResp));
for (const project of file.openExternalProjects.projects) {
const closeExternalProjectResp = await tsServer.closeExternalProject(project.projectFileName);
console.log('closeExternalProjectResp ', JSON.stringify(closeExternalProjectResp));
}
/* await tsServer.openFile(file.updateOpen.openFiles.fileName)
const updateOpenResp = await tsServer.updateOpen(file.updateOpen.openFiles, file.updateOpen.changedFiles, file.updateOpen.closedFiles);
console.log('updateOpenResp ', JSON.stringify(updateOpenResp));*/
const getOutliningSpansResponse = await tsServer.getOutliningSpans(file.getOutliningSpans.fileName);
console.log('getOutliningSpansResponse', JSON.stringify(getOutliningSpansResponse));
const todoCommentsResponse = await tsServer.todoComments(file.todoComments.fileName, file.todoComments.descriptors);
console.log('todoCommentsResponse', JSON.stringify(todoCommentsResponse));
const indentationsResponse = await tsServer.indentation(file.indentation.fileName, file.indentation.line, file.indentation.offset, file.indentation.options);
console.log('indentationsResponse', JSON.stringify(indentationsResponse));
await tsServer.openFile(file.docCommentTemplate.fileName);
const docCommentTemplateResponse = await tsServer.docCommentTemplate(file.docCommentTemplate.fileName, file.docCommentTemplate.line, file.docCommentTemplate.offset);
console.log('docCommentTemplateResponse', JSON.stringify(docCommentTemplateResponse));
/*const setCompilerOptionsForInferredProjectsResponse = await tsServer.setCompilerOptionsForInferredProjects(file.setCompilerOptionsForInferredProjects.options, file.setCompilerOptionsForInferredProjects.projectRootPath);
console.log('setCompilerOptionsForInferredProjectsResponse', JSON.stringify(setCompilerOptionsForInferredProjectsResponse));*/
//TODO: Revisit
/* await tsServer.openFile(file.getCodeFixes.fileName);
const getCodeFixesResponse = await tsServer.getCodeFixes(file.getCodeFixes.fileName, file.getCodeFixes.startLine, file.getCodeFixes.endLine, file.getCodeFixes.endLine, file.getCodeFixes.endOffset, file.getCodeFixes.errorCodes);
console.log('getCodeFixesResponse', JSON.stringify(getCodeFixesResponse));*/
// TODO: Revisit as it is used along with getCodeFixes in vscode
/* await tsServer.openFile(file.getCombinedCodeFix.scope.args.file);
const getCombinedCodeFixResponse = await tsServer.getCombinedCodeFix(file.getCombinedCodeFix.fileName, file.getCombinedCodeFix.fixId, file.getCombinedCodeFix.scope);
console.log('getCombinedCodeFixResponse', JSON.stringify(getCombinedCodeFixResponse));*/
const getSupportedCodeFixesResponse = await tsServer.getSupportedCodeFixes(file.getSupportedCodeFixes.file);
console.log('getSupportedCodeFixesResponse', JSON.stringify(getSupportedCodeFixesResponse));
await tsServer.openFile(file.getApplicableRefactors.filePath);
const getApplicableRefactorsResponse = await tsServer.getApplicableRefactors(file.getApplicableRefactors.filePath, file.getApplicableRefactors.line, file.getApplicableRefactors.offset/*, file.getApplicableRefactors.triggerReason, file.getApplicableRefactors.kind, file.getApplicableRefactors.includeInteractiveActions*/);
console.log('getApplicableRefactorsResponse', JSON.stringify(getApplicableRefactorsResponse));
//TODO: Write working use case with editor
await tsServer.openFile(file.getEditsForRefactor.filePath);
const getEditsForRefactorResponse = await tsServer.getEditsForRefactor(file.getEditsForRefactor.filePath, file.getEditsForRefactor.refactor, file.getEditsForRefactor.action, file.getEditsForRefactor.startLine, file.getEditsForRefactor.startOffset, file.getEditsForRefactor.endLine, file.getEditsForRefactor.endOffset, file.getEditsForRefactor.interactiveRefactorArguments);
console.log('getEditsForRefactorResponse', JSON.stringify(getEditsForRefactorResponse));
await tsServer.openFile(file.getMoveToRefactoringFileSuggestions.filePath);
const getMoveToRefactoringFileSuggestionsResponse = await tsServer.getMoveToRefactoringFileSuggestions(file.getMoveToRefactoringFileSuggestions.filePath, file.getMoveToRefactoringFileSuggestions.startLine, file.getMoveToRefactoringFileSuggestions.startOffset, file.getMoveToRefactoringFileSuggestions.endLine, file.getMoveToRefactoringFileSuggestions.endOffset/*,file.getMoveToRefactoringFileSuggestions.kind*/);
console.log('getMoveToRefactoringFileSuggestionsResponse', JSON.stringify(getMoveToRefactoringFileSuggestionsResponse));
await tsServer.openFile(file.organizeImports.filePath);
const organizeImportsResponse = await tsServer.organizeImports(file.organizeImports.filePath, file.organizeImports.mode);
console.log('organizeImportsResponse', JSON.stringify(organizeImportsResponse));
await tsServer.openFile(file.getEditsForFileRename.oldFilePath);
const getEditsForFileRenameResponse = await tsServer.getEditsForFileRename(file.getEditsForFileRename.oldFilePath, file.getEditsForFileRename.newFilePath);
console.log('getEditsForFileRenameResponse', JSON.stringify(getEditsForFileRenameResponse));
await tsServer.openFile(file.selectionRange.filePath);
const selectionRangeResponse = await tsServer.selectionRange(file.selectionRange.filePath, file.selectionRange.locations);
console.log('selectionRangeResponse', JSON.stringify(selectionRangeResponse));
await tsServer.openFile(file.toggleLineComment.filePath);
const toggleLineCommentResponse = await tsServer.toggleLineComment(file.toggleLineComment.filePath, file.toggleLineComment.startLine, file.toggleLineComment.startOffset, file.toggleLineComment.endLine, file.toggleLineComment.endOffset);
console.log('toggleLineCommentResponse', JSON.stringify(toggleLineCommentResponse));
const toggleMultilineCommentResponse = await tsServer.toggleMultilineComment(file.toggleLineComment.filePath, file.toggleLineComment.startLine, file.toggleLineComment.startOffset, file.toggleLineComment.endLine, file.toggleLineComment.endOffset);
console.log('toggleMultilineCommentResponse', JSON.stringify(toggleMultilineCommentResponse));
const commentSelectionResponse = await tsServer.commentSelection(file.toggleLineComment.filePath, file.toggleLineComment.startLine, file.toggleLineComment.startOffset, file.toggleLineComment.endLine, file.toggleLineComment.endOffset);
console.log('commentSelectionResponse', JSON.stringify(commentSelectionResponse));
const uncommentSelectionResponse = await tsServer.uncommentSelection(file.toggleLineComment.filePath, file.toggleLineComment.startLine, file.toggleLineComment.startOffset, file.toggleLineComment.endLine, file.toggleLineComment.endOffset);
console.log('uncommentSelectionResponse', JSON.stringify(uncommentSelectionResponse));
await tsServer.openFile(file.prepareCallHierarchy.filePath);
const prepareCallHierarchyResponse = await tsServer.prepareCallHierarchy(file.prepareCallHierarchy.filePath, file.prepareCallHierarchy.line, file.prepareCallHierarchy.offset);
console.log('prepareCallHierarchyResponse', JSON.stringify(prepareCallHierarchyResponse));
await tsServer.openFile(file.prepareCallHierarchy.filePath);
const provideCallHierarchyIncomingCallsResponse = await tsServer.provideCallHierarchyIncomingCalls(file.prepareCallHierarchy.filePath, file.prepareCallHierarchy.line, file.prepareCallHierarchy.offset);
console.log('provideCallHierarchyIncomingCallsResponse', JSON.stringify(provideCallHierarchyIncomingCallsResponse));
await tsServer.openFile(file.prepareCallHierarchy.filePath);
const provideCallHierarchyOutgoingCallsResponse = await tsServer.provideCallHierarchyOutgoingCalls(file.prepareCallHierarchy.filePath, file.prepareCallHierarchy.line, file.prepareCallHierarchy.offset);
console.log('provideCallHierarchyOutgoingCallsResponse', JSON.stringify(provideCallHierarchyOutgoingCallsResponse));
await tsServer.openFile(file.getLinkedEditingRange.filePath);
const getLinkedEditingRangeResponse = await tsServer.getLinkedEditingRange(file.getLinkedEditingRange.filePath, file.getLinkedEditingRange.line, file.getLinkedEditingRange.offset);
console.log('getLinkedEditingRangeResponse', JSON.stringify(getLinkedEditingRangeResponse));
await tsServer.openFile(file.braceCommand.filePath);
const braceCommandResponse = await tsServer.braceCommand(file.braceCommand.filePath, file.braceCommand.line, file.braceCommand.offset);
console.log('braceCommandResponse', JSON.stringify(braceCommandResponse));
// TODO: see working and non-working use case
await tsServer.openFile(file.braceCommand.filePath);
const braceCompletionResponse = await tsServer.braceCompletion(file.braceCommand.filePath, file.braceCommand.line + 1, file.braceCommand.offset, 'a');
console.log('braceCompletionResponse', JSON.stringify(braceCompletionResponse));
await tsServer.openFile(file.braceCommand.filePath);
const getSpanOfEnclosingCommentResponse = await tsServer.getSpanOfEnclosingComment(file.getSpanOfEnclosingComment.filePath, file.getSpanOfEnclosingComment.line, file.getSpanOfEnclosingComment.offset, file.getSpanOfEnclosingComment.onlyMultiLine);
console.log('getSpanOfEnclosingCommentResponse', JSON.stringify(getSpanOfEnclosingCommentResponse));
}
/*
tsServer.exitServer();
tsServer.killServer();
*/