Search in sources :

Example 1 with TsLintConfiguration

use of com.intellij.lang.javascript.linter.tslint.config.TsLintConfiguration in project intellij-plugins by JetBrains.

the class TsLintHighlightingTest method runTest.

private void runTest(boolean copyConfig, boolean useConfig, @Nullable LineSeparator lineSeparator, String... filePathToTest) {
    final String[] paths = copyConfig ? filePathToTest : new String[] { filePathToTest[0] };
    final PsiFile[] files = myFixture.configureByFiles(paths);
    if (lineSeparator != null) {
        Arrays.stream(files).forEach(file -> ensureLineSeparators(file.getVirtualFile(), lineSeparator.getSeparatorString()));
    }
    final TsLintConfiguration configuration = TsLintConfiguration.getInstance(getProject());
    final TsLintState.Builder builder = new TsLintState.Builder(configuration.getExtendedState().getState());
    if (useConfig) {
        final String configPath = copyConfig ? FileUtil.toSystemDependentName(files[files.length - 1].getVirtualFile().getPath()) : "aaa";
        builder.setCustomConfigFileUsed(true).setCustomConfigFilePath(configPath);
    }
    configuration.setExtendedState(true, builder.build());
    myFixture.testHighlighting(true, false, true);
}
Also used : TsLintState(com.intellij.lang.javascript.linter.tslint.config.TsLintState) TsLintConfiguration(com.intellij.lang.javascript.linter.tslint.config.TsLintConfiguration) PsiFile(com.intellij.psi.PsiFile)

Example 2 with TsLintConfiguration

use of com.intellij.lang.javascript.linter.tslint.config.TsLintConfiguration in project intellij-plugins by JetBrains.

the class TsLintExternalAnnotator method acceptPsiFile.

@Override
protected boolean acceptPsiFile(@NotNull PsiFile file) {
    if (!(file instanceof JSFile))
        return false;
    final TsLintConfiguration configuration = TsLintConfiguration.getInstance(file.getProject());
    if (configuration.isAllowJs() && JSUtils.isJavaScriptFile(file))
        return true;
    final DialectOptionHolder holder = DialectDetector.dialectOfFile(file);
    return holder != null && holder.isTypeScript;
}
Also used : DialectOptionHolder(com.intellij.lang.javascript.DialectOptionHolder) TsLintConfiguration(com.intellij.lang.javascript.linter.tslint.config.TsLintConfiguration) JSFile(com.intellij.lang.javascript.psi.JSFile)

Example 3 with TsLintConfiguration

use of com.intellij.lang.javascript.linter.tslint.config.TsLintConfiguration 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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TsLintState(com.intellij.lang.javascript.linter.tslint.config.TsLintState) TsLintConfiguration(com.intellij.lang.javascript.linter.tslint.config.TsLintConfiguration)

Aggregations

TsLintConfiguration (com.intellij.lang.javascript.linter.tslint.config.TsLintConfiguration)3 TsLintState (com.intellij.lang.javascript.linter.tslint.config.TsLintState)2 DialectOptionHolder (com.intellij.lang.javascript.DialectOptionHolder)1 JSFile (com.intellij.lang.javascript.psi.JSFile)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiFile (com.intellij.psi.PsiFile)1