-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement refactors tsserver commands. See
- Loading branch information
1 parent
cddd2e7
commit fc05cf7
Showing
11 changed files
with
246 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
core/ts.core/src/ts/client/refactors/ApplicableRefactorInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ts.client.refactors; | ||
|
||
public class ApplicableRefactorInfo { | ||
|
||
private String name; | ||
|
||
private String description; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
core/ts.core/src/ts/client/refactors/RefactorCodeActions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package ts.client.refactors; | ||
|
||
import java.util.List; | ||
|
||
import ts.client.codefixes.CodeAction; | ||
|
||
public class RefactorCodeActions { | ||
|
||
private List<CodeAction> actions; | ||
|
||
private Integer renameLocation; | ||
|
||
public List<CodeAction> getActions() { | ||
return actions; | ||
} | ||
|
||
public Integer getRenameLocation() { | ||
return renameLocation; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
core/ts.core/src/ts/internal/client/protocol/GetApplicableRefactorsRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright (c) 2015-2017 Angelo ZERR. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation | ||
*/ | ||
package ts.internal.client.protocol; | ||
|
||
import java.util.List; | ||
|
||
import com.google.gson.JsonObject; | ||
|
||
import ts.client.CommandNames; | ||
import ts.client.refactors.ApplicableRefactorInfo; | ||
|
||
/** | ||
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts | ||
*/ | ||
public class GetApplicableRefactorsRequest extends Request<GetApplicableRefactorsRequestArgs> { | ||
|
||
public GetApplicableRefactorsRequest(String file, int line, int offset) { | ||
super(CommandNames.GetApplicableRefactors.getName(), new GetApplicableRefactorsRequestArgs(file, line, offset)); | ||
} | ||
|
||
@Override | ||
public Response<List<ApplicableRefactorInfo>> parseResponse(JsonObject json) { | ||
return GsonHelper.DEFAULT_GSON.fromJson(json, GetApplicableRefactorsResponse.class); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
core/ts.core/src/ts/internal/client/protocol/GetApplicableRefactorsRequestArgs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Copyright (c) 2015-2017 Angelo ZERR. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation | ||
*/ | ||
package ts.internal.client.protocol; | ||
|
||
/** | ||
* | ||
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts | ||
* | ||
*/ | ||
public class GetApplicableRefactorsRequestArgs extends FileLocationRequestArgs { | ||
|
||
public GetApplicableRefactorsRequestArgs(String file, int position) { | ||
super(file, position); | ||
} | ||
|
||
public GetApplicableRefactorsRequestArgs(String file, int line, int offset) { | ||
super(file, line, offset); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
core/ts.core/src/ts/internal/client/protocol/GetApplicableRefactorsResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Copyright (c) 2015-2017 Angelo ZERR. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation | ||
*/ | ||
package ts.internal.client.protocol; | ||
|
||
import java.util.List; | ||
|
||
import ts.client.refactors.ApplicableRefactorInfo; | ||
|
||
/** | ||
* Refactors response message. | ||
* | ||
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts | ||
*/ | ||
public class GetApplicableRefactorsResponse extends Response<List<ApplicableRefactorInfo>> { | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
core/ts.core/src/ts/internal/client/protocol/GetRefactorCodeActionsRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright (c) 2015-2017 Angelo ZERR. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation | ||
*/ | ||
package ts.internal.client.protocol; | ||
|
||
import com.google.gson.JsonObject; | ||
|
||
import ts.client.CommandNames; | ||
import ts.client.refactors.RefactorCodeActions; | ||
|
||
/** | ||
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts | ||
*/ | ||
public class GetRefactorCodeActionsRequest extends Request<GetRefactorCodeActionsRequestArgs> { | ||
|
||
public GetRefactorCodeActionsRequest(String file, int line, int offset, String refactorName) { | ||
super(CommandNames.GetRefactorCodeActions.getName(), | ||
new GetRefactorCodeActionsRequestArgs(file, line, offset, refactorName)); | ||
} | ||
|
||
@Override | ||
public Response<RefactorCodeActions> parseResponse(JsonObject json) { | ||
return GsonHelper.DEFAULT_GSON.fromJson(json, GetRefactorCodeActionsResponse.class); | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
core/ts.core/src/ts/internal/client/protocol/GetRefactorCodeActionsRequestArgs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright (c) 2015-2017 Angelo ZERR. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation | ||
*/ | ||
package ts.internal.client.protocol; | ||
|
||
/** | ||
* | ||
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts | ||
* | ||
*/ | ||
public class GetRefactorCodeActionsRequestArgs extends FileLocationRequestArgs { | ||
|
||
/* The kind of the applicable refactor */ | ||
private String refactorName; | ||
|
||
public GetRefactorCodeActionsRequestArgs(String file, int position, String refactorName) { | ||
super(file, position); | ||
this.refactorName = refactorName; | ||
} | ||
|
||
public GetRefactorCodeActionsRequestArgs(String file, int line, int offset, String refactorName) { | ||
super(file, line, offset); | ||
this.refactorName = refactorName; | ||
} | ||
|
||
public String getRefactorName() { | ||
return refactorName; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
core/ts.core/src/ts/internal/client/protocol/GetRefactorCodeActionsResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Copyright (c) 2015-2017 Angelo ZERR. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation | ||
*/ | ||
package ts.internal.client.protocol; | ||
|
||
import ts.client.refactors.RefactorCodeActions; | ||
|
||
/** | ||
* Refactor code actions response message. | ||
* | ||
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts | ||
*/ | ||
public class GetRefactorCodeActionsResponse extends Response<RefactorCodeActions> { | ||
|
||
} |