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;
}
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);
}
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);
}
}
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;
}
});
}
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;
}
Aggregations