use of javax.ws.rs.POST in project che by eclipse.
the class TextDocumentService method documentHighlight.
@POST
@Path("documentHighlight")
@Consumes(MediaType.APPLICATION_JSON)
public DocumentHighlight documentHighlight(TextDocumentPositionParamsDTO positionParams) throws LanguageServerException, InterruptedException, ExecutionException {
positionParams.getTextDocument().setUri(prefixURI(positionParams.getTextDocument().getUri()));
LanguageServer server = getServer(positionParams.getTextDocument().getUri());
if (server != null) {
return server.getTextDocumentService().documentHighlight(positionParams).get();
}
return null;
}
use of javax.ws.rs.POST in project che by eclipse.
the class GitHubService method updateSSHKey.
@POST
@Path("ssh/generate")
public void updateSSHKey() throws ApiException {
final String host = "github.com";
SshPair sshPair = null;
try {
sshPair = sshServiceClient.getPair("vcs", host);
} catch (NotFoundException ignored) {
}
if (sshPair != null) {
if (sshPair.getPublicKey() == null) {
sshServiceClient.removePair("vcs", host);
sshPair = sshServiceClient.generatePair(newDto(GenerateSshPairRequest.class).withService("vcs").withName(host));
}
} else {
sshPair = sshServiceClient.generatePair(newDto(GenerateSshPairRequest.class).withService("vcs").withName(host));
}
// update public key
try {
githubKeyUploader.uploadKey(sshPair.getPublicKey());
} catch (IOException e) {
LOG.error("Upload github ssh key fail", e);
throw new GitException(e.getMessage(), e);
}
}
use of javax.ws.rs.POST in project che by eclipse.
the class RefactoringService method createRenameRefactoring.
/**
* Create rename refactoring session.
*
* @param settings
* rename settings
* @return the rename refactoring session
* @throws CoreException
* when RenameSupport can't be created
* @throws RefactoringException
* when Java element was not found
*/
@POST
@Path("rename/create")
@Produces("application/json")
@Consumes("application/json")
public RenameRefactoringSession createRenameRefactoring(CreateRenameRefactoring settings) throws CoreException, RefactoringException {
IJavaProject javaProject = model.getJavaProject(settings.getProjectPath());
IJavaElement elementToRename;
ICompilationUnit cu = null;
switch(settings.getType()) {
case COMPILATION_UNIT:
elementToRename = javaProject.findType(settings.getPath()).getCompilationUnit();
break;
case PACKAGE:
elementToRename = javaProject.findPackageFragment(new org.eclipse.core.runtime.Path(settings.getPath()));
break;
case JAVA_ELEMENT:
cu = javaProject.findType(settings.getPath()).getCompilationUnit();
elementToRename = getSelectionElement(cu, settings.getOffset());
break;
default:
elementToRename = null;
}
if (elementToRename == null) {
throw new RefactoringException("Can't find java element to rename.");
}
return manager.createRenameRefactoring(elementToRename, cu, settings.getOffset(), settings.isRefactorLightweight());
}
use of javax.ws.rs.POST in project che by eclipse.
the class RefactoringService method createMoveRefactoring.
/**
* Create move refactoring session.
*
* @param cmr
* move settings, contains resource paths to move.
* @return refactoring session id.
* @throws JavaModelException
* when JavaModel has a failure
* @throws RefactoringException
* when impossible to create move refactoring session
*/
@POST
@Path("move/create")
@Consumes("application/json")
@Produces("text/plain")
public String createMoveRefactoring(CreateMoveRefactoring cmr) throws JavaModelException, RefactoringException {
IJavaProject javaProject = model.getJavaProject(cmr.getProjectPath());
IJavaElement[] javaElements;
try {
Function<ElementToMove, IJavaElement> map = javaElement -> {
try {
if (javaElement.isPack()) {
return javaProject.findPackageFragment(new org.eclipse.core.runtime.Path(javaElement.getPath()));
} else {
return javaProject.findType(javaElement.getPath()).getCompilationUnit();
}
} catch (JavaModelException e) {
throw new IllegalArgumentException(e);
}
};
javaElements = cmr.getElements().stream().map(map).toArray(IJavaElement[]::new);
} catch (IllegalArgumentException e) {
if (e.getCause() instanceof JavaModelException) {
throw (JavaModelException) e.getCause();
} else {
throw e;
}
}
if (RefactoringAvailabilityTester.isMoveAvailable(new IResource[0], javaElements)) {
return manager.createMoveRefactoringSession(javaElements);
}
throw new RefactoringException("Can't create move refactoring.");
}
use of javax.ws.rs.POST in project che by eclipse.
the class SearchService method findUsages.
@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("find/usages")
public FindUsagesResponse findUsages(FindUsagesRequest request) throws SearchException {
JavaModel javaModel = JavaModelManager.getJavaModelManager().getJavaModel();
IJavaProject javaProject = javaModel.getJavaProject(request.getProjectPath());
return manager.findUsage(javaProject, request.getFQN(), request.getOffset());
}
Aggregations