コード例 #1
0
 protected void doRun(
     @NotNull final ExecutionEnvironment environment, @NotNull final Runnable startRunnable) {
   Boolean allowSkipRun = environment.getUserData(EXECUTION_SKIP_RUN);
   if (allowSkipRun != null && allowSkipRun) {
     environment
         .getProject()
         .getMessageBus()
         .syncPublisher(EXECUTION_TOPIC)
         .processNotStarted(environment.getExecutor().getId(), environment);
   } else {
     // important! Do not use DumbService.smartInvokeLater here because it depends on modality
     // state
     // and execution of startRunnable could be skipped if modality state check fails
     //noinspection SSBasedInspection
     SwingUtilities.invokeLater(
         () -> {
           if (!myProject.isDisposed()) {
             if (!Registry.is("dumb.aware.run.configurations")) {
               DumbService.getInstance(myProject).runWhenSmart(startRunnable);
             } else {
               try {
                 DumbService.getInstance(myProject).setAlternativeResolveEnabled(true);
                 startRunnable.run();
               } catch (IndexNotReadyException ignored) {
                 ExecutionUtil.handleExecutionError(
                     environment,
                     new ExecutionException("cannot start while indexing is in progress."));
               } finally {
                 DumbService.getInstance(myProject).setAlternativeResolveEnabled(false);
               }
             }
           }
         });
   }
 }
コード例 #2
0
    @Override
    public void selectionChanged(@NotNull FileEditorManagerEvent event) {
      final FileEditor newFileEditor = event.getNewEditor();
      Editor mxmlEditor = null;
      if (newFileEditor instanceof TextEditor) {
        final Editor editor = ((TextEditor) newFileEditor).getEditor();
        if (DesignerApplicationManager.dumbAwareIsApplicable(
            project, PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()))) {
          mxmlEditor = editor;
        }
      }

      if (mxmlEditor == null) {
        processFileEditorChange(null);
        return;
      }

      final DumbService dumbService = DumbService.getInstance(project);
      if (dumbService.isDumb()) {
        openWhenSmart(dumbService);
      } else {
        if (!isApplicableEditor(mxmlEditor)) {
          mxmlEditor = null;
        }

        processFileEditorChange(mxmlEditor);
      }
    }
コード例 #3
0
  @Override
  public void invoke(
      @NotNull final Project project, @NotNull Editor editor, @NotNull PsiFile file) {
    PsiDocumentManager.getInstance(project).commitAllDocuments();

    DumbService.getInstance(project).setAlternativeResolveEnabled(true);
    try {
      int offset = editor.getCaretModel().getOffset();
      PsiElement[] elements =
          underModalProgress(
              project,
              "Resolving Reference...",
              () -> findAllTargetElements(project, editor, offset));
      FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.goto.declaration");

      if (elements.length != 1) {
        if (elements.length == 0
            && suggestCandidates(TargetElementUtil.findReference(editor, offset)).isEmpty()) {
          PsiElement element =
              findElementToShowUsagesOf(editor, editor.getCaretModel().getOffset());
          if (startFindUsages(editor, element)) {
            return;
          }

          // disable 'no declaration found' notification for keywords
          final PsiElement elementAtCaret = file.findElementAt(offset);
          if (elementAtCaret != null) {
            final NamesValidator namesValidator =
                LanguageNamesValidation.INSTANCE.forLanguage(elementAtCaret.getLanguage());
            if (namesValidator != null
                && namesValidator.isKeyword(elementAtCaret.getText(), project)) {
              return;
            }
          }
        }
        chooseAmbiguousTarget(editor, offset, elements, file);
        return;
      }

      PsiElement element = elements[0];
      if (element == findElementToShowUsagesOf(editor, editor.getCaretModel().getOffset())
          && startFindUsages(editor, element)) {
        return;
      }

      PsiElement navElement = element.getNavigationElement();
      navElement = TargetElementUtil.getInstance().getGotoDeclarationTarget(element, navElement);
      if (navElement != null) {
        gotoTargetElement(navElement, editor, file);
      }
    } catch (IndexNotReadyException e) {
      DumbService.getInstance(project)
          .showDumbModeNotification("Navigation is not available here during index update");
    } finally {
      DumbService.getInstance(project).setAlternativeResolveEnabled(false);
    }
  }
コード例 #4
0
  @Nullable
  public static TextCompletionProvider getProvider(@NotNull PsiFile file) {
    TextCompletionProvider provider = file.getUserData(COMPLETING_TEXT_FIELD_KEY);

    if (provider == null
        || (DumbService.isDumb(file.getProject()) && !DumbService.isDumbAware(provider))) {
      return null;
    }
    return provider;
  }
コード例 #5
0
 @NotNull
 private KotlinPsiElementFinderWrapper[] filteredFinders() {
   DumbService dumbService = DumbService.getInstance(getProject());
   KotlinPsiElementFinderWrapper[] finders = finders();
   if (dumbService.isDumb()) {
     List<KotlinPsiElementFinderWrapper> list =
         dumbService.filterByDumbAwareness(Arrays.asList(finders));
     finders = list.toArray(new KotlinPsiElementFinderWrapper[list.size()]);
   }
   return finders;
 }
コード例 #6
0
  void processInPlaceInjectorsFor(@NotNull PsiElement element, @NotNull InjProcessor processor) {
    MultiHostInjector[] infos = getInjectorMap().get(element.getClass());
    if (infos != null) {
      final boolean dumb = myDumbService.isDumb();
      for (MultiHostInjector injector : infos) {
        if (dumb && !DumbService.isDumbAware(injector)) {
          continue;
        }

        if (!processor.process(element, injector)) return;
      }
    }
  }
コード例 #7
0
  void duringCompletion(CompletionInitializationContext initContext) {
    if (isAutopopupCompletion()) {
      if (shouldFocusLookup(myParameters)) {
        myLookup.setFocused(true);
      } else if (FeatureUsageTracker.getInstance()
          .isToBeAdvertisedInLookup(
              CodeCompletionFeatures.EDITING_COMPLETION_CONTROL_ENTER, getProject())) {
        myLookup.addAdvertisement(
            "Press "
                + CompletionContributor.getActionShortcut(
                    IdeActions.ACTION_CHOOSE_LOOKUP_ITEM_ALWAYS)
                + " to choose the first suggestion");
      }
      if (!myEditor.isOneLineMode()
          && FeatureUsageTracker.getInstance()
              .isToBeAdvertisedInLookup(
                  CodeCompletionFeatures.EDITING_COMPLETION_CONTROL_ARROWS, getProject())) {
        myLookup.addAdvertisement(
            CompletionContributor.getActionShortcut(IdeActions.ACTION_LOOKUP_DOWN)
                + " and "
                + CompletionContributor.getActionShortcut(IdeActions.ACTION_LOOKUP_UP)
                + " will move caret down and up in the editor");
      }
    }

    ProgressManager.checkCanceled();

    if (!initContext
        .getOffsetMap()
        .wasModified(CompletionInitializationContext.IDENTIFIER_END_OFFSET)) {
      try {
        final int selectionEndOffset = initContext.getSelectionEndOffset();
        final PsiReference reference = initContext.getFile().findReferenceAt(selectionEndOffset);
        if (reference != null) {
          initContext.setReplacementOffset(findReplacementOffset(selectionEndOffset, reference));
        }
      } catch (IndexNotReadyException ignored) {
      }
    }

    for (CompletionContributor contributor :
        CompletionContributor.forLanguage(initContext.getPositionLanguage())) {
      ProgressManager.checkCanceled();
      if (DumbService.getInstance(initContext.getProject()).isDumb()
          && !DumbService.isDumbAware(contributor)) {
        continue;
      }

      contributor.duringCompletion(initContext);
    }
  }
コード例 #8
0
ファイル: MavenUtil.java プロジェクト: Zeratyl-SK/consulo
 public static void runDumbAware(final Project project, final Runnable r) {
   if (DumbService.isDumbAware(r)) {
     r.run();
   } else {
     DumbService.getInstance(project)
         .runWhenSmart(
             new Runnable() {
               public void run() {
                 if (project.isDisposed()) return;
                 r.run();
               }
             });
   }
 }
コード例 #9
0
  public synchronized void runPostStartupActivities() {
    final Application app = ApplicationManager.getApplication();
    app.assertIsDispatchThread();

    if (myPostStartupActivitiesPassed) return;

    runActivities(myDumbAwarePostStartupActivities);
    DumbService.getInstance(myProject)
        .runWhenSmart(
            new Runnable() {
              public void run() {
                synchronized (StartupManagerImpl.this) {
                  app.assertIsDispatchThread();
                  if (myProject.isDisposed()) return;
                  runActivities(
                      myDumbAwarePostStartupActivities); // they can register activities while in
                                                         // the dumb mode
                  runActivities(myNotDumbAwarePostStartupActivities);

                  myPostStartupActivitiesPassed = true;
                }
              }
            });

    if (!app.isUnitTestMode()) {
      VirtualFileManager.getInstance().refresh(!app.isHeadlessEnvironment());
    }
  }
  @Nullable
  @Override
  public PhpType getType(PsiElement e) {
    if (DumbService.getInstance(e.getProject()).isDumb()) {
      return null;
    }

    if (!ContainerGetHelper.isContainerGetCall(e)) {
      return null;
    }

    String serviceId = ContainerGetHelper.getServiceId((MethodReference) e);
    if (null == serviceId) {
      return null;
    }

    Symfony2ProjectComponent symfony2ProjectComponent =
        e.getProject().getComponent(Symfony2ProjectComponent.class);
    ServiceMap serviceMap = symfony2ProjectComponent.getServicesMap();
    if (null == serviceMap) {
      return null;
    }
    String serviceClass = serviceMap.getMap().get(serviceId);

    if (null == serviceClass) {
      return null;
    }

    return new PhpType().add(serviceClass);
  }
コード例 #11
0
  public static void addJarsToRootsAndImportClass(
      @NotNull List<String> jarPaths,
      final String libraryName,
      @NotNull final Module currentModule,
      @Nullable final Editor editor,
      @Nullable final PsiReference reference,
      @Nullable @NonNls final String className) {
    addJarsToRoots(
        jarPaths, libraryName, currentModule, reference != null ? reference.getElement() : null);

    final Project project = currentModule.getProject();
    if (editor != null && reference != null && className != null) {
      DumbService.getInstance(project)
          .withAlternativeResolveEnabled(
              new Runnable() {
                @Override
                public void run() {
                  GlobalSearchScope scope =
                      GlobalSearchScope.moduleWithLibrariesScope(currentModule);
                  PsiClass aClass = JavaPsiFacade.getInstance(project).findClass(className, scope);
                  if (aClass != null) {
                    new AddImportAction(project, reference, editor, aClass).execute();
                  }
                }
              });
    }
  }
コード例 #12
0
  public Pair<RenderResources, RenderResources> createResourceResolver(
      final AndroidFacet facet,
      FolderConfiguration config,
      ProjectResources projectResources,
      String themeName,
      boolean isProjectTheme) {
    final Map<ResourceType, Map<String, ResourceValue>> configedProjectRes =
        projectResources.getConfiguredResources(config);

    DumbService.getInstance(facet.getModule().getProject()).waitForSmartMode();

    final Collection<String> ids =
        ApplicationManager.getApplication()
            .runReadAction(
                new Computable<Collection<String>>() {
                  @Override
                  public Collection<String> compute() {
                    return facet.getLocalResourceManager().getIds();
                  }
                });
    final Map<String, ResourceValue> map = configedProjectRes.get(ResourceType.ID);
    for (String id : ids) {
      if (!map.containsKey(id)) {
        map.put(id, new ResourceValue(ResourceType.ID, id, false));
      }
    }

    final Map<ResourceType, Map<String, ResourceValue>> configedFrameworkRes =
        myResources.getConfiguredResources(config);
    final ResourceResolver resolver =
        ResourceResolver.create(
            configedProjectRes, configedFrameworkRes, themeName, isProjectTheme);
    return new Pair<RenderResources, RenderResources>(
        new ResourceResolverDecorator(resolver), resolver);
  }
コード例 #13
0
  private void removeSdk() {
    final Sdk currentSdk = getSelectedSdk();
    if (currentSdk != null) {
      final Sdk sdk = myProjectSdksModel.findSdk(currentSdk);
      final PySdkService sdkService = PySdkService.getInstance();
      sdkService.removeSdk(currentSdk);
      DumbService.allowStartingDumbModeInside(
          DumbModePermission.MAY_START_MODAL, () -> SdkConfigurationUtil.removeSdk(sdk));

      myProjectSdksModel.removeSdk(sdk);
      myProjectSdksModel.removeSdk(currentSdk);

      if (myModificators.containsKey(currentSdk)) {
        SdkModificator modificator = myModificators.get(currentSdk);
        myModifiedModificators.remove(modificator);
        myModificators.remove(currentSdk);
      }
      refreshSdkList();
      mySdkListChanged = true;
      // TODO select initially selected SDK
      if (mySdkList.getSelectedIndex() < 0) {
        mySdkList.setSelectedIndex(0);
      }
    }
  }
コード例 #14
0
 private void updateWarnings(@NotNull final MPSFileNodeEditor editor) {
   DumbService.getInstance(myProject)
       .smartInvokeLater(
           new Runnable() {
             @Override
             public void run() {
               final Runnable task =
                   new Runnable() {
                     @Override
                     public void run() {
                       doUpdateWarnings(editor);
                     }
                   };
               Boolean aBoolean =
                   ModelAccess.instance()
                       .tryRead(
                           new Computable<Boolean>() {
                             @Override
                             public Boolean compute() {
                               task.run();
                               return Boolean.TRUE;
                             }
                           });
               if (aBoolean == null) {
                 ModelAccess.instance().runReadInEDT(task);
               }
             }
           });
 }
コード例 #15
0
  @Override
  public void runCheckinHandlers(@NotNull final Runnable finishAction) {
    final VcsConfiguration configuration = VcsConfiguration.getInstance(myProject);
    final Collection<VirtualFile> files = myPanel.getVirtualFiles();

    final Runnable performCheckoutAction =
        new Runnable() {
          @Override
          public void run() {
            FileDocumentManager.getInstance().saveAllDocuments();
            finishAction.run();
          }
        };

    if (reformat(configuration, true) && !DumbService.isDumb(myProject)) {
      new ReformatCodeProcessor(
              myProject,
              CheckinHandlerUtil.getPsiFiles(myProject, files),
              FormatterUtil.REFORMAT_BEFORE_COMMIT_COMMAND_NAME,
              performCheckoutAction,
              true)
          .run();
    } else {
      performCheckoutAction.run();
    }
  }
  @Nullable
  @Override
  public String getType(PsiElement e) {
    if (DumbService.getInstance(e.getProject()).isDumb()
        || !Settings.getInstance(e.getProject()).pluginEnabled
        || !Settings.getInstance(e.getProject()).objectManagerFindTypeProvider) {
      return null;
    }

    if (!(e instanceof MethodReference)
        || !PhpElementsUtil.isMethodWithFirstStringOrFieldReference(e, "find")) {
      return null;
    }

    String refSignature = ((MethodReference) e).getSignature();
    if (StringUtil.isEmpty(refSignature)) {
      return null;
    }

    // we need the param key on getBySignature(), since we are already in the resolved method there
    // attach it to signature
    // param can have dotted values split with \
    PsiElement[] parameters = ((MethodReference) e).getParameters();
    if (parameters.length == 2) {
      return PhpTypeProviderUtil.getReferenceSignature((MethodReference) e, TRIM_KEY, 2);
    }

    return null;
  }
コード例 #17
0
  @Override
  protected void performRefactoring(@NotNull UsageInfo[] usages) {
    try {
      for (UsageInfo usage : usages) {
        if (usage instanceof SafeDeleteCustomUsageInfo) {
          ((SafeDeleteCustomUsageInfo) usage).performRefactoring();
        }
      }

      DumbService.allowStartingDumbModeInside(
          DumbModePermission.MAY_START_MODAL,
          () -> {
            for (PsiElement element : myElements) {
              for (SafeDeleteProcessorDelegate delegate :
                  Extensions.getExtensions(SafeDeleteProcessorDelegate.EP_NAME)) {
                if (delegate.handlesElement(element)) {
                  delegate.prepareForDeletion(element);
                }
              }

              element.delete();
            }
          });
    } catch (IncorrectOperationException e) {
      RefactoringUIUtil.processIncorrectOperation(myProject, e);
    }
  }
コード例 #18
0
  void updateFileName(@Nullable final VirtualFile updatedFile) {
    final EditorWindow[] windows = getWindows();
    for (int i = 0; i != windows.length; ++i) {
      for (VirtualFile file : windows[i].getFiles()) {
        if (updatedFile == null || file.getName().equals(updatedFile.getName())) {
          windows[i].updateFileName(file);
        }
      }
    }

    Project project = myManager.getProject();

    final IdeFrame frame = getFrame(project);
    if (frame != null) {
      VirtualFile file = getCurrentFile();

      File ioFile = file == null ? null : new File(file.getPresentableUrl());
      String fileTitle = null;
      if (file != null) {
        fileTitle =
            DumbService.isDumb(project)
                ? file.getName()
                : FrameTitleBuilder.getInstance().getFileTitle(project, file);
      }

      frame.setFileTitle(fileTitle, ioFile);
    }
  }
コード例 #19
0
 @Override
 public void run(@NotNull ProgressIndicator indicator) {
   try {
     mySocket = myServerSocket.accept();
     final ExecutionException[] ex = new ExecutionException[1];
     DumbService.getInstance(getProject())
         .repeatUntilPassesInSmartMode(
             new Runnable() {
               @Override
               public void run() {
                 try {
                   search();
                 } catch (ExecutionException e) {
                   ex[0] = e;
                 }
               }
             });
     if (ex[0] != null) {
       logCantRunException(ex[0]);
     }
   } catch (ProcessCanceledException e) {
     throw e;
   } catch (IOException e) {
     LOG.info(e);
   } catch (Throwable e) {
     LOG.error(e);
   }
 }
コード例 #20
0
  private boolean checkUnderReadAction(
      final MyValidatorProcessingItem item,
      final CompileContext context,
      final Computable<Map<ProblemDescriptor, HighlightDisplayLevel>> runnable) {
    return DumbService.getInstance(context.getProject())
        .runReadActionInSmartMode(
            new Computable<Boolean>() {
              @Override
              public Boolean compute() {
                final PsiFile file = item.getPsiFile();
                if (file == null) return false;

                final Document document = myPsiDocumentManager.getCachedDocument(file);
                if (document != null && myPsiDocumentManager.isUncommited(document)) {
                  final String url = file.getViewProvider().getVirtualFile().getUrl();
                  context.addMessage(
                      CompilerMessageCategory.WARNING,
                      CompilerBundle.message("warning.text.file.has.been.changed"),
                      url,
                      -1,
                      -1);
                  return false;
                }

                if (reportProblems(context, runnable.compute())) return false;
                return true;
              }
            });
  }
コード例 #21
0
  private CompletionInitializationContext runContributorsBeforeCompletion(
      Editor editor, PsiFile psiFile, int invocationCount, Caret caret) {
    final Ref<CompletionContributor> current = Ref.create(null);
    CompletionInitializationContext context =
        new CompletionInitializationContext(
            editor, caret, psiFile, myCompletionType, invocationCount) {
          CompletionContributor dummyIdentifierChanger;

          @Override
          public void setDummyIdentifier(@NotNull String dummyIdentifier) {
            super.setDummyIdentifier(dummyIdentifier);

            if (dummyIdentifierChanger != null) {
              LOG.error(
                  "Changing the dummy identifier twice, already changed by "
                      + dummyIdentifierChanger);
            }
            dummyIdentifierChanger = current.get();
          }
        };
    List<CompletionContributor> contributors =
        CompletionContributor.forLanguage(context.getPositionLanguage());
    Project project = psiFile.getProject();
    List<CompletionContributor> filteredContributors =
        DumbService.getInstance(project).filterByDumbAwareness(contributors);
    for (final CompletionContributor contributor : filteredContributors) {
      current.set(contributor);
      contributor.beforeCompletion(context);
      CompletionAssertions.checkEditorValid(editor);
      assert !PsiDocumentManager.getInstance(project).isUncommited(editor.getDocument())
          : "Contributor " + contributor + " left the document uncommitted";
    }
    return context;
  }
コード例 #22
0
  private Icon getIcon(DaemonCodeAnalyzerStatus status) {
    if (status == null) {
      return NO_ICON;
    }
    if (status.noHighlightingRoots != null
        && status.noHighlightingRoots.length == status.rootsNumber) {
      return NO_ANALYSIS_ICON;
    }

    Icon icon = HighlightDisplayLevel.DO_NOT_SHOW.getIcon();
    for (int i = status.errorCount.length - 1; i >= 0; i--) {
      if (status.errorCount[i] != 0) {
        icon = mySeverityRegistrar.getRendererIconByIndex(i);
        break;
      }
    }

    if (status.errorAnalyzingFinished) {
      if (myProject != null && DumbService.isDumb(myProject)) {
        return new LayeredIcon(NO_ANALYSIS_ICON, icon, STARING_EYE_ICON);
      }

      return icon;
    }
    if (!status.enabled) return NO_ANALYSIS_ICON;

    double progress = getOverallProgress(status);
    TruncatingIcon trunc =
        new TruncatingIcon(icon, icon.getIconWidth(), (int) (icon.getIconHeight() * progress));

    return new LayeredIcon(NO_ANALYSIS_ICON, trunc, STARING_EYE_ICON);
  }
コード例 #23
0
 @Nullable
 protected PsiType inferType(PsiTypeElement typeElement) {
   if (null == typeElement || DumbService.isDumb(typeElement.getProject())) {
     return null;
   }
   return valProcessor.inferType(typeElement);
 }
コード例 #24
0
  @Override
  @NotNull
  public VirtualFile[] choose(
      @Nullable final Project project, @NotNull final VirtualFile... toSelect) {
    init();
    if ((myProject == null) && (project != null)) {
      myProject = project;
    }
    if (toSelect.length == 1) {
      restoreSelection(toSelect[0]);
    } else if (toSelect.length == 0) {
      restoreSelection(null); // select last opened file
    } else {
      selectInTree(toSelect, true);
    }

    DumbService.allowStartingDumbModeInside(
        DumbModePermission.MAY_START_MODAL,
        new Runnable() {
          @Override
          public void run() {
            show();
          }
        });

    return myChosenFiles;
  }
 private static void doPersistProjectUsages(@NotNull Project project) {
   if (DumbService.isDumb(project)) return;
   for (UsagesCollector usagesCollector : Extensions.getExtensions(UsagesCollector.EP_NAME)) {
     if (usagesCollector instanceof AbstractApplicationUsagesCollector) {
       ((AbstractApplicationUsagesCollector) usagesCollector).persistProjectUsages(project);
     }
   }
 }
コード例 #26
0
  private static void showParameterHint(
      final PsiElement element,
      final Editor editor,
      final Object[] descriptors,
      final Project project,
      @Nullable PsiElement highlighted,
      final int elementStart,
      final ParameterInfoHandler handler,
      final boolean requestFocus) {
    if (ParameterInfoController.isAlreadyShown(editor, elementStart)) return;

    if (editor.isDisposed() || !editor.getComponent().isVisible()) return;
    final ParameterInfoComponent component =
        new ParameterInfoComponent(descriptors, editor, handler, requestFocus);
    component.setParameterOwner(element);
    component.setRequestFocus(requestFocus);
    if (highlighted != null) {
      component.setHighlightedParameter(highlighted);
    }

    component.update(); // to have correct preferred size

    final LightweightHint hint = new LightweightHint(component);
    hint.setSelectingHint(true);
    final HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl();
    final ShowParameterInfoHandler.BestLocationPointProvider provider =
        new MyBestLocationPointProvider(editor);
    final Pair<Point, Short> pos =
        provider.getBestPointPosition(hint, element, elementStart, true, HintManager.UNDER);

    PsiDocumentManager.getInstance(project)
        .performLaterWhenAllCommitted(
            () -> {
              if (editor.isDisposed() || DumbService.isDumb(project)) return;

              final Document document = editor.getDocument();
              if (document.getTextLength() < elementStart) return;

              HintHint hintHint =
                  HintManagerImpl.createHintHint(editor, pos.getFirst(), hint, pos.getSecond());
              hintHint.setExplicitClose(true);
              hintHint.setRequestFocus(requestFocus);

              Editor editorToShow =
                  editor instanceof EditorWindow ? ((EditorWindow) editor).getDelegate() : editor;
              // is case of injection we need to calculate position for EditorWindow
              // also we need to show the hint in the main editor because of intention bulb
              hintManager.showEditorHint(
                  hint,
                  editorToShow,
                  pos.getFirst(),
                  HintManager.HIDE_BY_ESCAPE | HintManager.UPDATE_BY_SCROLLING,
                  0,
                  false,
                  hintHint);
              new ParameterInfoController(project, editor, elementStart, hint, handler, provider);
            });
  }
コード例 #27
0
  @Nullable
  protected XmlElementDescriptor computeElementDescriptor() {
    for (XmlElementDescriptorProvider provider :
        Extensions.getExtensions(XmlElementDescriptorProvider.EP_NAME)) {
      XmlElementDescriptor elementDescriptor = provider.getDescriptor(this);
      if (elementDescriptor != null) {
        return elementDescriptor;
      }
    }

    final String namespace = getNamespace();
    if (XmlUtil.EMPTY_URI.equals(namespace)) { // nonqualified items
      final XmlTag parent = getParentTag();
      if (parent != null) {
        final XmlElementDescriptor descriptor = parent.getDescriptor();
        if (descriptor != null) {
          XmlElementDescriptor fromParent = descriptor.getElementDescriptor(this, parent);
          if (fromParent != null && !(fromParent instanceof AnyXmlElementDescriptor)) {
            return fromParent;
          }
        }
      }
    }

    XmlElementDescriptor elementDescriptor = null;
    final XmlNSDescriptor nsDescriptor = getNSDescriptor(namespace, false);

    LOG.debug(
        "Descriptor for namespace "
            + namespace
            + " is "
            + (nsDescriptor != null ? nsDescriptor.getClass().getCanonicalName() : "NULL"));

    if (nsDescriptor != null) {
      if (!DumbService.getInstance(getProject()).isDumb()
          || DumbService.isDumbAware(nsDescriptor)) {
        elementDescriptor = nsDescriptor.getElementDescriptor(this);
      }
    }
    if (elementDescriptor == null) {
      return XmlUtil.findXmlDescriptorByType(this);
    }

    return elementDescriptor;
  }
コード例 #28
0
 private void createConfiguration() {
   LOG.assertTrue(myConfiguration == null);
   final Location location = getLocation();
   myConfiguration =
       location != null && !DumbService.isDumb(location.getProject())
           ? PreferredProducerFind.createConfiguration(location, this)
           : null;
   myInitialized = true;
 }
コード例 #29
0
 public final void invokeCompletion(final Project project, final Editor editor) {
   try {
     invokeCompletion(project, editor, 1);
   } catch (IndexNotReadyException e) {
     DumbService.getInstance(project)
         .showDumbModeNotification(
             "Code completion is not available here while indices are being built");
   }
 }
コード例 #30
0
 @Override
 public synchronized void registerPostStartupActivity(@NotNull Runnable runnable) {
   LOG.assertTrue(
       !myPostStartupActivitiesPassed, "Registering post-startup activity that will never be run");
   (DumbService.isDumbAware(runnable)
           ? myDumbAwarePostStartupActivities
           : myNotDumbAwarePostStartupActivities)
       .add(runnable);
 }