use of com.thoughtworks.gauge.core.GaugeService in project Intellij-Plugin by getgauge.
the class GaugeRefactorHandler method refactor.
private void refactor(String currentStepText, String newStepText, TransactionId contextTransaction, CompileContext context, RefactorStatusCallback refactorStatusCallback) {
refactorStatusCallback.onStatusChange("Refactoring...");
Module module = GaugeUtil.moduleForPsiElement(file);
TransactionGuard.getInstance().submitTransaction(() -> {
}, contextTransaction, () -> {
Api.PerformRefactoringResponse response = null;
FileDocumentManager.getInstance().saveAllDocuments();
FileDocumentManager.getInstance().saveDocumentAsIs(editor.getDocument());
GaugeService gaugeService = Gauge.getGaugeService(module, true);
try {
response = gaugeService.getGaugeConnection().sendPerformRefactoringRequest(currentStepText, newStepText);
} catch (Exception e) {
refactorStatusCallback.onFinish(new RefactoringStatus(false, String.format("Could not execute refactor command: %s", e.toString())));
return;
}
new UndoHandler(response.getFilesChangedList(), module.getProject(), "Refactoring").handle();
if (!response.getSuccess()) {
showMessage(response, context, refactorStatusCallback);
return;
}
refactorStatusCallback.onFinish(new RefactoringStatus(true));
});
}
use of com.thoughtworks.gauge.core.GaugeService in project Intellij-Plugin by getgauge.
the class GaugeLibHelper method gaugeLib.
private ProjectLib gaugeLib(Module module) {
String libRoot;
try {
GaugeService gaugeService = Gauge.getGaugeService(module, true);
if (gaugeService == null) {
gaugeService = GaugeModuleComponent.createGaugeService(module);
}
GaugeConnection gaugeConnection = gaugeService.getGaugeConnection();
if (gaugeConnection == null) {
throw new IOException("Gauge api connection not established");
}
libRoot = gaugeConnection.getLibPath("java");
} catch (IOException e) {
System.err.println("Could not add gauge lib, add it manually: " + e.getMessage());
LOG.debug("Could not add gauge lib, add it manually: " + e.getMessage());
return null;
} catch (PluginNotInstalledException e) {
throw new RuntimeException("Gauge " + JAVA + " plugin is not installed.");
}
return new ProjectLib(GAUGE_LIB, new File(libRoot));
}
use of com.thoughtworks.gauge.core.GaugeService in project Intellij-Plugin by getgauge.
the class StepCompletionProvider method getStepsInModule.
private Collection<Type> getStepsInModule(Module module) {
Map<String, Type> steps = getImplementedSteps(module);
try {
GaugeService gaugeService = Gauge.getGaugeService(module, true);
if (gaugeService == null)
return steps.values();
GaugeConnection gaugeConnection = gaugeService.getGaugeConnection();
if (gaugeConnection != null) {
gaugeConnection.fetchAllSteps().forEach(s -> addStep(steps, s, STEP));
gaugeConnection.fetchAllConcepts().forEach(concept -> addStep(steps, concept.getStepValue(), CONCEPT));
}
} catch (IOException ignored) {
LOG.debug(ignored);
}
return steps.values();
}
use of com.thoughtworks.gauge.core.GaugeService in project Intellij-Plugin by getgauge.
the class GaugeModuleComponent method createGaugeService.
/**
* Creates a gauge service for the particular module. GaugeService is used to make api calls to the gauge daemon process.
*
* @param module
* @return
*/
public static GaugeService createGaugeService(Module module) {
int freePortForApi = SocketUtils.findFreePortForApi();
Process gaugeProcess = initializeGaugeProcess(freePortForApi, module);
GaugeConnection gaugeConnection = initializeGaugeConnection(freePortForApi);
GaugeService gaugeService = new GaugeService(gaugeProcess, gaugeConnection);
Gauge.addModule(module, gaugeService);
return gaugeService;
}
Aggregations