use of org.jetbrains.annotations.TestOnly in project intellij-community by JetBrains.
the class FileBasedIndexImpl method cleanupForNextTest.
@TestOnly
public void cleanupForNextTest() {
myChangedFilesCollector.ensureUpToDate();
myTransactionMap = SmartFMap.emptyMap();
IndexConfiguration state = getState();
for (ID<?, ?> indexId : state.getIndexIDs()) {
final MapReduceIndex index = (MapReduceIndex) state.getIndex(indexId);
assert index != null;
final MemoryIndexStorage memStorage = (MemoryIndexStorage) index.getStorage();
index.getWriteLock().lock();
try {
memStorage.clearCaches();
} finally {
index.getWriteLock().unlock();
}
}
}
use of org.jetbrains.annotations.TestOnly in project intellij-community by JetBrains.
the class ProjectTypeStep method availableTemplateGroupsToString.
@TestOnly
public String availableTemplateGroupsToString() {
ListModel model = myProjectTypeList.getModel();
StringBuilder builder = new StringBuilder();
for (int i = 0; i < model.getSize(); i++) {
if (builder.length() > 0) {
builder.append(", ");
}
builder.append(((TemplatesGroup) model.getElementAt(i)).getName());
}
return builder.toString();
}
use of org.jetbrains.annotations.TestOnly in project intellij-community by JetBrains.
the class ComponentManagerImpl method registerComponentInstance.
@SuppressWarnings("unchecked")
@TestOnly
public synchronized <T> T registerComponentInstance(@NotNull Class<T> componentKey, @NotNull T componentImplementation) {
MutablePicoContainer picoContainer = getPicoContainer();
ComponentAdapter adapter = picoContainer.getComponentAdapter(componentKey);
LOG.assertTrue(adapter instanceof ComponentConfigComponentAdapter);
ComponentConfigComponentAdapter componentAdapter = (ComponentConfigComponentAdapter) adapter;
Object oldInstance = componentAdapter.myInitializedComponentInstance;
// we don't update pluginId - method is test only
componentAdapter.myInitializedComponentInstance = componentImplementation;
return (T) oldInstance;
}
use of org.jetbrains.annotations.TestOnly in project intellij-community by JetBrains.
the class JavaProjectCodeInsightSettings method setExcludedNames.
@TestOnly
public static void setExcludedNames(Project project, Disposable parentDisposable, String... excludes) {
final JavaProjectCodeInsightSettings instance = getSettings(project);
assert instance.excludedNames.isEmpty();
instance.excludedNames = Arrays.asList(excludes);
Disposer.register(parentDisposable, new Disposable() {
@Override
public void dispose() {
instance.excludedNames = ContainerUtil.newArrayList();
}
});
}
use of org.jetbrains.annotations.TestOnly in project intellij-community by JetBrains.
the class JavaSdkImpl method createMockJdk.
@NotNull
@TestOnly
public Sdk createMockJdk(@NotNull String jdkName, @NotNull String home, boolean isJre) {
String homePath = home.replace(File.separatorChar, '/');
File jdkHomeFile = new File(homePath);
ProjectRootContainerImpl rootContainer = new ProjectRootContainerImpl(true);
SdkModificator sdkModificator = new SdkModificator() {
@Override
public String getName() {
throw new UnsupportedOperationException();
}
@Override
public void setName(String name) {
throw new UnsupportedOperationException();
}
@Override
public String getHomePath() {
throw new UnsupportedOperationException();
}
@Override
public void setHomePath(String path) {
throw new UnsupportedOperationException();
}
@Override
public String getVersionString() {
throw new UnsupportedOperationException();
}
@Override
public void setVersionString(String versionString) {
throw new UnsupportedOperationException();
}
@Override
public SdkAdditionalData getSdkAdditionalData() {
throw new UnsupportedOperationException();
}
@Override
public void setSdkAdditionalData(SdkAdditionalData data) {
throw new UnsupportedOperationException();
}
@Override
public VirtualFile[] getRoots(OrderRootType rootType) {
throw new UnsupportedOperationException();
}
@Override
public void removeRoot(VirtualFile root, OrderRootType rootType) {
throw new UnsupportedOperationException();
}
@Override
public void removeRoots(OrderRootType rootType) {
throw new UnsupportedOperationException();
}
@Override
public void removeAllRoots() {
throw new UnsupportedOperationException();
}
@Override
public void commitChanges() {
throw new UnsupportedOperationException();
}
@Override
public boolean isWritable() {
throw new UnsupportedOperationException();
}
@Override
public void addRoot(VirtualFile root, OrderRootType rootType) {
rootContainer.addRoot(root, rootType);
}
};
rootContainer.startChange();
addClasses(jdkHomeFile, sdkModificator, isJre);
addSources(jdkHomeFile, sdkModificator);
rootContainer.finishChange();
ProjectJdkImpl jdk = new ProjectJdkImpl(jdkName, this, homePath, jdkName) {
@Override
public void setName(@NotNull String name) {
throwReadOnly();
}
@Override
public void readExternal(@NotNull Element element) {
throwReadOnly();
}
@Override
public void readExternal(@NotNull Element element, @Nullable ProjectJdkTable projectJdkTable) {
throwReadOnly();
}
@NotNull
@Override
public SdkModificator getSdkModificator() {
throwReadOnly();
return null;
}
@Override
public void setSdkAdditionalData(SdkAdditionalData data) {
throwReadOnly();
}
@Override
public void addRoot(VirtualFile root, OrderRootType rootType) {
throwReadOnly();
}
@Override
public void removeRoot(VirtualFile root, OrderRootType rootType) {
throwReadOnly();
}
@Override
public void removeRoots(OrderRootType rootType) {
throwReadOnly();
}
@Override
public void removeAllRoots() {
throwReadOnly();
}
@Override
public boolean isWritable() {
return false;
}
@Override
public void update() {
throwReadOnly();
}
@Override
public VirtualFile[] getRoots(OrderRootType rootType) {
return rootContainer.getRootFiles(rootType);
}
@NotNull
@Override
public RootProvider getRootProvider() {
return new RootProvider() {
@NotNull
@Override
public String[] getUrls(@NotNull OrderRootType rootType) {
return ContainerUtil.map2Array(getFiles(rootType), String.class, VirtualFile::getUrl);
}
@NotNull
@Override
public VirtualFile[] getFiles(@NotNull OrderRootType rootType) {
return getRoots(rootType);
}
@Override
public void addRootSetChangedListener(@NotNull RootSetChangedListener listener) {
}
@Override
public void addRootSetChangedListener(@NotNull RootSetChangedListener listener, @NotNull Disposable parentDisposable) {
}
@Override
public void removeRootSetChangedListener(@NotNull RootSetChangedListener listener) {
}
};
}
private void throwReadOnly() {
throw new IncorrectOperationException("Can't modify, MockJDK is read-only, consider calling .clone() first");
}
};
ProjectJdkImpl.copyRoots(rootContainer, jdk);
return jdk;
}
Aggregations