use of com.google.jstestdriver.idea.execution.settings.JstdRunSettings in project intellij-plugins by JetBrains.
the class JstdRunConfiguration method readExternal.
@Override
public void readExternal(Element element) throws InvalidDataException {
super.readExternal(element);
JstdRunSettings runSettings = JstdRunSettingsSerializationUtils.readFromXml(element);
setRunSettings(runSettings);
}
use of com.google.jstestdriver.idea.execution.settings.JstdRunSettings in project intellij-plugins by JetBrains.
the class JstdRunConfigurationProducer method buildRunSettingsContext.
@Nullable
private static JstdRunSettings buildRunSettingsContext(@Nullable Location<?> location) {
if (location != null) {
PsiElement element = location.getPsiElement();
JstdRunSettings runSettings = findJstdRunSettings(element);
if (runSettings != null) {
return runSettings;
}
}
return null;
}
use of com.google.jstestdriver.idea.execution.settings.JstdRunSettings in project intellij-plugins by JetBrains.
the class JstdRunConfigurationRefactoringHandler method getRefactoringElementListener.
@Nullable
public static RefactoringElementListener getRefactoringElementListener(@NotNull JstdRunConfiguration configuration, @Nullable PsiElement element) {
VirtualFile fileAtElement = PsiUtilBase.asVirtualFile(element);
if (fileAtElement == null) {
return null;
}
JstdRunSettings settings = configuration.getRunSettings();
String path = fileAtElement.getPath();
if (settings.getTestType() == TestType.ALL_CONFIGS_IN_DIRECTORY) {
String allInDirectory = FileUtil.toSystemIndependentName(settings.getDirectory());
if (allInDirectory.equals(path)) {
return new FilePathRefactoringElementListener(configuration, false, false, true);
}
} else {
String jsFilePath = FileUtil.toSystemIndependentName(settings.getJsFilePath());
if (jsFilePath.equals(path)) {
return new FilePathRefactoringElementListener(configuration, false, true, false);
}
String configFilePath = FileUtil.toSystemIndependentName(settings.getConfigFile());
if (configFilePath.equals(path)) {
return new FilePathRefactoringElementListener(configuration, true, false, false);
}
}
return null;
}
use of com.google.jstestdriver.idea.execution.settings.JstdRunSettings in project intellij-plugins by JetBrains.
the class JstdRunConfigurationProducer method setupConfigurationFromContext.
@Override
protected boolean setupConfigurationFromContext(JstdRunConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
Project project = configuration.getProject();
if (!JstdSettingsUtil.areJstdConfigFilesInProjectCached(project)) {
return false;
}
RunConfiguration original = context.getOriginalConfiguration(null);
if (original != null && !ConfigurationTypeUtil.equals(original.getType(), JstdConfigurationType.getInstance())) {
return false;
}
long startTimeNano = System.nanoTime();
@SuppressWarnings({ "unchecked" }) JstdRunSettings settings = buildRunSettingsContext(context.getLocation());
if (settings == null) {
logDoneCreateConfigurationByElement(startTimeNano, "1");
return false;
}
if (settings.getConfigFile().isEmpty()) {
JstdRunSettings clonedSettings = configuration.getRunSettings();
JstdRunSettings.Builder builder = new JstdRunSettings.Builder(settings);
builder.setConfigFile(clonedSettings.getConfigFile());
settings = builder.build();
}
configuration.setRunSettings(settings);
String configurationName = configuration.resetGeneratedName();
configuration.setName(configurationName);
logDoneCreateConfigurationByElement(startTimeNano, "3");
return true;
}
use of com.google.jstestdriver.idea.execution.settings.JstdRunSettings in project intellij-plugins by JetBrains.
the class JstdRunConfigurationProducer method isConfigurationFromContext.
@Override
public boolean isConfigurationFromContext(JstdRunConfiguration configuration, ConfigurationContext context) {
Project project = configuration.getProject();
if (!JstdSettingsUtil.areJstdConfigFilesInProjectCached(project)) {
return false;
}
JstdRunSettings patternRunSettings = buildRunSettingsContext(context.getLocation());
if (patternRunSettings == null) {
return false;
}
JstdRunSettings candidateRunSettings = configuration.getRunSettings();
TestType patternTestType = patternRunSettings.getTestType();
if (patternTestType != candidateRunSettings.getTestType()) {
return false;
}
if (patternTestType == TestType.ALL_CONFIGS_IN_DIRECTORY) {
File dir1 = new File(patternRunSettings.getDirectory());
File dir2 = new File(candidateRunSettings.getDirectory());
if (dir1.isDirectory() && dir2.isDirectory() && FileUtil.filesEqual(dir1, dir2)) {
return true;
}
} else if (patternTestType == TestType.CONFIG_FILE) {
File configFilePattern = new File(patternRunSettings.getConfigFile());
File configFileCandidate = new File(candidateRunSettings.getConfigFile());
if (configFilePattern.isFile() && configFileCandidate.isFile() && FileUtil.filesEqual(configFilePattern, configFileCandidate)) {
return true;
}
} else if (patternTestType == TestType.JS_FILE || patternTestType == TestType.TEST_CASE || patternTestType == TestType.TEST_METHOD) {
File patternJsFile = new File(patternRunSettings.getJsFilePath());
File candidateJsFile = new File(candidateRunSettings.getJsFilePath());
boolean eq = candidateJsFile.isFile() && FileUtil.filesEqual(patternJsFile, candidateJsFile);
if (patternTestType == TestType.TEST_CASE) {
eq = eq && patternRunSettings.getTestCaseName().equals(candidateRunSettings.getTestCaseName());
}
if (patternTestType == TestType.TEST_METHOD) {
eq = eq && patternRunSettings.getTestCaseName().equals(candidateRunSettings.getTestCaseName());
eq = eq && patternRunSettings.getTestMethodName().equals(candidateRunSettings.getTestMethodName());
}
if (eq) {
return true;
}
}
return false;
}
Aggregations