com.intellij.openapi.project.Project.isInitialized()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(137)

本文整理了Java中com.intellij.openapi.project.Project.isInitialized()方法的一些代码示例,展示了Project.isInitialized()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.isInitialized()方法的具体详情如下:
包路径:com.intellij.openapi.project.Project
类名称:Project
方法名:isInitialized

Project.isInitialized介绍

暂无

代码示例

代码示例来源:origin: dubreuia/intellij-plugin-save-actions

private boolean isProjectValid(Project project) {
  return project.isInitialized()
      && !project.isDisposed();
}

代码示例来源:origin: groboclown/p4ic4idea

static boolean canSendMessage(@NotNull Project project) {
  return project.isInitialized() && !project.isDisposed();
}

代码示例来源:origin: sonar-intellij-plugin/sonar-intellij-plugin

private void updateHighlightingFor(Optional<VirtualFile> file,Project project) {
 if (file.isPresent() && !project.isDisposed() && project.isInitialized()) {
  Optional<PsiFile> psiFile = Optional.ofNullable(PsiManager.getInstance(project).findFile(file.get()));
  psiFile.ifPresent(psiFile1 -> DaemonCodeAnalyzer.getInstance(project).restart(psiFile1));
 }
}

代码示例来源:origin: SonarSource/sonarlint-intellij

@Test
public void disable_if_project_is_not_init() {
 when(project.isInitialized()).thenReturn(false);
 action.update(e);
 assertThat(presentation.isVisible()).isTrue();
 assertThat(presentation.isEnabled()).isFalse();
}

代码示例来源:origin: SonarSource/sonarlint-intellij

@Before
public void prepare() {
 status = new SonarLintStatus(project);
 super.register(project, SonarLintStatus.class, status);
 when(event.getProject()).thenReturn(project);
 when(project.isInitialized()).thenReturn(true);
 when(event.getPresentation()).thenReturn(presentation);
}

代码示例来源:origin: SonarSource/sonarlint-intellij

@Before
public void prepare() {
 register(SonarLintStatus.class, new SonarLintStatus(project));
 when(event.getPresentation()).thenReturn(presentation);
 when(project.isDisposed()).thenReturn(false);
 when(project.isInitialized()).thenReturn(true);
}

代码示例来源:origin: SonarSource/sonarlint-intellij

@Before
public void setup() {
 super.register(project, SonarLintProjectSettings.class, settings);
 super.register(app, SonarLintAppUtils.class, appUtils);
 when(appUtils.getRelativePathForAnalysis(project, file1)).thenReturn("file1");
 when(project.isInitialized()).thenReturn(true);
 when(e.getProject()).thenReturn(project);
 when(e.getPresentation()).thenReturn(presentation);
 when(e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY)).thenReturn(new VirtualFile[] {file1});
 when(e.getPlace()).thenReturn(EDITOR_POPUP);
}

代码示例来源:origin: groboclown/p4ic4idea

@Override
public void beforeEach(ExtensionContext extensionContext) {
  contextStack.add(0, extensionContext);
  DisposableRegistry parent = new DisposableRegistry();
  getStore(extensionContext).put("parent", parent);
  final FileTypeRegistry fileTypeRegistry = mock(FileTypeRegistry.class);
  getStore(extensionContext).put("fileTypeRegistry", fileTypeRegistry);
  Application original = ApplicationManager.getApplication();
  getStore(extensionContext).put("original-application", original);
  Application application = mock(Application.class);
  ApplicationManager.setApplication(application, () -> fileTypeRegistry, parent);
  getStore(extensionContext).put("application", application);
  initializeApplication(application);
  Project project = mock(Project.class);
  when(project.isInitialized()).thenReturn(true);
  when(project.isDisposed()).thenReturn(false);
  getStore(extensionContext).put("project", project);
  initializeProject(project);
  LocalFileSystem lfs = mock(LocalFileSystem.class);
  getStore(extensionContext).put("local-filesystem", lfs);
  setupLocalFileSystem(lfs);
}

代码示例来源:origin: SonarSource/sonarlint-intellij

@Test
public void testUpdate() {
 sonarCancelAction.update(event);
 assertThat(presentation.isVisible()).isTrue();
 assertThat(presentation.isEnabled()).isFalse();
 SonarLintStatus status = SonarLintStatus.get(project);
 status.tryRun();
 sonarCancelAction.update(event);
 assertThat(presentation.isEnabled()).isTrue();
 when(project.isInitialized()).thenReturn(false);
 sonarCancelAction.update(event);
 assertThat(presentation.isEnabled()).isFalse();
}

代码示例来源:origin: SonarSource/sonarlint-intellij

@Override
public void update(AnActionEvent e) {
 super.update(e);
 Project project = e.getProject();
 if (project == null || !project.isInitialized() || project.isDisposed()) {
  e.getPresentation().setEnabled(false);
  e.getPresentation().setVisible(true);
  return;
 }
 VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
 if (!ActionPlaces.isPopupPlace(e.getPlace()) || files == null || files.length == 0) {
  e.getPresentation().setEnabled(false);
  e.getPresentation().setVisible(false);
  return;
 }
 e.getPresentation().setVisible(true);
 SonarLintProjectSettings settings = SonarLintUtils.get(project, SonarLintProjectSettings.class);
 List<String> exclusions = new ArrayList<>(settings.getFileExclusions());
 boolean anyFileToAdd = toStringStream(project, files)
  .anyMatch(path -> !exclusions.contains(path));
 if (!anyFileToAdd) {
  e.getPresentation().setEnabled(false);
 }
}

代码示例来源:origin: SonarSource/sonarlint-intellij

@Override
public void update(AnActionEvent e) {
 super.update(e);
 VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
 if (files == null || files.length == 0) {
  e.getPresentation().setEnabled(false);
  e.getPresentation().setVisible(false);
  return;
 }
 if (SonarLintToolWindowFactory.TOOL_WINDOW_ID.equals(e.getPlace())) {
  e.getPresentation().setIcon(SonarLintIcons.PLAY);
 }
 e.getPresentation().setVisible(true);
 Project project = e.getProject();
 if (project == null || !project.isInitialized() || project.isDisposed()) {
  e.getPresentation().setEnabled(false);
  return;
 }
 SonarLintStatus status = SonarLintUtils.get(project, SonarLintStatus.class);
 if (status.isRunning()) {
  e.getPresentation().setEnabled(false);
  return;
 }
 e.getPresentation().setEnabled(true);
}

代码示例来源:origin: SonarSource/sonarlint-intellij

@Override
public void update(AnActionEvent e) {
 Project p = e.getProject();
 if (isVisible(e.getPlace())) {
  e.getPresentation().setVisible(true);
 } else {
  e.getPresentation().setVisible(false);
  e.getPresentation().setEnabled(false);
  return;
 }
 if (p == null || !p.isInitialized() || p.isDisposed()) {
  e.getPresentation().setEnabled(false);
 } else {
  SonarLintStatus status = SonarLintStatus.get(p);
  e.getPresentation().setEnabled(isEnabled(e, p, status));
 }
}

相关文章