Java Code Examples for com.intellij.openapi.extensions.Extensions

The following are top voted examples for showing how to use com.intellij.openapi.extensions.Extensions. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: idea-php-dotenv-plugin   File: DotEnvLightCodeInsightFixtureTestCase.java   Source Code and License 6 votes vote down vote up
private void assertNavigationMatch(ElementPattern<?> pattern) {

        PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());

        Set<String> targetStrings = new HashSet<String>();

        for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) {

            PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor());
            if(gotoDeclarationTargets == null || gotoDeclarationTargets.length == 0) {
                continue;
            }

            for (PsiElement gotoDeclarationTarget : gotoDeclarationTargets) {
                targetStrings.add(gotoDeclarationTarget.toString());
                if(pattern.accepts(gotoDeclarationTarget)) {
                    return;
                }
            }
        }

        fail(String.format("failed that PsiElement (%s) navigate matches one of %s", psiElement.toString(), targetStrings.toString()));
    }
 
Example 2
Project: Android-Resource-Usage-Count   File: FindUsageUtils.java   Source Code and License 6 votes vote down vote up
public static FindUsagesHandler getFindUsagesHandler(PsiElement element, Project project) {
    FindUsagesHandlerFactory[] arrs = (FindUsagesHandlerFactory[]) Extensions.getExtensions(FindUsagesHandlerFactory.EP_NAME, project);
    FindUsagesHandler handler = null;
    int length = arrs.length;
    for (int i = 0; i < length; i++) {
        FindUsagesHandlerFactory arr = arrs[i];
        if (arr.canFindUsages(element)) {
            handler = arr.createFindUsagesHandler(element, false);
            if(handler == FindUsagesHandler.NULL_HANDLER) {
                return null;
            }

            if(handler != null) {
                return handler;
            }
        }
    }
    return null;
}
 
Example 3
Project: intellij-ce-playground   File: ExternalLanguageAnnotators.java   Source Code and License 6 votes vote down vote up
@NotNull
public static List<ExternalAnnotator> allForFile(@NotNull Language language, @NotNull final PsiFile file) {
  List<ExternalAnnotator> annotators = INSTANCE.allForLanguage(language);
  final ExternalAnnotatorsFilter[] filters = Extensions.getExtensions(ExternalAnnotatorsFilter.EXTENSION_POINT_NAME);
  return ContainerUtil.findAll(annotators, new Condition<ExternalAnnotator>() {
    @Override
    public boolean value(ExternalAnnotator annotator) {
      for (ExternalAnnotatorsFilter filter : filters) {
        if (filter.isProhibited(annotator, file)) {
          return false;
        }
      }
      return true;
    }
  });
}
 
Example 4
Project: intellij-ce-playground   File: VcsChangeDetailsManager.java   Source Code and License 6 votes vote down vote up
public VcsChangeDetailsManager(final Project project) {
  myProject = project;
  myQueue = new BackgroundTaskQueue(myProject, "Loading change details");
  myDedicatedList = new ArrayList<VcsChangeDetailsProvider>();

  myDedicatedList.add(new BinaryDetailsProviderNew(project));
  myDedicatedList.add(new FragmentedDiffDetailsProvider(myProject));

  VcsChangeDetailsProvider[] extensions = Extensions.getExtensions(VcsChangeDetailsProvider.EP_NAME, myProject);
  myProviders.addAll(Arrays.asList(extensions));

  Disposer.register(project, new Disposable() {
    @Override
    public void dispose() {
      myQueue.clear();
    }
  });
}
 
Example 5
Project: DarkyenusTimeTracker   File: TimeTrackerWidget.java   Source Code and License 6 votes vote down vote up
@Override
public void install(@NotNull StatusBar statusBar) {
    Toolkit.getDefaultToolkit().addAWTEventListener(this,
            AWTEvent.KEY_EVENT_MASK |
                    AWTEvent.MOUSE_EVENT_MASK |
                    AWTEvent.MOUSE_MOTION_EVENT_MASK
    );
    saveDocumentListener = new FileDocumentManagerAdapter() {
        @Override
        public void beforeAllDocumentsSaving() {
            foldRunningTime();
        }

        @Override
        public void beforeDocumentSaving(@NotNull Document document) {
            foldRunningTime();
        }
    };
    Extensions.getArea(null).getExtensionPoint(FileDocumentManagerListener.EP_NAME).registerExtension(saveDocumentListener);

    synchronized (ALL_OPENED_TRACKERS_LOCK) {
        ALL_OPENED_TRACKERS.add(this);
    }
}
 
Example 6
Project: intellij-ce-playground   File: ExtensibleQueryFactory.java   Source Code and License 6 votes vote down vote up
protected ExtensibleQueryFactory(@NonNls final String epNamespace) {
  myPoint = new NotNullLazyValue<SimpleSmartExtensionPoint<QueryExecutor<Result, Parameters>>>() {
    @Override
    @NotNull
    protected SimpleSmartExtensionPoint<QueryExecutor<Result, Parameters>> compute() {
      return new SimpleSmartExtensionPoint<QueryExecutor<Result, Parameters>>(new SmartList<QueryExecutor<Result, Parameters>>()){
        @Override
        @NotNull
        protected ExtensionPoint<QueryExecutor<Result, Parameters>> getExtensionPoint() {
          @NonNls String epName = ExtensibleQueryFactory.this.getClass().getName();
          int pos = epName.lastIndexOf('.');
          if (pos >= 0) {
            epName = epName.substring(pos+1);
          }
          epName = epNamespace + "." + StringUtil.decapitalize(epName);
          return Extensions.getRootArea().getExtensionPoint(epName);
        }
      };
    }
  };
}
 
Example 7
Project: intellij-ce-playground   File: InlineRefactoringActionHandler.java   Source Code and License 6 votes vote down vote up
@Override
public void invoke(@NotNull final Project project, Editor editor, PsiFile file, DataContext dataContext) {
  editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);

  PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
  if (element == null) {
    element = BaseRefactoringAction.getElementAtCaret(editor, file);
  }
  if (element != null) {
    for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) {
      if (handler.canInlineElementInEditor(element, editor)) {
        handler.inlineElement(project, editor, element);
        return;
      }
    }

    if (invokeInliner(editor, element)) return;

    String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.method.or.local.name"));
    CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, null);
  }
}
 
Example 8
Project: intellij-ce-playground   File: ClsFieldImpl.java   Source Code and License 6 votes vote down vote up
@Override
@NotNull
public PsiElement getNavigationElement() {
  if (DumbService.isDumb(getProject())) return this;
  
  for (ClsCustomNavigationPolicy customNavigationPolicy : Extensions.getExtensions(ClsCustomNavigationPolicy.EP_NAME)) {
    PsiElement navigationElement = customNavigationPolicy.getNavigationElement(this);
    if (navigationElement != null) {
      return navigationElement;
    }
  }

  PsiClass sourceClassMirror = ((ClsClassImpl)getParent()).getSourceMirrorClass();
  PsiElement sourceFieldMirror = sourceClassMirror != null ? sourceClassMirror.findFieldByName(getName(), false) : null;
  return sourceFieldMirror != null ? sourceFieldMirror.getNavigationElement() : this;
}
 
Example 9
Project: intellij-ce-playground   File: JavaTestFrameworkRunnableState.java   Source Code and License 6 votes vote down vote up
protected void collectListeners(JavaParameters javaParameters, StringBuilder buf, String epName, String delimiter) {
  final T configuration = getConfiguration();
  final Object[] listeners = Extensions.getExtensions(epName);
  for (final Object listener : listeners) {
    boolean enabled = true;
    for (RunConfigurationExtension ext : Extensions.getExtensions(RunConfigurationExtension.EP_NAME)) {
      if (ext.isListenerDisabled(configuration, listener, getRunnerSettings())) {
        enabled = false;
        break;
      }
    }
    if (enabled) {
      if (buf.length() > 0) buf.append(delimiter);
      final Class classListener = listener.getClass();
      buf.append(classListener.getName());
      javaParameters.getClassPath().add(PathUtil.getJarPathForClass(classListener));
    }
  }
}
 
Example 10
Project: intellij-ce-playground   File: PyFunctionImpl.java   Source Code and License 6 votes vote down vote up
@Nullable
private PyType getReturnType(@NotNull TypeEvalContext context) {
  for (PyTypeProvider typeProvider : Extensions.getExtensions(PyTypeProvider.EP_NAME)) {
    final Ref<PyType> returnTypeRef = typeProvider.getReturnType(this, context);
    if (returnTypeRef != null) {
      final PyType returnType = returnTypeRef.get();
      if (returnType != null) {
        returnType.assertValid(typeProvider.toString());
      }
      return returnType;
    }
  }
  final PyType docStringType = getReturnTypeFromDocString();
  if (docStringType != null) {
    docStringType.assertValid("from docstring");
    return docStringType;
  }
  if (context.allowReturnTypes(this)) {
    final Ref<? extends PyType> yieldTypeRef = getYieldStatementType(context);
    if (yieldTypeRef != null) {
      return yieldTypeRef.get();
    }
    return getReturnStatementType(context);
  }
  return null;
}
 
Example 11
Project: intellij-ce-playground   File: TemplateState.java   Source Code and License 6 votes vote down vote up
private void shortenReferences() {
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      final PsiFile file = getPsiFile();
      if (file != null) {
        IntArrayList indices = initEmptyVariables();
        mySegments.setSegmentsGreedy(false);
        for (TemplateOptionalProcessor processor : Extensions.getExtensions(TemplateOptionalProcessor.EP_NAME)) {
          processor.processText(myProject, myTemplate, myDocument, myTemplateRange, myEditor);
        }
        mySegments.setSegmentsGreedy(true);
        restoreEmptyVariables(indices);
      }
    }
  });
}
 
Example 12
Project: intellij-ce-playground   File: MigrationProcessor.java   Source Code and License 6 votes vote down vote up
protected void performRefactoring(@NotNull UsageInfo[] usages) {
  final PsiMigration psiMigration = PsiMigrationManager.getInstance(myProject).startMigration();
  LocalHistoryAction a = LocalHistory.getInstance().startAction(getCommandName());

  try {
    for (int i = 0; i < myMigrationMap.getEntryCount(); i++) {
      MigrationMapEntry entry = myMigrationMap.getEntryAt(i);
      if (entry.getType() == MigrationMapEntry.PACKAGE) {
        MigrationUtil.doPackageMigration(myProject, psiMigration, entry.getNewName(), usages);
      }
      if (entry.getType() == MigrationMapEntry.CLASS) {
        MigrationUtil.doClassMigration(myProject, psiMigration, entry.getNewName(), usages);
      }
    }

    for(RefactoringHelper helper: Extensions.getExtensions(RefactoringHelper.EP_NAME)) {
      Object preparedData = helper.prepareOperation(usages);
      //noinspection unchecked
      helper.performOperation(myProject, preparedData);
    }
  }
  finally {
    a.finish();
    psiMigration.finish();
  }
}
 
Example 13
Project: intellij-ce-playground   File: SaveProjectAsTemplateAction.java   Source Code and License 6 votes vote down vote up
public static Map<String, String> computeParameters(final Project project, boolean replaceParameters) {
  final Map<String, String> parameters = new HashMap<String, String>();
  if (replaceParameters) {
    ApplicationManager.getApplication().runReadAction(new Runnable() {
      public void run() {
        ProjectTemplateParameterFactory[] extensions = Extensions.getExtensions(ProjectTemplateParameterFactory.EP_NAME);
        for (ProjectTemplateParameterFactory extension : extensions) {
          String value = extension.detectParameterValue(project);
          if (value != null) {
            parameters.put(value, extension.getParameterId());
          }
        }
      }
    });
  }
  return parameters;
}
 
Example 14
Project: intellij-ce-playground   File: PyTargetExpressionImpl.java   Source Code and License 6 votes vote down vote up
@Nullable
private static PyType getWithItemVariableType(TypeEvalContext context, PyWithItem item) {
  final PyExpression expression = item.getExpression();
  if (expression != null) {
    final PyType exprType = context.getType(expression);
    if (exprType instanceof PyClassType) {
      final PyClass cls = ((PyClassType)exprType).getPyClass();
      final PyFunction enter = cls.findMethodByName(PyNames.ENTER, true);
      if (enter != null) {
        final PyType enterType = enter.getCallType(expression, Collections.<PyExpression, PyNamedParameter>emptyMap(), context);
        if (enterType != null) {
          return enterType;
        }
        for (PyTypeProvider provider: Extensions.getExtensions(PyTypeProvider.EP_NAME)) {
          PyType typeFromProvider = provider.getContextManagerVariableType(cls, expression, context);
          if (typeFromProvider != null) {
            return typeFromProvider;
          }
        }
        // Guess the return type of __enter__
        return PyUnionType.createWeakType(exprType);
      }
    }
  }
  return null;
}
 
Example 15
Project: intellij-ce-playground   File: FindUsagesManager.java   Source Code and License 6 votes vote down vote up
@Nullable
public FindUsagesHandler getNewFindUsagesHandler(@NotNull PsiElement element, final boolean forHighlightUsages) {
  for (FindUsagesHandlerFactory factory : Extensions.getExtensions(FindUsagesHandlerFactory.EP_NAME, myProject)) {
    if (factory.canFindUsages(element)) {
      Class<? extends FindUsagesHandlerFactory> aClass = factory.getClass();
      FindUsagesHandlerFactory copy = (FindUsagesHandlerFactory)new ConstructorInjectionComponentAdapter(aClass.getName(), aClass)
        .getComponentInstance(myProject.getPicoContainer());
      final FindUsagesHandler handler = copy.createFindUsagesHandler(element, forHighlightUsages);
      if (handler == FindUsagesHandler.NULL_HANDLER) return null;
      if (handler != null) {
        return handler;
      }
    }
  }
  return null;
}
 
Example 16
Project: intellij-ce-playground   File: PyCharmEduInitialConfigurator.java   Source Code and License 6 votes vote down vote up
private static void patchProjectAreaExtensions(@NotNull final Project project) {
  Executor debugExecutor = DefaultDebugExecutor.getDebugExecutorInstance();
  unregisterAction(debugExecutor.getId(), ExecutorRegistryImpl.RUNNERS_GROUP);
  unregisterAction(debugExecutor.getContextActionId(), ExecutorRegistryImpl.RUN_CONTEXT_GROUP);

  ExtensionsArea projectArea = Extensions.getArea(project);

  for (SelectInTarget target : Extensions.getExtensions(SelectInTarget.EP_NAME, project)) {
    if (ToolWindowId.FAVORITES_VIEW.equals(target.getToolWindowId()) ||
        ToolWindowId.STRUCTURE_VIEW.equals(target.getToolWindowId())) {
      projectArea.getExtensionPoint(SelectInTarget.EP_NAME).unregisterExtension(target);
    }
  }

  for (AbstractProjectViewPane pane : Extensions.getExtensions(AbstractProjectViewPane.EP_NAME, project)) {
    if (pane.getId().equals(ScopeViewPane.ID)) {
      Disposer.dispose(pane);
      projectArea.getExtensionPoint(AbstractProjectViewPane.EP_NAME).unregisterExtension(pane);
    }
  }
}
 
Example 17
Project: intellij-ce-playground   File: PyUserSkeletonsUtil.java   Source Code and License 6 votes vote down vote up
@Nullable
private static PyFile getUserSkeletonForFile(@NotNull PyFile file) {
  final Boolean hasSkeleton = file.getUserData(HAS_SKELETON);
  if (hasSkeleton != null && !hasSkeleton) {
    return null;
  }
  final VirtualFile moduleVirtualFile = file.getVirtualFile();
  if (moduleVirtualFile != null) {
    String moduleName = QualifiedNameFinder.findShortestImportableName(file, moduleVirtualFile);
    if (moduleName != null) {
      final QualifiedName qName = QualifiedName.fromDottedString(moduleName);
      for (PyCanonicalPathProvider provider : Extensions.getExtensions(PyCanonicalPathProvider.EP_NAME)) {
        final QualifiedName restored = provider.getCanonicalPath(qName, null);
        if (restored != null) {
          moduleName = restored.toString();
        }
      }
      final PyFile skeletonFile = getUserSkeletonForModuleQName(moduleName, file);
      file.putUserData(HAS_SKELETON, skeletonFile != null);
      return skeletonFile;
    }
  }
  return null;
}
 
Example 18
Project: intellij-ce-playground   File: VcsSelectionUtil.java   Source Code and License 6 votes vote down vote up
@Nullable
public static VcsSelection getSelection(VcsContext context) {

  VcsSelection selectionFromEditor = getSelectionFromEditor(context);
  if (selectionFromEditor != null) {
    return selectionFromEditor;
  }
  for(VcsSelectionProvider provider: Extensions.getExtensions(VcsSelectionProvider.EP_NAME)) {
    try {
      final VcsSelection vcsSelection = provider.getSelection(context);
      if (vcsSelection != null) return vcsSelection;
    }
    catch (IndexNotReadyException ignored) {
    }
  }
  return null;
}
 
Example 19
Project: idea-php-dotenv-plugin   File: DotEnvLightCodeInsightFixtureTestCase.java   Source Code and License 5 votes vote down vote up
public void assertNavigationContains(PsiElement psiElement, String targetShortcut) {

        if(!targetShortcut.startsWith("\\")) {
            targetShortcut = "\\" + targetShortcut;
        }

        Set<String> classTargets = new HashSet<String>();

        for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) {
            PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor());
            if(gotoDeclarationTargets != null && gotoDeclarationTargets.length > 0) {

                for (PsiElement gotoDeclarationTarget : gotoDeclarationTargets) {
                    if(gotoDeclarationTarget instanceof Method) {

                        String meName = ((Method) gotoDeclarationTarget).getName();

                        String clName = ((Method) gotoDeclarationTarget).getContainingClass().getPresentableFQN();
                        if(!clName.startsWith("\\")) {
                            clName = "\\" + clName;
                        }

                        classTargets.add(clName + "::" + meName);
                    } else if(gotoDeclarationTarget instanceof Function) {
                        classTargets.add("\\" + ((Function) gotoDeclarationTarget).getName());
                    }
                }

            }
        }

        if(!classTargets.contains(targetShortcut)) {
            fail(String.format("failed that PsiElement (%s) navigate to %s on %s", psiElement.toString(), targetShortcut, classTargets.toString()));
        }

    }
 
Example 20
Project: idea-php-dotenv-plugin   File: DotEnvLightCodeInsightFixtureTestCase.java   Source Code and License 5 votes vote down vote up
private void assertNavigationIsEmpty() {
    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
    for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) {
        PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor());
        if(gotoDeclarationTargets != null && gotoDeclarationTargets.length > 0) {
            fail(String.format("failed that PsiElement (%s) navigate is empty; found target in '%s'", psiElement.toString(), gotoDeclarationHandler.getClass()));
        }
    }
}
 
Example 21
Project: idea-php-dotenv-plugin   File: DotEnvLightCodeInsightFixtureTestCase.java   Source Code and License 5 votes vote down vote up
public void assertNavigationContainsFile(LanguageFileType languageFileType, String configureByText, String targetShortcut) {
    myFixture.configureByText(languageFileType, configureByText);
    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());

    Set<String> targets = new HashSet<String>();

    for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) {
        PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor());
        if (gotoDeclarationTargets != null && gotoDeclarationTargets.length > 0) {
            for (PsiElement gotoDeclarationTarget : gotoDeclarationTargets) {
                if(gotoDeclarationTarget instanceof PsiFile) {
                    targets.add(((PsiFile) gotoDeclarationTarget).getVirtualFile().getUrl());
                }
            }
        }
    }

    // its possible to have memory fields,
    // so simple check for ending conditions
    // temp:///src/interchange.en.xlf
    for (String target : targets) {
        if(target.endsWith(targetShortcut)) {
            return;
        }
    }

    fail(String.format("failed that PsiElement (%s) navigate to file %s", psiElement.toString(), targetShortcut));
}
 
Example 22
Project: hybris-integration-intellij-idea-plugin   File: DefaultHybrisProjectImportBuilder.java   Source Code and License 5 votes vote down vote up
public ConfiguratorFactory getConfiguratorFactory() {
    if (!Extensions.getRootArea().hasExtensionPoint(HybrisConstants.CONFIGURATOR_FACTORY_ID)) {
        return ServiceManager.getService(DefaultConfiguratorFactory.class);
    }

    final ExtensionPoint ep = Extensions.getRootArea().getExtensionPoint(HybrisConstants.CONFIGURATOR_FACTORY_ID);
    final ConfiguratorFactory ultimateConfiguratorFactory = (ConfiguratorFactory) ep.getExtension();

    if (ultimateConfiguratorFactory != null) {
        return ultimateConfiguratorFactory;
    }

    return ServiceManager.getService(DefaultConfiguratorFactory.class);
}
 
Example 23
Project: hybris-integration-intellij-idea-plugin   File: HybrisWritingAccessProvider.java   Source Code and License 5 votes vote down vote up
@NotNull
public static HybrisWritingAccessProvider getInstance(@NotNull final Project project) {
    return Arrays.stream(Extensions.getExtensions(EP_NAME, project))
                 .map(o -> ObjectUtils.tryCast(o, HybrisWritingAccessProvider.class))
                 .filter(Objects::nonNull)
                 .findAny()
                 .orElseThrow(IllegalStateException::new);
}
 
Example 24
Project: hybris-integration-intellij-idea-plugin   File: ProjectRefreshAction.java   Source Code and License 5 votes vote down vote up
private HybrisProjectImportProvider getHybrisProjectImportProvider() {
    for (ProjectImportProvider provider : Extensions.getExtensions(ProjectImportProvider.PROJECT_IMPORT_PROVIDER)) {
        if (provider instanceof HybrisProjectImportProvider) {
            return (HybrisProjectImportProvider) provider;
        }
    }
    return null;
}
 
Example 25
Project: educational-plugin   File: StudyProjectGenerator.java   Source Code and License 5 votes vote down vote up
@Nullable
public List<Course> getBundledCourses() {
  final ArrayList<Course> courses = new ArrayList<>();
  final LanguageExtensionPoint<EduPluginConfigurator>[] extensions = Extensions.getExtensions(EduPluginConfigurator.EP_NAME, null);
  for (LanguageExtensionPoint<EduPluginConfigurator> extension : extensions) {
    final EduPluginConfigurator configurator = extension.getInstance();
    final List<String> paths = configurator.getBundledCoursePaths();
    for (String path : paths) {
      courses.add(getCourse(path));
    }
  }
  return courses;
}
 
Example 26
Project: educational-plugin   File: StudyTwitterAction.java   Source Code and License 5 votes vote down vote up
@Override
public void afterCheck(@NotNull Project project, @NotNull Task task) {
  for (StudyTwitterPluginConfigurator twitterPluginConfigurator : Extensions.getExtensions(StudyTwitterPluginConfigurator.EP_NAME)) {
    if (twitterPluginConfigurator.askToTweet(project, task, myStatusBeforeCheck)) {
      StudyTwitterUtils.createTwitterDialogAndShow(project, twitterPluginConfigurator, task);
    }
  }
}
 
Example 27
Project: educational-plugin   File: EduStepicConnector.java   Source Code and License 5 votes vote down vote up
static boolean canBeOpened(RemoteCourse courseInfo) {
  final ArrayList<String> supportedLanguages = new ArrayList<>();
  final LanguageExtensionPoint[] extensions = Extensions.getExtensions(EduPluginConfigurator.EP_NAME, null);
  for (LanguageExtensionPoint extension : extensions) {
    String languageId = extension.getKey();
    supportedLanguages.add(languageId);
  }

  if (courseInfo.isAdaptive()) {
    return supportedLanguages.contains(courseInfo.getLanguageID());
  }

  String courseType = courseInfo.getType();
  final List<String> typeLanguage = StringUtil.split(courseType, " ");
  String prefix = typeLanguage.get(0);
  if (!supportedLanguages.contains(courseInfo.getLanguageID())) return false;
  if (typeLanguage.size() < 2 || !prefix.startsWith(PYCHARM_PREFIX)) {
    return false;
  }
  String versionString = prefix.substring(PYCHARM_PREFIX.length());
  if (versionString.isEmpty()) {
    return true;
  }
  try {
    Integer version = Integer.valueOf(versionString);
    return version <= CURRENT_VERSION;
  }
  catch (NumberFormatException e) {
    LOG.info("Wrong version format", e);
    return false;
  }
}
 
Example 28
Project: educational-plugin   File: StudyCheckAction.java   Source Code and License 5 votes vote down vote up
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  EduUsagesCollector.taskChecked();
  Project project = e.getProject();
  if (project == null) {
    return;
  }
  if (DumbService.isDumb(project)) {
    StudyCheckUtils
      .showTestResultPopUp("Checking is not available while indexing is in progress", MessageType.WARNING.getPopupBackground(), project);
    return;
  }
  StudyCheckUtils.hideTestResultsToolWindow(project);
  FileDocumentManager.getInstance().saveAllDocuments();
  Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
  if (editor == null) {
    return;
  }
  VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(editor.getDocument());
  if (virtualFile == null) {
    return;
  }
  Task task = StudyUtils.getTaskForFile(project, virtualFile);
  if (task == null) {
    return;
  }
  for (StudyCheckListener listener : Extensions.getExtensions(StudyCheckListener.EP_NAME)) {
    listener.beforeCheck(project, task);
  }
  ProgressManager.getInstance().run(new StudyCheckTask(project, task));
}
 
Example 29
Project: educational-plugin   File: EduCCModuleBuilder.java   Source Code and License 5 votes vote down vote up
@Nullable
@Override
public ModuleWizardStep modifySettingsStep(@NotNull SettingsStep settingsStep) {
  ModuleWizardStep javaSettingsStep =
    ProjectWizardStepFactory.getInstance().createJavaSettingsStep(settingsStep, this, Conditions.alwaysTrue());
  Function<JTextField, String> getValue = JTextComponent::getText;
  getWizardInputField("ccname", "", "Name:", myPanel.getNameField(), getValue).addToSettings(settingsStep);
  getWizardInputField("ccauthor", "", "Author:", myPanel.getAuthorField(), getValue).addToSettings(settingsStep);

  myLanguageComboBox.removeAllItems();
  for (LanguageExtensionPoint extension : Extensions.<LanguageExtensionPoint>getExtensions(EduPluginConfigurator.EP_NAME, null)) {
    String languageId = extension.getKey();
    Language language = Language.findLanguageByID(languageId);
    if (language == null) {
      LOG.info("Language with id " + languageId + " not found");
      continue;
    }
    myLanguageComboBox.addItem(new LanguageWrapper(language));
  }
  getWizardInputField("cclang", "", "Language:", myLanguageComboBox, comboBox -> (String) comboBox.getSelectedItem())
    .addToSettings(settingsStep);
  JTextArea descriptionField = myPanel.getDescriptionField();
  descriptionField.setRows(4);
  descriptionField.setBorder(null);
  descriptionField.invalidate();
  JBScrollPane scrollPane = new JBScrollPane(descriptionField);
  scrollPane.setMinimumSize(scrollPane.getUI().getPreferredSize(descriptionField));
  getWizardInputField("ccdescr", "", "Description:", scrollPane, pane -> descriptionField.getText()).addToSettings(settingsStep);
  return javaSettingsStep;
}
 
Example 30
Project: intellij-ce-playground   File: JavaCoverageEngine.java   Source Code and License 5 votes vote down vote up
@Override
public boolean isApplicableTo(@Nullable final RunConfigurationBase conf) {
  if (conf instanceof CommonJavaRunConfigurationParameters) {
    return true;
  }
  for (JavaCoverageEngineExtension extension : Extensions.getExtensions(JavaCoverageEngineExtension.EP_NAME)) {
    if (extension.isApplicableTo(conf)) {
      return true;
    }
  }
  return false;
}
 
Example 31
Project: DarkyenusTimeTracker   File: TimeTrackerWidget.java   Source Code and License 5 votes vote down vote up
@Override
public void dispose() {
    setupAutoStartDocumentListener(false);
    Extensions.getArea(null).getExtensionPoint(FileDocumentManagerListener.EP_NAME).unregisterExtension(saveDocumentListener);
    Toolkit.getDefaultToolkit().removeAWTEventListener(this);
    setRunning(false);

    synchronized (ALL_OPENED_TRACKERS_LOCK) {
        ALL_OPENED_TRACKERS.remove(this);
    }
}
 
Example 32
Project: intellij-ce-playground   File: CoreProjectEnvironment.java   Source Code and License 5 votes vote down vote up
public <T> void addProjectExtension(@NotNull ExtensionPointName<T> name, @NotNull final T extension) {
  final ExtensionPoint<T> extensionPoint = Extensions.getArea(myProject).getExtensionPoint(name);
  extensionPoint.registerExtension(extension);
  Disposer.register(myParentDisposable, new Disposable() {
    @Override
    public void dispose() {
      extensionPoint.unregisterExtension(extension);
    }
  });
}
 
Example 33
Project: intellij-ce-playground   File: PyContentEntriesEditor.java   Source Code and License 5 votes vote down vote up
public PyContentEntriesEditor(Module module, ModuleConfigurationState moduleConfigurationState,
                                    JpsModuleSourceRootType<?>... rootTypes) {
  super(module.getName(), moduleConfigurationState, rootTypes);
  myRootTypeProviders = Extensions.getExtensions(PyRootTypeProvider.EP_NAME);
  myModule = module;
  myWarningPanel = new FacetErrorPanel();
  reset();
}
 
Example 34
Project: intellij   File: TestUtils.java   Source Code and License 5 votes vote down vote up
@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);
}
 
Example 35
Project: intellij-ce-playground   File: TargetElementUtil.java   Source Code and License 5 votes vote down vote up
@Override
public int getReferenceSearchFlags() {
  int result = getAllAccepted();
  for (TargetElementUtilExtender each : Extensions.getExtensions(TargetElementUtilExtender.EP_NAME)) {
    result |= each.getAdditionalReferenceSearchFlags();
  }
  return result;
}
 
Example 36
Project: intellij-ce-playground   File: EditorTabbedContainer.java   Source Code and License 5 votes vote down vote up
@Nullable
public static Color calcTabColor(@NotNull Project project, @NotNull VirtualFile file) {
  for (EditorTabColorProvider provider : Extensions.getExtensions(EditorTabColorProvider.EP_NAME)) {
    final Color result = provider.getEditorTabColor(project, file);
    if (result != null) {
      return result;
    }
  }

  return null;
}
 
Example 37
Project: intellij-ce-playground   File: XmlSuppressionProvider.java   Source Code and License 5 votes vote down vote up
public static boolean isSuppressed(@NotNull PsiElement element, @NotNull String inspectionId) {
  for (XmlSuppressionProvider provider : Extensions.getExtensions(EP_NAME)) {
    if (provider.isProviderAvailable(element.getContainingFile()) && provider.isSuppressedFor(element, inspectionId)) {
      return true;
    }
  }
  return false;
}
 
Example 38
Project: intellij-ce-playground   File: SuppressionUtil.java   Source Code and License 5 votes vote down vote up
public static boolean isSuppressed(@NotNull PsiElement psiElement, @NotNull String id) {
  for (InspectionExtensionsFactory factory : Extensions.getExtensions(InspectionExtensionsFactory.EP_NAME)) {
    if (!factory.isToCheckMember(psiElement, id)) {
      return true;
    }
  }
  return false;
}
 
Example 39
Project: intellij-ce-playground   File: PyUnresolvedReferencesInspection.java   Source Code and License 5 votes vote down vote up
private static boolean hasUnresolvedDynamicMember(@NotNull final PyClassType type,
                                                  PsiReference reference,
                                                  @NotNull final String name) {
  for (PyClassMembersProvider provider : Extensions.getExtensions(PyClassMembersProvider.EP_NAME)) {
    final Collection<PyCustomMember> resolveResult = provider.getMembers(type, reference.getElement());
    for (PyCustomMember member : resolveResult) {
      if (member.getName().equals(name)) return true;
    }
  }
  return false;
}
 
Example 40
Project: intellij-ce-playground   File: ExtensionsAreaTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testGetComponentAdapterDoesntDuplicateAdapters() throws Exception {
  MutablePicoContainer picoContainer =
    new ExtensionsAreaImpl("foo", null, new DefaultPicoContainer(), new Extensions.SimpleLogProvider()).getPicoContainer();
  picoContainer.registerComponentImplementation("runnable", ExtensionsAreaTest.class);

  List adapters = picoContainer.getComponentAdaptersOfType(ExtensionsAreaTest.class);
  assertEquals(1, adapters.size());
}
 
Example 41
Project: intellij-ce-playground   File: CodeStyleManagerImpl.java   Source Code and License 5 votes vote down vote up
private PsiElement postProcessElement(@NotNull final PsiElement formatted) {
  PsiElement result = formatted;
  if (getSettings().FORMATTER_TAGS_ENABLED && formatted instanceof PsiFile) {
    postProcessEnabledRanges((PsiFile) formatted, formatted.getTextRange(), getSettings());
  }
  else {
    for (PostFormatProcessor postFormatProcessor : Extensions.getExtensions(PostFormatProcessor.EP_NAME)) {
      result = postFormatProcessor.processElement(result, getSettings());
    }
  }
  return result;
}
 
Example 42
Project: intellij-ce-playground   File: GetFromVcsAction.java   Source Code and License 5 votes vote down vote up
@Override
public void update(AnActionEvent e) {
  e.getPresentation().setEnabled(Extensions.getExtensions(CheckoutProvider.EXTENSION_POINT_NAME).length > 0);
  if (NewWelcomeScreen.isNewWelcomeScreen(e)) {
    e.getPresentation().setIcon(AllIcons.Welcome.FromVCS);
  }
}
 
Example 43
Project: intellij-ce-playground   File: StubIndexImpl.java   Source Code and License 5 votes vote down vote up
@Override
public void initComponent() {
  try {
    final boolean forceClean = Boolean.TRUE == ourForcedClean.getAndSet(Boolean.FALSE);

    StubIndexExtension<?, ?>[] extensions = Extensions.getExtensions(StubIndexExtension.EP_NAME);
    StringBuilder updated = new StringBuilder();
    for (StubIndexExtension extension : extensions) {
      @SuppressWarnings("unchecked") boolean rebuildRequested = registerIndexer(extension, forceClean);
      if (rebuildRequested) {
        updated.append(extension).append(' ');
      }
    }
    if (updated.length() > 0) {
      final Throwable e = new Throwable(updated.toString());
      // avoid direct forceRebuild as it produces dependency cycle (IDEA-105485)
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          forceRebuild(e);
        }
      }, ModalityState.NON_MODAL);
    }
    dropUnregisteredIndices();
  } catch (IOException ex) {
    throw new RuntimeException(ex);
  }
}
 
Example 44
Project: intellij-ce-playground   File: PyReferenceExpressionImpl.java   Source Code and License 5 votes vote down vote up
@Nullable
public static PyType getReferenceTypeFromProviders(@NotNull final PsiElement target,
                                                   TypeEvalContext context,
                                                   @Nullable PsiElement anchor) {
  for (PyTypeProvider provider : Extensions.getExtensions(PyTypeProvider.EP_NAME)) {
    final PyType result = provider.getReferenceType(target, context, anchor);
    if (result != null) {
      return result;
    }
  }

  return null;
}
 
Example 45
Project: intellij-ce-playground   File: XmlExtension.java   Source Code and License 5 votes vote down vote up
private static XmlExtension calcExtension(PsiFile file) {
  for (XmlExtension extension : Extensions.getExtensions(EP_NAME)) {
    if (extension.isAvailable(file)) {
      return extension;
    }
  }
  return DEFAULT_EXTENSION;
}
 
Example 46
Project: intellij-ce-playground   File: UnusedDeclarationInspectionBase.java   Source Code and License 5 votes vote down vote up
public boolean isEntryPoint(@NotNull PsiElement element) {
  final Project project = element.getProject();
  final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
  if (element instanceof PsiMethod && isAddMainsEnabled() && PsiClassImplUtil.isMainOrPremainMethod((PsiMethod)element)) {
    return true;
  }
  if (element instanceof PsiClass) {
    PsiClass aClass = (PsiClass)element;
    final PsiClass applet = psiFacade.findClass("java.applet.Applet", GlobalSearchScope.allScope(project));
    if (isAddAppletEnabled() && applet != null && aClass.isInheritor(applet, true)) {
      return true;
    }

    final PsiClass servlet = psiFacade.findClass("javax.servlet.Servlet", GlobalSearchScope.allScope(project));
    if (isAddServletEnabled() && servlet != null && aClass.isInheritor(servlet, true)) {
      return true;
    }
    if (isAddMainsEnabled() && PsiMethodUtil.hasMainMethod(aClass)) return true;
  }
  if (element instanceof PsiModifierListOwner) {
    final EntryPointsManager entryPointsManager = EntryPointsManager.getInstance(project);
    if (entryPointsManager.isEntryPoint(element)) return true;
  }
  for (EntryPoint extension : myExtensions) {
    if (extension.isEntryPoint(element)) {
      return true;
    }
  }
  final ImplicitUsageProvider[] implicitUsageProviders = Extensions.getExtensions(ImplicitUsageProvider.EP_NAME);
  for (ImplicitUsageProvider provider : implicitUsageProviders) {
    if (provider.isImplicitUsage(element)) return true;
  }
  return false;
}
 
Example 47
Project: intellij-ce-playground   File: XmlInvalidIdInspection.java   Source Code and License 5 votes vote down vote up
@Override
protected void checkValue(XmlAttributeValue value, XmlFile file, XmlRefCountHolder refHolder, XmlTag tag, ProblemsHolder holder) {

  String idRef = XmlHighlightVisitor.getUnquotedValue(value, tag);

  if (tag instanceof HtmlTag) {
    idRef = idRef.toLowerCase();
  }

  if (XmlUtil.isSimpleValue(idRef, value) && refHolder.isIdReferenceValue(value)) {
    boolean hasIdDeclaration = refHolder.hasIdDeclaration(idRef);
    if (!hasIdDeclaration && tag instanceof HtmlTag) {
      hasIdDeclaration = refHolder.hasIdDeclaration(value.getValue());
    }

    if (!hasIdDeclaration) {
      for(XmlIdContributor contributor: Extensions.getExtensions(XmlIdContributor.EP_NAME)) {
        if (contributor.suppressExistingIdValidation(file)) {
          return;
        }
      }

      final FileViewProvider viewProvider = tag.getContainingFile().getViewProvider();
      if (viewProvider instanceof MultiplePsiFilesPerDocumentFileViewProvider) {
        holder.registerProblem(value, XmlErrorMessages.message("invalid.id.reference"), ProblemHighlightType.LIKE_UNKNOWN_SYMBOL,
                               new XmlDeclareIdInCommentAction(idRef));

      }
      else {
        holder.registerProblem(value, XmlErrorMessages.message("invalid.id.reference"), ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
      }
    }
  }
}
 
Example 48
Project: intellij-ce-playground   File: FileDocumentManagerImpl.java   Source Code and License 5 votes vote down vote up
private boolean fireBeforeFileContentReload(final VirtualFile file, @NotNull Document document) {
  for (FileDocumentSynchronizationVetoer vetoer : Extensions.getExtensions(FileDocumentSynchronizationVetoer.EP_NAME)) {
    try {
      if (!vetoer.mayReloadFileContent(file, document)) {
        return false;
      }
    }
    catch (Exception e) {
      LOG.error(e);
    }
  }

  myMultiCaster.beforeFileContentReload(file, document);
  return true;
}
 
Example 49
Project: intellij-ce-playground   File: GenerateByPatternAction.java   Source Code and License 5 votes vote down vote up
@Override
public void update(AnActionEvent e) {
  PatternProvider[] extensions = Extensions.getExtensions(PatternProvider.EXTENSION_POINT_NAME);
  e.getPresentation().setVisible(true);
  for (PatternProvider extension : extensions) {
    if (extension.isAvailable(e.getDataContext())) return;
  }
  e.getPresentation().setVisible(false);
}
 
Example 50
Project: intellij-ce-playground   File: SafeDeleteProcessor.java   Source Code and License 5 votes vote down vote up
private void showUsages(final UsageInfo[] usages) {
  UsageViewPresentation presentation = new UsageViewPresentation();
  presentation.setTabText(RefactoringBundle.message("safe.delete.title"));
  presentation.setTargetsNodeText(RefactoringBundle.message("attempting.to.delete.targets.node.text"));
  presentation.setShowReadOnlyStatusAsRed(true);
  presentation.setShowCancelButton(true);
  presentation.setCodeUsagesString(RefactoringBundle.message("references.found.in.code"));
  presentation.setUsagesInGeneratedCodeString(RefactoringBundle.message("references.found.in.generated.code"));
  presentation.setNonCodeUsagesString(RefactoringBundle.message("occurrences.found.in.comments.strings.and.non.java.files"));
  presentation.setUsagesString(RefactoringBundle.message("usageView.usagesText"));

  UsageViewManager manager = UsageViewManager.getInstance(myProject);
  final UsageView usageView = showUsages(usages, presentation, manager);
  usageView.addPerformOperationAction(new RerunSafeDelete(myProject, myElements, usageView),
                                      RefactoringBundle.message("retry.command"), null, RefactoringBundle.message("rerun.safe.delete"));
  usageView.addPerformOperationAction(new Runnable() {
    @Override
    public void run() {
      UsageInfo[] preprocessedUsages = usages;
      for (SafeDeleteProcessorDelegate delegate : Extensions.getExtensions(SafeDeleteProcessorDelegate.EP_NAME)) {
        preprocessedUsages = delegate.preprocessUsages(myProject, preprocessedUsages);
        if (preprocessedUsages == null) return;
      }
      final UsageInfo[] filteredUsages = UsageViewUtil.removeDuplicatedUsages(preprocessedUsages);
      execute(filteredUsages);
    }
  }, "Delete Anyway", RefactoringBundle.message("usageView.need.reRun"), RefactoringBundle.message("usageView.doAction"));
}
 
Example 51
Project: intellij-ce-playground   File: CopyHandler.java   Source Code and License 5 votes vote down vote up
public static void doClone(PsiElement element) {
  PsiElement[] elements = new PsiElement[]{element};
  for(CopyHandlerDelegate delegate: Extensions.getExtensions(CopyHandlerDelegate.EP_NAME)) {
    if (delegate.canCopy(elements)) {
      if (delegate instanceof CopyHandlerDelegateBase && ((CopyHandlerDelegateBase)delegate).forbidToClone(elements, false)) {
        return;
      }
      delegate.doClone(element);
      break;
    }
  }
}
 
Example 52
Project: intellij-ce-playground   File: ScopeEditorPanel.java   Source Code and License 5 votes vote down vote up
@Override
@NotNull
protected DefaultActionGroup createPopupActionGroup(final JComponent button) {
  final DefaultActionGroup group = new DefaultActionGroup();
  for (final PatternDialectProvider provider : Extensions.getExtensions(PatternDialectProvider.EP_NAME)) {
    group.add(new AnAction(provider.getDisplayName()) {
      @Override
      public void actionPerformed(final AnActionEvent e) {
        DependencyUISettings.getInstance().SCOPE_TYPE = provider.getShortName();
        myUpdate.run();
      }
    });
  }
  return group;
}
 
Example 53
Project: intellij-ce-playground   File: LocalInspectionToolWrapper.java   Source Code and License 5 votes vote down vote up
@NotNull
@Override
protected Map<String, LocalInspectionEP> compute() {
  HashMap<String, LocalInspectionEP> map = new HashMap<String, LocalInspectionEP>();
  for (LocalInspectionEP ep : Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION)) {
    map.put(ep.getShortName(), ep);
  }
  return map;
}
 
Example 54
Project: intellij-ce-playground   File: ElementBase.java   Source Code and License 5 votes vote down vote up
public static RowIcon createLayeredIcon(Iconable instance, Icon icon, int flags) {
  List<Icon> layersFromProviders = new SmartList<Icon>();
  for (IconLayerProvider provider : Extensions.getExtensions(IconLayerProvider.EP_NAME)) {
    final Icon layerIcon = provider.getLayerIcon(instance, (flags & FLAGS_LOCKED) != 0);
    if (layerIcon != null) {
      layersFromProviders.add(layerIcon);
    }
  }
  if (flags != 0 || !layersFromProviders.isEmpty()) {
    List<Icon> iconLayers = new SmartList<Icon>();
    for(IconLayer l: ourIconLayers) {
      if ((flags & l.flagMask) != 0) {
        iconLayers.add(l.icon);
      }
    }
    iconLayers.addAll(layersFromProviders);
    LayeredIcon layeredIcon = new LayeredIcon(1 + iconLayers.size());
    layeredIcon.setIcon(icon, 0);
    for (int i = 0; i < iconLayers.size(); i++) {
      Icon icon1 = iconLayers.get(i);
      layeredIcon.setIcon(icon1, i+1);
    }
    icon = layeredIcon;
  }
  RowIcon baseIcon = new RowIcon(2);
  baseIcon.setIcon(icon, 0);
  return baseIcon;
}
 
Example 55
Project: intellij-ce-playground   File: ModuleImpl.java   Source Code and License 5 votes vote down vote up
@Override
public synchronized void dispose() {
  isModuleAdded = false;
  disposeComponents();
  Extensions.disposeArea(this);
  super.dispose();
}
 
Example 56
Project: intellij-ce-playground   File: MavenIndicesManager.java   Source Code and License 5 votes vote down vote up
public synchronized Set<MavenArchetype> getArchetypes() {
  ensureInitialized();
  Set<MavenArchetype> result = new THashSet<MavenArchetype>(myIndexer.getArchetypes());
  result.addAll(myUserArchetypes);

  for (MavenArchetypesProvider each : Extensions.getExtensions(MavenArchetypesProvider.EP_NAME)) {
    result.addAll(each.getArchetypes());
  }
  return result;
}
 
Example 57
Project: intellij-ce-playground   File: MethodUpDownUtil.java   Source Code and License 5 votes vote down vote up
public static int[] getNavigationOffsets(PsiFile file, final int caretOffset) {
  for(MethodNavigationOffsetProvider provider: Extensions.getExtensions(MethodNavigationOffsetProvider.EP_NAME)) {
    final int[] offsets = provider.getMethodNavigationOffsets(file, caretOffset);
    if (offsets != null && offsets.length > 0) {
      return offsets;
    }
  }

  Collection<PsiElement> array = new THashSet<PsiElement>();
  addNavigationElements(array, file);
  return offsetsFromElements(array);
}
 
Example 58
Project: intellij-ce-playground   File: FoldingPolicy.java   Source Code and License 5 votes vote down vote up
@Nullable
public static String getSignature(@NotNull PsiElement element) {
  for(ElementSignatureProvider provider: Extensions.getExtensions(ElementSignatureProvider.EP_NAME)) {
    String signature = provider.getSignature(element);
    if (signature != null) return signature;
  }
  return GENERIC_PROVIDER.getSignature(element);
}
 
Example 59
Project: intellij-ce-playground   File: GetterSetterPrototypeProvider.java   Source Code and License 5 votes vote down vote up
public static boolean isReadOnlyProperty(PsiField field) {
  for (GetterSetterPrototypeProvider provider : Extensions.getExtensions(EP_NAME)) {
    if (provider.canGeneratePrototypeFor(field)) {
      return provider.isReadOnly(field);
    }
  }
  return field.hasModifierProperty(PsiModifier.FINAL);
}
 
Example 60
Project: intellij-ce-playground   File: ColorSettingsUtil.java   Source Code and License 5 votes vote down vote up
private static boolean isInspectionColorsPage(ColorAndFontDescriptorsProvider provider) {
  // the first registered page implementing InspectionColorSettingsPage
  // gets the inspection attribute descriptors added to its list
  if (!(provider instanceof InspectionColorSettingsPage)) return false;
  for(ColorSettingsPage settingsPage: Extensions.getExtensions(ColorSettingsPage.EP_NAME)) {
    if (settingsPage == provider) break;
    if (settingsPage instanceof InspectionColorSettingsPage) return false;
  }
  return true;        
}