use of com.intellij.lang.javascript.linter.tslint.config.TsLintState in project intellij-plugins by JetBrains.
the class TsLintFileFixAction method createTask.
@Override
protected Task createTask(@NotNull Project project, @NotNull Collection<VirtualFile> filesToProcess, @NotNull Runnable completeCallback) {
LocalHistory.getInstance().putSystemLabel(project, JSBundle.message("javascript.linter.action.fix.problems.name.start", TsLintBundle.message("tslint.framework.title")));
return new Task.Backgroundable(project, TsLintBundle.message("tslint.action.background.title"), true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
TsLintLanguageService service = TsLintLanguageService.getService(project);
TsLintState state = TsLintConfiguration.getInstance(project).getExtendedState().getState();
for (VirtualFile file : filesToProcess) {
indicator.setText("Processing file " + file.getCanonicalPath());
Future<List<TsLinterError>> future = ReadAction.compute(() -> service.highlightAndFix(file, state));
JSLanguageServiceUtil.awaitFuture(future, JSLanguageServiceUtil.TIMEOUT_MILLS, JSLanguageServiceUtil.QUOTA_MILLS, indicator);
}
completeCallback.run();
}
};
}
use of com.intellij.lang.javascript.linter.tslint.config.TsLintState in project intellij-plugins by JetBrains.
the class TsLintExternalAnnotator method annotate.
@Nullable
@Override
public JSLinterAnnotationResult<TsLintState> annotate(@NotNull TsLinterInput collectedInfo) {
TsLintLanguageService service = TsLintLanguageService.getService(collectedInfo.getProject());
VirtualFile config = collectedInfo.getConfig();
Future<List<TsLinterError>> highlight = service.highlight(collectedInfo.getVirtualFile(), config, collectedInfo.getFileContent());
List<TsLinterError> annotationErrors = JSLanguageServiceUtil.awaitFuture(highlight);
if (annotationErrors == null) {
if (!service.isServiceCreated() || service.getServiceCreationError() != null) {
String error = service.getServiceCreationError();
error = error == null ? JSLanguageServiceQueueImpl.CANNOT_START_LANGUAGE_SERVICE_PROCESS : error;
return JSLinterAnnotationResult.create(collectedInfo, new JSLinterFileLevelAnnotation(error), config);
}
return null;
}
if (!annotationErrors.isEmpty()) {
final Optional<TsLinterError> globalError = annotationErrors.stream().filter(error -> error.isGlobal()).findFirst();
if (globalError.isPresent()) {
final JSLinterAnnotationResult<TsLintState> annotation = createGlobalErrorMessage(collectedInfo, config, globalError.get().getDescription());
if (annotation != null)
return annotation;
}
}
List<JSLinterError> result = filterResultByFile(collectedInfo, annotationErrors);
return JSLinterAnnotationResult.createLinterResult(collectedInfo, result, config);
}
use of com.intellij.lang.javascript.linter.tslint.config.TsLintState in project intellij-plugins by JetBrains.
the class TsLintConfigurable method apply.
@Override
public void apply() throws ConfigurationException {
super.apply();
final TsLintState state = getExtendedState(TsLintConfiguration.class).getState();
if (!StringUtil.isEmptyOrSpaces(state.getPackagePath()) && state.isAllowJs()) {
if (!checkPackageVersionForJs(state.getPackagePath()))
throw new ConfigurationException("Linting JavaScript is not supported for this version of TSLint.");
}
final TsLintLanguageService service = TsLintLanguageService.getService(myProject);
service.terminateStartedProcess(false);
}
use of com.intellij.lang.javascript.linter.tslint.config.TsLintState in project intellij-plugins by JetBrains.
the class TsLintConfigFileChangeTracker method isAnalyzerRestartNeeded.
@Override
protected boolean isAnalyzerRestartNeeded(@NotNull Project project, @NotNull VirtualFile changedFile) {
final TsLintConfiguration configuration = TsLintConfiguration.getInstance(project);
final TsLintState state = configuration.getExtendedState().getState();
if (state.isCustomConfigFileUsed() && state.getCustomConfigFilePath() != null) {
final VirtualFile configVirtualFile = JSLinterConfigFileUtil.findLocalFileByPath(state.getCustomConfigFilePath());
return changedFile.equals(configVirtualFile);
} else if (TSLINT_JSON.equals(changedFile.getName())) {
return true;
}
return false;
}
Aggregations