本文整理汇总了Java中com.intellij.mock.MockProject类的典型用法代码示例。如果您正苦于以下问题:Java MockProject类的具体用法?Java MockProject怎么用?Java MockProject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockProject类属于com.intellij.mock包,在下文中一共展示了MockProject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialiseEventsConsumer
import com.intellij.mock.MockProject; //导入依赖的package包/类
public BuckEventsConsumer initialiseEventsConsumer() {
Extensions.registerAreaClass("IDEA_PROJECT", null);
MockDisposable mockDisposable = new MockDisposable();
MockProject project = new MockProjectEx(new MockDisposable());
MockApplication application = new MyMockApplication(mockDisposable);
ApplicationManager.setApplication(application, mockDisposable);
final BuckEventsConsumer buckEventsConsumer = new BuckEventsConsumer(project);
project.registerService(BuckUIManager.class, new BuckUIManager());
project.registerService(ToolWindowManager.class, new Mock.MyToolWindowManager());
application.registerService(
FileDocumentManager.class, new MockFileDocumentManagerImpl(null, null));
application.registerService(
VirtualFileManager.class, EasyMock.createMock(VirtualFileManager.class));
return buckEventsConsumer;
}
示例2: createTemplateConfiguration
import com.intellij.mock.MockProject; //导入依赖的package包/类
@Test
public void createTemplateConfiguration() {
Extensions.registerAreaClass("IDEA_PROJECT", null);
MockDisposable mockDisposable = new MockDisposable();
MockProject project = new MockProjectEx(mockDisposable);
ConfigurationTypeLivingDoc configurationTypeLivingDoc = new ConfigurationTypeLivingDoc();
RemoteConfigurationFactory remoteConfigurationFactory = new RemoteConfigurationFactory(configurationTypeLivingDoc);
RunConfiguration runConfiguration = remoteConfigurationFactory
.createTemplateConfiguration(project);
Assert.assertNotNull(runConfiguration);
}
示例3: loadProject
import com.intellij.mock.MockProject; //导入依赖的package包/类
public static boolean loadProject(MockProject project, @NotNull VirtualFile virtualFile)
throws IOException, JDOMException, InvalidDataException {
if (virtualFile.isDirectory() && virtualFile.findChild(Project.DIRECTORY_STORE_FOLDER) != null) {
project.setBaseDir(virtualFile);
loadDirectoryProject(project, virtualFile);
return true;
}
// TODO load .ipr
return false;
}
示例4: loadDirectoryProject
import com.intellij.mock.MockProject; //导入依赖的package包/类
private static void loadDirectoryProject(MockProject project, VirtualFile projectDir) throws IOException, JDOMException,
InvalidDataException {
VirtualFile dotIdea = projectDir.findChild(Project.DIRECTORY_STORE_FOLDER);
if (dotIdea == null)
throw new FileNotFoundException("Missing '" + Project.DIRECTORY_STORE_FOLDER + "' in " + projectDir.getPath());
VirtualFile modulesXml = dotIdea.findChild("modules.xml");
if (modulesXml == null)
throw new FileNotFoundException("Missing 'modules.xml' in " + dotIdea.getPath());
TreeMap<String, Element> storageData = loadStorageFile(project, modulesXml);
final Element moduleManagerState = storageData.get("ProjectModuleManager");
if (moduleManagerState == null) {
throw new JDOMException("cannot find ProjectModuleManager state in modules.xml");
}
final CoreModuleManager moduleManager = (CoreModuleManager)ModuleManager.getInstance(project);
moduleManager.loadState(moduleManagerState);
VirtualFile miscXml = dotIdea.findChild("misc.xml");
if (miscXml == null)
throw new FileNotFoundException("Missing 'misc.xml' in " + dotIdea.getPath());
storageData = loadStorageFile(project, miscXml);
final Element projectRootManagerState = storageData.get("ProjectRootManager");
if (projectRootManagerState == null) {
throw new JDOMException("cannot find ProjectRootManager state in misc.xml");
}
((ProjectRootManagerImpl) ProjectRootManager.getInstance(project)).loadState(projectRootManagerState);
VirtualFile libraries = dotIdea.findChild("libraries");
if (libraries != null) {
Map<String, Element> data = DirectoryStorageUtil.loadFrom(libraries, PathMacroManager.getInstance(project).createTrackingSubstitutor());
Element libraryTable = DefaultStateSerializer.deserializeState(DirectoryStorageUtil.getCompositeState(data, new ProjectLibraryTable.LibraryStateSplitter()), Element.class, null);
((LibraryTableBase) ProjectLibraryTable.getInstance(project)).loadState(libraryTable);
}
moduleManager.loadModules();
project.projectOpened();
}
示例5: ProjectEnvironment
import com.intellij.mock.MockProject; //导入依赖的package包/类
public ProjectEnvironment(CoreProjectEnvironment projectEnvironment) {
MockProject project = projectEnvironment.getProject();
project.registerService(GroovyPsiElementFactory.class, GroovyPsiElementFactoryImpl.class);
project.registerService(GroovyPsiManager.class, GroovyPsiManager.class);
project.registerService(GroovyCodeStyleManager.class, CoreGroovyCodeStyleManager.class);
project.registerService(GroovyCodeStyleSettingsFacade.class, CoreGroovyCodeStyleSettingsFacade.class);
project.registerService(GroovyExtensionProvider.class, GroovyExtensionProvider.class);
projectEnvironment.addProjectExtension(PsiShortNamesCache.EP_NAME, new GroovyShortNamesCache(project));
projectEnvironment.addProjectExtension(PsiElementFinder.EP_NAME, new GroovyClassFinder(project));
TextEditorHighlightingPassRegistrar registrar = TextEditorHighlightingPassRegistrar.getInstance(project);
projectEnvironment.registerProjectComponent(GroovyUnusedImportsPassFactory.class, new GroovyUnusedImportsPassFactory(project, registrar));
projectEnvironment.registerProjectComponent(GrKeywordAndDeclarationHighlightFactory.class, new GrKeywordAndDeclarationHighlightFactory(project, registrar));
projectEnvironment.registerProjectComponent(GrReferenceHighlighterFactory.class, new GrReferenceHighlighterFactory(project, registrar));
}
示例6: mockProject
import com.intellij.mock.MockProject; //导入依赖的package包/类
@NotNull
public static MockProject mockProject(
@Nullable PicoContainer container, Disposable parentDisposable) {
Extensions.registerAreaClass("IDEA_PROJECT", null);
container = container != null ? container : new DefaultPicoContainer();
return new MockProject(container, parentDisposable);
}
示例7: setup
import com.intellij.mock.MockProject; //导入依赖的package包/类
@Before
public final void setup() {
testDisposable = new RootDisposable();
TestUtils.createMockApplication(testDisposable);
MutablePicoContainer applicationContainer =
(MutablePicoContainer) ApplicationManager.getApplication().getPicoContainer();
MockProject mockProject = TestUtils.mockProject(applicationContainer, testDisposable);
Extensions.cleanRootArea(testDisposable);
extensionsArea = (ExtensionsAreaImpl) Extensions.getRootArea();
this.project = mockProject;
initTest(new Container(applicationContainer), new Container(mockProject.getPicoContainer()));
}
示例8: mockProject
import com.intellij.mock.MockProject; //导入依赖的package包/类
/** Construct a mock project. */
@NotNull
public static MockProject mockProject(@Nullable PicoContainer container) {
Extensions.registerAreaClass("IDEA_PROJECT", null);
container = container != null ? container : new DefaultPicoContainer();
return new MockProject(container, getParentDisposableForCleanup());
}
示例9: loadDirectoryProject
import com.intellij.mock.MockProject; //导入依赖的package包/类
private static void loadDirectoryProject(MockProject project, VirtualFile projectDir) throws IOException, JDOMException,
InvalidDataException {
VirtualFile dotIdea = projectDir.findChild(Project.DIRECTORY_STORE_FOLDER);
VirtualFile modulesXml = dotIdea.findChild("modules.xml");
StorageData storageData = loadStorageFile(project, modulesXml);
final Element moduleManagerState = storageData.getState("ProjectModuleManager");
if (moduleManagerState == null) {
throw new JDOMException("cannot find ProjectModuleManager state in modules.xml");
}
final CoreModuleManager moduleManager = (CoreModuleManager)ModuleManager.getInstance(project);
moduleManager.loadState(moduleManagerState);
VirtualFile miscXml = dotIdea.findChild("misc.xml");
storageData = loadStorageFile(project, miscXml);
final Element projectRootManagerState = storageData.getState("ProjectRootManager");
if (projectRootManagerState == null) {
throw new JDOMException("cannot find ProjectRootManager state in misc.xml");
}
((ProjectRootManagerImpl) ProjectRootManager.getInstance(project)).readExternal(projectRootManagerState);
VirtualFile libraries = dotIdea.findChild("libraries");
if (libraries != null) {
DirectoryStorageData data = new DirectoryStorageData();
data.loadFrom(libraries, PathMacroManager.getInstance(project).createTrackingSubstitutor());
final Element libraryTable = data.getMergedState("libraryTable", Element.class, new ProjectLibraryTable.LibraryStateSplitter(), null);
((LibraryTableBase) ProjectLibraryTable.getInstance(project)).loadState(libraryTable);
}
moduleManager.loadModules();
project.projectOpened();
}
示例10: CoreProjectEnvironment
import com.intellij.mock.MockProject; //导入依赖的package包/类
public CoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) {
myParentDisposable = parentDisposable;
myEnvironment = applicationEnvironment;
myProject = new MockProject(myEnvironment.getApplication().getPicoContainer(), myParentDisposable);
preregisterServices();
myFileIndexFacade = createFileIndexFacade();
myMessageBus = new MessageBusImpl("CoreProjectEnvironment", null);
PsiModificationTrackerImpl modificationTracker = new PsiModificationTrackerImpl(myProject);
myProject.registerService(PsiModificationTracker.class, modificationTracker);
myProject.registerService(FileIndexFacade.class, myFileIndexFacade);
myProject.registerService(ResolveCache.class, new ResolveCache(myMessageBus));
registerProjectExtensionPoint(PsiTreeChangePreprocessor.EP_NAME, PsiTreeChangePreprocessor.class);
myPsiManager = new PsiManagerImpl(myProject, null, null, myFileIndexFacade, myMessageBus, modificationTracker);
((FileManagerImpl) myPsiManager.getFileManager()).markInitialized();
registerProjectComponent(PsiManager.class, myPsiManager);
myProject.registerService(ResolveScopeManager.class, createResolveScopeManager(myPsiManager));
myProject.registerService(PsiFileFactory.class, new PsiFileFactoryImpl(myPsiManager));
myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager)));
myProject.registerService(PsiDirectoryFactory.class, new PsiDirectoryFactoryImpl(myPsiManager));
myProject.registerService(ProjectScopeBuilder.class, createProjectScopeBuilder());
myProject.registerService(DumbService.class, new MockDumbService(myProject));
}
示例11: setUp
import com.intellij.mock.MockProject; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
homeDirectory.setParent(rootDirectory);
studioProjectsDirectory.setParent(homeDirectory);
projectDirectory.setParent(studioProjectsDirectory);
project = mock(MockProject.class);
when(project.getBaseDir()).thenReturn(projectDirectory);
}
示例12: setUp
import com.intellij.mock.MockProject; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
Extensions.registerAreaClass("IDEA_PROJECT", null);
myProject = new MockProject(null, new Disposable() {
@Override
public void dispose() {
}
});
}
示例13: CoreProjectEnvironment
import com.intellij.mock.MockProject; //导入依赖的package包/类
public CoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) {
myParentDisposable = parentDisposable;
myEnvironment = applicationEnvironment;
myProject = new MockProject(myEnvironment.getApplication().getPicoContainer(), myParentDisposable);
preregisterServices();
myFileIndexFacade = createFileIndexFacade();
myMessageBus = (MessageBusImpl)myProject.getMessageBus();
PsiModificationTrackerImpl modificationTracker = new PsiModificationTrackerImpl(myProject);
myProject.registerService(PsiModificationTracker.class, modificationTracker);
myProject.registerService(FileIndexFacade.class, myFileIndexFacade);
myProject.registerService(ResolveCache.class, new ResolveCache(myMessageBus));
registerProjectExtensionPoint(PsiTreeChangePreprocessor.EP_NAME, PsiTreeChangePreprocessor.class);
myPsiManager = new PsiManagerImpl(myProject, null, null, myFileIndexFacade, myMessageBus, modificationTracker);
((FileManagerImpl)myPsiManager.getFileManager()).markInitialized();
registerProjectComponent(PsiManager.class, myPsiManager);
registerProjectComponent(PsiDocumentManager.class, new CorePsiDocumentManager(myProject, myPsiManager, myMessageBus, new MockDocumentCommitProcessor()));
myProject.registerService(ResolveScopeManager.class, createResolveScopeManager(myPsiManager));
myProject.registerService(PsiFileFactory.class, new PsiFileFactoryImpl(myPsiManager));
myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager)));
myProject.registerService(ProjectScopeBuilder.class, createProjectScopeBuilder());
myProject.registerService(DumbService.class, new MockDumbService(myProject));
}
示例14: testReady
import com.intellij.mock.MockProject; //导入依赖的package包/类
public void testReady() {
assertReady(null);
MockProject project1 = new MockProjectEx(getTestRootDisposable());
assertReady(project1);
MockProject project2 = new MockProjectEx(getTestRootDisposable());
assertReady(project2);
myMonitor.initBusyObjectFor(project1);
assertTrue(myMonitor.hasObjectFor(project1));
myMonitor.initBusyObjectFor(project2);
assertTrue(myMonitor.hasObjectFor(project2));
myMonitor.addActivity(new UiActivity("global"), ModalityState.any());
assertBusy(null);
assertBusy(project1);
assertBusy(project2);
myMonitor.addActivity(new UiActivity("global"), ModalityState.any());
assertBusy(null);
assertBusy(project1);
assertBusy(project2);
myMonitor.removeActivity(new UiActivity("global"));
assertReady(null);
assertReady(project1);
assertReady(project2);
myMonitor.addActivity(project1, new UiActivity("p1"), ModalityState.any());
assertReady(null);
assertBusy(project1);
assertReady(project2);
myMonitor.addActivity(new UiActivity("global"), ModalityState.any());
assertBusy(null);
assertBusy(project1);
assertBusy(project2);
myMonitor.removeActivity(new UiActivity("global"));
assertReady(null);
assertBusy(project1);
assertReady(project2);
myMonitor.removeActivity(project1, new UiActivity("p1"));
assertReady(null);
assertReady(project1);
assertReady(project2);
}
示例15: createProject
import com.intellij.mock.MockProject; //导入依赖的package包/类
@SuppressWarnings("MethodMayBeStatic")
@NotNull
protected MockProject createProject(@NotNull PicoContainer parent, @NotNull Disposable parentDisposable) {
return new MockProject(parent, parentDisposable);
}