use of com.thoughtworks.gauge.connection.GaugeConnection in project Intellij-Plugin by getgauge.
the class GaugeModuleComponent method initializeGaugeConnection.
private static GaugeConnection initializeGaugeConnection(int apiPort) {
if (apiPort != -1) {
LOG.warn("Initializing Gauge connection");
GaugeConnection gaugeConn = null;
for (int i = 1; i <= 10; i++) {
try {
gaugeConn = new GaugeConnection(apiPort);
break;
} catch (java.lang.RuntimeException ex) {
LOG.warn("Unable to open connection on try " + i + ". Waiting and trying again");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
return gaugeConn;
} else {
return null;
}
}
use of com.thoughtworks.gauge.connection.GaugeConnection in project Intellij-Plugin by getgauge.
the class SpecPsiImplUtil method getStepValueFor.
public static StepValue getStepValueFor(Module module, PsiElement element, String stepText, Boolean hasInlineTable) {
GaugeService gaugeService = Gauge.getGaugeService(module, false);
if (gaugeService == null) {
return getDefaultStepValue(element);
}
GaugeConnection apiConnection = gaugeService.getGaugeConnection();
if (apiConnection == null) {
return getDefaultStepValue(element);
}
StepValue value = StepUtil.getStepValue(apiConnection, stepText, hasInlineTable);
return value == null ? getDefaultStepValue(element) : value;
}
use of com.thoughtworks.gauge.connection.GaugeConnection 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.connection.GaugeConnection 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.connection.GaugeConnection 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