Skip to content

Commit c2829c2

Browse files
committed
feat: added support for configurePlugin, selectionRange, toggleLineComment, toggleMultilineComment, commentSelection, uncommentSelection, prepareCallHierarchy, provideCallHierarchyIncomingCalls, provideCallHierarchyOutgoingCalls, provideInlayHints
1 parent c8838c7 commit c2829c2

File tree

9 files changed

+567
-1
lines changed

9 files changed

+567
-1
lines changed

src/exp.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,34 @@ for (let file of FILES) {
160160
await tsServer.openFile(file.getEditsForFileRename.oldFilePath);
161161
const getEditsForFileRenameResponse = await tsServer.getEditsForFileRename(file.getEditsForFileRename.oldFilePath, file.getEditsForFileRename.newFilePath);
162162
console.log('getEditsForFileRenameResponse', JSON.stringify(getEditsForFileRenameResponse));
163+
164+
await tsServer.openFile(file.selectionRange.filePath);
165+
const selectionRangeResponse = await tsServer.selectionRange(file.selectionRange.filePath, file.selectionRange.locations);
166+
console.log('selectionRangeResponse', JSON.stringify(selectionRangeResponse));
167+
168+
await tsServer.openFile(file.toggleLineComment.filePath);
169+
const toggleLineCommentResponse = await tsServer.toggleLineComment(file.toggleLineComment.filePath, file.toggleLineComment.startLine, file.toggleLineComment.startOffset, file.toggleLineComment.endLine, file.toggleLineComment.endOffset);
170+
console.log('toggleLineCommentResponse', JSON.stringify(toggleLineCommentResponse));
171+
172+
const toggleMultilineCommentResponse = await tsServer.toggleMultilineComment(file.toggleLineComment.filePath, file.toggleLineComment.startLine, file.toggleLineComment.startOffset, file.toggleLineComment.endLine, file.toggleLineComment.endOffset);
173+
console.log('toggleMultilineCommentResponse', JSON.stringify(toggleMultilineCommentResponse));
174+
175+
const commentSelectionResponse = await tsServer.commentSelection(file.toggleLineComment.filePath, file.toggleLineComment.startLine, file.toggleLineComment.startOffset, file.toggleLineComment.endLine, file.toggleLineComment.endOffset);
176+
console.log('commentSelectionResponse', JSON.stringify(commentSelectionResponse));
177+
178+
const uncommentSelectionResponse = await tsServer.uncommentSelection(file.toggleLineComment.filePath, file.toggleLineComment.startLine, file.toggleLineComment.startOffset, file.toggleLineComment.endLine, file.toggleLineComment.endOffset);
179+
console.log('uncommentSelectionResponse', JSON.stringify(uncommentSelectionResponse));
180+
181+
await tsServer.openFile(file.prepareCallHierarchy.filePath);
182+
const prepareCallHierarchyResponse = await tsServer.prepareCallHierarchy(file.prepareCallHierarchy.filePath, file.prepareCallHierarchy.line, file.prepareCallHierarchy.offset);
183+
console.log('prepareCallHierarchyResponse', JSON.stringify(prepareCallHierarchyResponse));
184+
185+
await tsServer.openFile(file.prepareCallHierarchy.filePath);
186+
const provideCallHierarchyIncomingCallsResponse = await tsServer.provideCallHierarchyIncomingCalls(file.prepareCallHierarchy.filePath, file.prepareCallHierarchy.line, file.prepareCallHierarchy.offset);
187+
console.log('provideCallHierarchyIncomingCallsResponse', JSON.stringify(provideCallHierarchyIncomingCallsResponse));
188+
189+
await tsServer.openFile(file.prepareCallHierarchy.filePath);
190+
const provideCallHierarchyOutgoingCallsResponse = await tsServer.provideCallHierarchyOutgoingCalls(file.prepareCallHierarchy.filePath, file.prepareCallHierarchy.line, file.prepareCallHierarchy.offset);
191+
console.log('provideCallHierarchyOutgoingCallsResponse', JSON.stringify(provideCallHierarchyOutgoingCallsResponse));
163192
}
164193
//tsServer.exitServer();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// file.ts
2+
export class MathOperations {
3+
/**
4+
* Calculates the sum of two numbers.
5+
* @param a The first number.
6+
* @param b The second number.
7+
* @returns The sum of a and b.
8+
*/
9+
static add(a: number, b: number): number {
10+
return a + b;
11+
}
12+
13+
/**
14+
* Demonstrates a call to the add function.
15+
*/
16+
static demoAddition() {
17+
const result = this.add(5, 3);
18+
console.log(`The result is ${result}`);
19+
}
20+
}
21+
22+
// Calling the demoAddition method
23+
MathOperations.demoAddition();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5", // Specify ECMAScript target version
4+
"provideInlayHints": true,
5+
"module": "commonjs", // Specify module code generation
6+
"strict": true, // Enable all strict type-checking options
7+
"esModuleInterop": true, // Enables compatibility with default imports from CommonJS modules
8+
"outDir": "./dist", // Redirect output structure to the directory
9+
"baseUrl": "./", // Base directory to resolve non-relative module names
10+
"paths": { // Specify paths for module names
11+
"*": ["node_modules/*"]
12+
},
13+
"skipLibCheck": true, // Skip type checking of all declaration files (*.d.ts)
14+
"forceConsistentCasingInFileNames": true // Disallow inconsistently-cased references to the same file.
15+
},
16+
"include": [
17+
"./**/*.ts" // Include all TypeScript files in the project
18+
],
19+
"exclude": [
20+
"node_modules", // Exclude the node_modules directory
21+
"**/*.spec.ts" // Exclude test files
22+
]
23+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
export class Calculator {
2+
/**
3+
* Adds two numbers together.
4+
* @param a The first number.
5+
* @param b The second number.
6+
* @returns The sum of a and b.
7+
*/
8+
add(a: number, b: number): number {
9+
return a + b;
10+
}
11+
12+
/**
13+
* Multiplies two numbers.
14+
* @param a The first number.
15+
* @param b The second number.
16+
* @returns The product of a and b.
17+
*/
18+
multiply(a: number, b: number): number {
19+
return a * b;
20+
}
21+
22+
/**
23+
* Subtracts the second number from the first.
24+
* @param a The number to subtract from.
25+
* @param b The number to subtract.
26+
* @returns The difference between a and b.
27+
*/
28+
subtract(a: number, b: number): number {
29+
return a - b;
30+
}
31+
32+
/**
33+
* Divides the first number by the second.
34+
* @param a The dividend.
35+
* @param b The divisor.
36+
* @returns The quotient of a and b.
37+
*/
38+
divide(a: number, b: number): number {
39+
if (b === 0) {
40+
throw new Error("Cannot divide by zero.");
41+
}
42+
return a / b;
43+
}
44+
}
45+
46+
// Usage of Calculator
47+
const calc = new Calculator();
48+
const sum = calc.add(5, 3);
49+
console.log(`Sum: ${sum}`);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5", // Specify ECMAScript target version
4+
"provideInlayHints": true,
5+
"module": "commonjs", // Specify module code generation
6+
"strict": true, // Enable all strict type-checking options
7+
"esModuleInterop": true, // Enables compatibility with default imports from CommonJS modules
8+
"outDir": "./dist", // Redirect output structure to the directory
9+
"baseUrl": "./", // Base directory to resolve non-relative module names
10+
"paths": { // Specify paths for module names
11+
"*": ["node_modules/*"]
12+
},
13+
"skipLibCheck": true, // Skip type checking of all declaration files (*.d.ts)
14+
"forceConsistentCasingInFileNames": true // Disallow inconsistently-cased references to the same file.
15+
},
16+
"include": [
17+
"./**/*.ts" // Include all TypeScript files in the project
18+
],
19+
"exclude": [
20+
"node_modules", // Exclude the node_modules directory
21+
"**/*.spec.ts" // Exclude test files
22+
]
23+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Example {
2+
greet(name: string): string {
3+
return `Hello, ${name}!`;
4+
}
5+
6+
farewell(name: string): string {
7+
return `Goodbye, ${name}!`;
8+
}
9+
}
10+
11+
const example = new Example();
12+
console.log(example.greet('Alice'));
13+
console.log(example.farewell('Bob'));
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// sample.ts
2+
function calculateSum(a: number, b: number): number {
3+
let result = a + b;
4+
console.log(`The sum of ${a} and ${b} is ${result}`);
5+
return result;
6+
}
7+
8+
const number1 = 5;
9+
const number2 = 10;
10+
11+
const sum = calculateSum(number1, number2);
12+
console.log(`Sum: ${sum}`);

0 commit comments

Comments
 (0)