Beispiel #1
0
  public void doInit() {
    // register kinds
    ExtensionPoint<ConfigurationType> configurationExtensionPoint =
        Extensions.getArea(null).getExtensionPoint(ConfigurationType.CONFIGURATION_TYPE_EP);

    // add foreign factories
    _FunctionTypes._return_P1_E0<? extends Class<ConfigurationType>, ? super String>
        getClassFunction =
            new _FunctionTypes._return_P1_E0<Class<ConfigurationType>, String>() {
              public Class<ConfigurationType> invoke(String className) {
                try {
                  return (Class<ConfigurationType>)
                      getClass().getClassLoader().loadClass(className);
                } catch (ClassNotFoundException cl) {
                  LOG.error(
                      "Can not find configuration type "
                          + className
                          + ". Check languages dependency.",
                      cl);
                  return (Class<ConfigurationType>) null;
                }
              }
            };
    {
      ConfigurationType configurationType =
          ContainerUtil.findInstance(
              configurationExtensionPoint.getExtensions(),
              getClassFunction.invoke("jetbrains.mps.buildlanguage.plugin.Ant_Kind"));
      if (configurationType != null) {
        ((Ant_Kind) configurationType)
            .addForeignFactory(
                new PackagingBuildScript_Configuration_Factory((Ant_Kind) configurationType));
      }
    }

    // register creators
    ExtensionPoint<RuntimeConfigurationProducer> producerExtensionPoint =
        Extensions.getArea(null)
            .getExtensionPoint(RuntimeConfigurationProducer.RUNTIME_CONFIGURATION_PRODUCER);
    {
      ConfigurationType configurationType =
          ContainerUtil.findInstance(
              configurationExtensionPoint.getExtensions(),
              getClassFunction.invoke("jetbrains.mps.buildlanguage.plugin.Ant_Kind"));
      if (configurationType != null) {
        List<RuntimeConfigurationProducer> configurationProducers =
            PackagingBuildScript_Producer.getProducers(configurationType);
        ListSequence.fromList(
                RunConfigurationsInitializer_CustomApplicationPlugin.this.myRegisteredProducers)
            .addSequence(ListSequence.fromList(configurationProducers));
        for (RuntimeConfigurationProducer producer :
            ListSequence.fromList(configurationProducers)) {
          producerExtensionPoint.registerExtension(producer);
        }
      }
    }
  }
 private void fireBeforeApplicationLoaded() {
   ExtensionPoint<ApplicationLoadListener> point =
       Extensions.getRootArea().getExtensionPoint("com.intellij.ApplicationLoadListener");
   final ApplicationLoadListener[] objects = point.getExtensions();
   for (ApplicationLoadListener object : objects) {
     object.beforeApplicationLoaded(this);
   }
 }
 public void initializeAnnotators() {
   ExtensionPoint<RefGraphAnnotator> point =
       Extensions.getRootArea().getExtensionPoint(ToolExtensionPoints.INSPECTIONS_GRAPH_ANNOTATOR);
   final RefGraphAnnotator[] graphAnnotators = point.getExtensions();
   for (RefGraphAnnotator annotator : graphAnnotators) {
     registerGraphAnnotator(annotator);
   }
 }
 public void resumeInteractions() {
   myAvailabilityNotificationsActive = true;
   ExtensionPoint[] extensionPoints = getExtensionPoints();
   for (ExtensionPoint extensionPoint : extensionPoints) {
     extensionPoint.getExtensions(); // creates extensions from ComponentAdapters
   }
   for (Runnable action : mySuspendedListenerActions) {
     try {
       action.run();
     } catch (Exception e) {
       myLogger.error(e);
     }
   }
   mySuspendedListenerActions.clear();
 }
  private static void loadComponentRoamingTypes() {
    ExtensionPoint<RoamingTypeExtensionPointBean> point =
        Extensions.getRootArea().getExtensionPoint("com.intellij.ComponentRoamingType");
    final RoamingTypeExtensionPointBean[] componentRoamingTypes = point.getExtensions();

    for (RoamingTypeExtensionPointBean object : componentRoamingTypes) {

      assert object.componentName != null;
      assert object.roamingType != null;

      final RoamingType type = RoamingType.valueOf(object.roamingType);

      assert type != null;

      ComponentRoamingManager.getInstance().setRoamingType(object.componentName, type);
    }
  }
  @Override
  protected boolean queryExternalUsagesRequests(
      @NotNull final RefManager manager,
      @NotNull final GlobalJavaInspectionContext globalContext,
      @NotNull final ProblemDescriptionsProcessor processor) {
    final EntryPointsManager entryPointsManager = globalContext.getEntryPointsManager(manager);
    for (RefElement entryPoint : entryPointsManager.getEntryPoints()) {
      ignoreElement(processor, entryPoint);
    }

    ExtensionPoint<VisibilityExtension> point =
        Extensions.getRootArea().getExtensionPoint(ExtensionPoints.VISIBLITY_TOOL);
    for (VisibilityExtension addin : point.getExtensions()) {
      addin.fillIgnoreList(manager, processor);
    }
    manager.iterate(
        new RefJavaVisitor() {
          @Override
          public void visitElement(@NotNull final RefEntity refEntity) {
            if (!(refEntity instanceof RefElement)) return;
            if (processor.getDescriptions(refEntity) == null) return;
            refEntity.accept(
                new RefJavaVisitor() {
                  @Override
                  public void visitField(@NotNull final RefField refField) {
                    if (refField.getAccessModifier() != PsiModifier.PRIVATE) {
                      globalContext.enqueueFieldUsagesProcessor(
                          refField,
                          new GlobalJavaInspectionContext.UsagesProcessor() {
                            @Override
                            public boolean process(PsiReference psiReference) {
                              ignoreElement(processor, refField);
                              return false;
                            }
                          });
                    }
                  }

                  @Override
                  public void visitMethod(@NotNull final RefMethod refMethod) {
                    if (!refMethod.isExternalOverride()
                        && refMethod.getAccessModifier() != PsiModifier.PRIVATE
                        && !(refMethod instanceof RefImplicitConstructor)) {
                      globalContext.enqueueDerivedMethodsProcessor(
                          refMethod,
                          new GlobalJavaInspectionContext.DerivedMethodsProcessor() {
                            @Override
                            public boolean process(PsiMethod derivedMethod) {
                              ignoreElement(processor, refMethod);
                              return false;
                            }
                          });

                      globalContext.enqueueMethodUsagesProcessor(
                          refMethod,
                          new GlobalJavaInspectionContext.UsagesProcessor() {
                            @Override
                            public boolean process(PsiReference psiReference) {
                              ignoreElement(processor, refMethod);
                              return false;
                            }
                          });

                      if (entryPointsManager.isAddNonJavaEntries()) {
                        final RefClass ownerClass = refMethod.getOwnerClass();
                        if (refMethod.isConstructor()
                            && ownerClass.getDefaultConstructor() != null) {
                          String qualifiedName = ownerClass.getElement().getQualifiedName();
                          if (qualifiedName != null) {
                            final Project project = manager.getProject();
                            PsiSearchHelper.SERVICE
                                .getInstance(project)
                                .processUsagesInNonJavaFiles(
                                    qualifiedName,
                                    new PsiNonJavaFileReferenceProcessor() {
                                      @Override
                                      public boolean process(
                                          PsiFile file, int startOffset, int endOffset) {
                                        entryPointsManager.addEntryPoint(refMethod, false);
                                        ignoreElement(processor, refMethod);
                                        return false;
                                      }
                                    },
                                    GlobalSearchScope.projectScope(project));
                          }
                        }
                      }
                    }
                  }

                  @Override
                  public void visitClass(@NotNull final RefClass refClass) {
                    if (!refClass.isAnonymous()) {
                      globalContext.enqueueDerivedClassesProcessor(
                          refClass,
                          new GlobalJavaInspectionContext.DerivedClassesProcessor() {
                            @Override
                            public boolean process(PsiClass inheritor) {
                              ignoreElement(processor, refClass);
                              return false;
                            }
                          });

                      globalContext.enqueueClassUsagesProcessor(
                          refClass,
                          new GlobalJavaInspectionContext.UsagesProcessor() {
                            @Override
                            public boolean process(PsiReference psiReference) {
                              ignoreElement(processor, refClass);
                              return false;
                            }
                          });
                    }
                  }
                });
          }
        });
    return false;
  }