Search in sources :

Example 51 with TestOnly

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

the class UpdateRequestsQueue method waitUntilRefreshed.

@TestOnly
public void waitUntilRefreshed() {
    while (true) {
        final Semaphore semaphore = new Semaphore();
        synchronized (myLock) {
            if (!myRequestSubmitted && !myRequestRunning) {
                return;
            }
            if (!myRequestRunning) {
                myFuture.set(myExecutor.submit(new MyRunnable()));
            }
            semaphore.down();
            myWaitingUpdateCompletionSemaphores.add(semaphore);
        }
        if (!semaphore.waitFor(100 * 1000)) {
            LOG.error("Too long VCS update");
            return;
        }
    }
}
Also used : Semaphore(com.intellij.util.concurrency.Semaphore) TestOnly(org.jetbrains.annotations.TestOnly)

Example 52 with TestOnly

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

the class GCUtil method tryGcSoftlyReachableObjects.

/**
   * Try to force VM to collect soft references if possible.
   * Method doesn't guarantee to succeed, and should not be used in the production code.
   * Commits / hours optimized method code: 5 / 3
   */
@TestOnly
public static void tryGcSoftlyReachableObjects() {
    //long started = System.nanoTime();
    ReferenceQueue<Object> q = new ReferenceQueue<Object>();
    SoftReference<Object> ref = new SoftReference<Object>(new Object(), q);
    ArrayList<SoftReference<?>> list = ContainerUtil.newArrayListWithCapacity(100 + useReference(ref));
    System.gc();
    final long freeMemory = Runtime.getRuntime().freeMemory();
    for (int i = 0; i < 100; i++) {
        if (q.poll() != null) {
            break;
        }
        // full gc is caused by allocation of large enough array below, SoftReference will be cleared after two full gc
        int bytes = Math.min((int) (freeMemory * 0.45), Integer.MAX_VALUE / 2);
        list.add(new SoftReference<Object>(new byte[bytes]));
    }
    // use ref is important as to loop to finish with several iterations: long runs of the method (~80 run of PsiModificationTrackerTest)
    // discovered 'ref' being collected and loop iterated 100 times taking a lot of time
    list.ensureCapacity(list.size() + useReference(ref));
    // do not leave a chance for our created SoftReference's content to lie around until next full GC's
    for (SoftReference createdReference : list) createdReference.clear();
//System.out.println("Done gc'ing refs:" + ((System.nanoTime() - started) / 1000000));
}
Also used : ReferenceQueue(java.lang.ref.ReferenceQueue) SoftReference(java.lang.ref.SoftReference) TestOnly(org.jetbrains.annotations.TestOnly)

Example 53 with TestOnly

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

the class JSLibraryStdDescription method createNewLibraryForTests.

@TestOnly
public NewLibraryConfiguration createNewLibraryForTests() {
    KotlinJsModuleConfigurator configurator = (KotlinJsModuleConfigurator) getConfiguratorByName(NAME);
    assert configurator != null : "Cannot find configurator with name " + NAME;
    RuntimeLibraryFiles files = configurator.getExistingJarFiles();
    return createConfiguration(Collections.singletonList(files.getRuntimeJar()), files.getRuntimeSourcesJar());
}
Also used : RuntimeLibraryFiles(org.jetbrains.kotlin.idea.configuration.RuntimeLibraryFiles) KotlinJsModuleConfigurator(org.jetbrains.kotlin.idea.configuration.KotlinJsModuleConfigurator) TestOnly(org.jetbrains.annotations.TestOnly)

Example 54 with TestOnly

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

the class ClassFileFactory method createText.

@NotNull
@TestOnly
public String createText() {
    StringBuilder answer = new StringBuilder();
    for (OutputFile file : asList()) {
        answer.append("@").append(file.getRelativePath()).append('\n');
        answer.append(file.asText());
    }
    return answer.toString();
}
Also used : OutputFile(org.jetbrains.kotlin.backend.common.output.OutputFile) TestOnly(org.jetbrains.annotations.TestOnly) NotNull(org.jetbrains.annotations.NotNull)

Example 55 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)

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