Search in sources :

Example 31 with TestOnly

use of org.jetbrains.annotations.TestOnly in project intellij-community by JetBrains.

the class CompilerReferenceServiceImpl method getReferentFiles.

@TestOnly
@Nullable
public Set<VirtualFile> getReferentFiles(@NotNull PsiElement element) {
    FileBasedIndex fileIndex = FileBasedIndex.getInstance();
    final TIntHashSet ids = getReferentFileIds(element);
    if (ids == null)
        return null;
    Set<VirtualFile> fileSet = new THashSet<>();
    ids.forEach(id -> {
        final VirtualFile vFile = fileIndex.findFileById(myProject, id);
        assert vFile != null;
        fileSet.add(vFile);
        return true;
    });
    return fileSet;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileBasedIndex(com.intellij.util.indexing.FileBasedIndex) TIntHashSet(gnu.trove.TIntHashSet) THashSet(gnu.trove.THashSet) TestOnly(org.jetbrains.annotations.TestOnly) Nullable(org.jetbrains.annotations.Nullable)

Example 32 with TestOnly

use of org.jetbrains.annotations.TestOnly in project android by JetBrains.

the class GradleWrapper method updateDistributionUrl.

@TestOnly
public void updateDistributionUrl(@NotNull File gradleDistribution) throws IOException {
    String path = gradleDistribution.getPath();
    if (!extensionEquals(path, "zip")) {
        throw new IllegalArgumentException("'" + path + "' should be a zip file");
    }
    Properties properties = getProperties();
    properties.setProperty(DISTRIBUTION_URL_PROPERTY, gradleDistribution.toURI().toURL().toString());
    savePropertiesToFile(properties, myPropertiesFilePath, null);
}
Also used : Properties(java.util.Properties) TestOnly(org.jetbrains.annotations.TestOnly)

Example 33 with TestOnly

use of org.jetbrains.annotations.TestOnly in project intellij-plugins by JetBrains.

the class LibraryUtil method getTestGlobalLibrary.

@TestOnly
static // we cannot use LocalFileSystem, because our test can run outside the idea
VirtualFile getTestGlobalLibrary(boolean isPlayer) {
    String name = (isPlayer ? "player" : "air") + "-catalog.xml";
    File file = new File(DebugPathManager.getTestDataPath() + "/lib/playerglobal", name);
    assert file.exists();
    try {
        return new LightVirtualFile(name, XmlFileType.INSTANCE, IOUtil.getCharSequence(file), StandardCharsets.UTF_8, 0);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : LightVirtualFile(com.intellij.testFramework.LightVirtualFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) TestOnly(org.jetbrains.annotations.TestOnly)

Example 34 with TestOnly

use of org.jetbrains.annotations.TestOnly in project intellij-community by JetBrains.

the class RecursionManager method assertOnRecursionPrevention.

@TestOnly
public static void assertOnRecursionPrevention(@NotNull Disposable parentDisposable) {
    ourAssertOnPrevention = true;
    Disposer.register(parentDisposable, new Disposable() {

        @Override
        public void dispose() {
            //noinspection AssignmentToStaticFieldFromInstanceMethod
            ourAssertOnPrevention = false;
        }
    });
}
Also used : Disposable(com.intellij.openapi.Disposable) TestOnly(org.jetbrains.annotations.TestOnly)

Example 35 with TestOnly

use of org.jetbrains.annotations.TestOnly in project intellij-community by JetBrains.

the class CodeInsightTestFixtureImpl method instantiateAndRun.

@NotNull
@TestOnly
public static List<HighlightInfo> instantiateAndRun(@NotNull PsiFile file, @NotNull Editor editor, @NotNull int[] toIgnore, boolean canChangeDocument) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    Project project = file.getProject();
    ensureIndexesUpToDate(project);
    DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(project);
    TextEditor textEditor = TextEditorProvider.getInstance().getTextEditor(editor);
    DaemonCodeAnalyzerSettings settings = DaemonCodeAnalyzerSettings.getInstance();
    ProcessCanceledException exception = null;
    for (int i = 0; i < 1000; i++) {
        int oldDelay = settings.AUTOREPARSE_DELAY;
        try {
            settings.AUTOREPARSE_DELAY = 0;
            List<HighlightInfo> infos = codeAnalyzer.runPasses(file, editor.getDocument(), textEditor, toIgnore, canChangeDocument, null);
            infos.addAll(DaemonCodeAnalyzerEx.getInstanceEx(project).getFileLevelHighlights(project, file));
            return infos;
        } catch (ProcessCanceledException e) {
            PsiDocumentManager.getInstance(project).commitAllDocuments();
            UIUtil.dispatchAllInvocationEvents();
            exception = e;
        } finally {
            settings.AUTOREPARSE_DELAY = oldDelay;
        }
    }
    // unable to highlight after 100 retries
    throw exception;
}
Also used : DaemonCodeAnalyzerSettings(com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings) Project(com.intellij.openapi.project.Project) ExtensionPoint(com.intellij.openapi.extensions.ExtensionPoint) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) TestOnly(org.jetbrains.annotations.TestOnly) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

TestOnly (org.jetbrains.annotations.TestOnly)56 Disposable (com.intellij.openapi.Disposable)18 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 NotNull (org.jetbrains.annotations.NotNull)7 Project (com.intellij.openapi.project.Project)5 Application (com.intellij.openapi.application.Application)4 Document (com.intellij.openapi.editor.Document)3 Editor (com.intellij.openapi.editor.Editor)3 THashSet (gnu.trove.THashSet)3 Nullable (org.jetbrains.annotations.Nullable)3 HighlightingPass (com.intellij.codeHighlighting.HighlightingPass)2 TextEditorHighlightingPass (com.intellij.codeHighlighting.TextEditorHighlightingPass)2 ApplicationEx (com.intellij.openapi.application.ex.ApplicationEx)2 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)2 CollectionListModel (com.intellij.ui.CollectionListModel)2 THashMap (gnu.trove.THashMap)2 BackgroundEditorHighlighter (com.intellij.codeHighlighting.BackgroundEditorHighlighter)1 Pass (com.intellij.codeHighlighting.Pass)1 AutoPopupController (com.intellij.codeInsight.AutoPopupController)1 com.intellij.codeInsight.daemon (com.intellij.codeInsight.daemon)1