private static boolean shouldBeBuiltByExternalSystem(@NotNull Module module) {
   for (Facet facet : FacetManager.getInstance(module).getAllFacets()) {
     if (ArrayUtil.contains(facet.getName(), "Android", "Android-Gradle", "Java-Gradle"))
       return true;
   }
   return false;
 }
 @Override
 public boolean isSupportAlreadyAdded(@NotNull Module module) {
   return FacetManager.getInstance(module)
           .getFacetsByType(PythonFacetType.getInstance().getId())
           .size()
       > 0;
 }
Ejemplo n.º 3
0
  @Override
  public Iterable<SDependency> getDeclaredDependencies() {
    if (myDependencies == null) {
      myDependencies = new ArrayList<SDependency>();

      ArrayList<Module> usedModules =
          new ArrayList<Module>(
              Arrays.asList(ModuleRootManager.getInstance(myModule).getDependencies()));
      for (Module usedModule : usedModules) {
        MPSFacet usedModuleMPSFacet =
            FacetManager.getInstance(usedModule).getFacetByType(MPSFacetType.ID);
        if (usedModuleMPSFacet != null && usedModuleMPSFacet.wasInitialized()) {
          myDependencies.add(
              new SDependencyImpl(
                  usedModuleMPSFacet.getSolution(), SDependencyScope.DEFAULT, false));
        }
      }

      addUsedSdk(myDependencies);
      addUsedLibraries(myDependencies);

      // adding JDK module to a set of dependencies
      // why, oh, why are we doing it?
      // FIXME, PLEASE!
      //      Solution jdkSolution = StubSolutionIdea.getJdkSolution();
      //      if (jdkSolution != null) {
      //        myDependencies.add(new Dependency(jdkSolution.getModuleReference(), false));
      //      }
    }
    return myDependencies;
  }
  @Override
  public void moduleAdded() {
    if (FacetManager.getInstance(module).getFacetByType(CeylonFacet.ID) == null) {
      return;
    }

    ceylonModel.addProject(module);
  }
 private static void validateFacet(@NotNull Module module) throws Exception {
   FacetManager facetManager = FacetManager.getInstance(module);
   ErlangFacet facet = facetManager.getFacetByType(ErlangFacetType.TYPE_ID);
   assertNotNull("Erlang facet was not added.", facet);
   List<String> actualIncludePaths = facet.getConfiguration().getIncludePaths();
   List<String> expectedIncludePaths = new ArrayList<String>();
   for (VirtualFile contentRoot : ModuleRootManager.getInstance(module).getContentRoots()) {
     VirtualFile includeDirectory = VfsUtil.findRelativeFile(contentRoot, "include");
     if (includeDirectory != null) {
       expectedIncludePaths.add(includeDirectory.getPath());
     }
   }
   assertSameElements(actualIncludePaths, expectedIncludePaths);
 }
        @Override
        public void configureModule(
            @NotNull Module module,
            @NotNull ModifiableRootModel model,
            @NotNull ContentEntry contentEntry) {
          super.configureModule(module, model, contentEntry);

          String libPath = PluginPathManager.getPluginHomePath("osmorc") + "/lib";
          PsiTestUtil.addLibrary(
              module, model, "osgi.core", libPath, "org.apache.felix.framework-4.2.1.jar");
          PsiTestUtil.addLibrary(module, model, "plexus", libPath, "plexus-utils-3.0.10.jar");

          String annotationsPath = PathManager.getJarPathForClass(NotNull.class);
          assertNotNull(annotationsPath);
          File annotations = new File(annotationsPath);
          PsiTestUtil.addLibrary(
              module, model, "annotations", annotations.getParent(), annotations.getName());

          FacetManager.getInstance(module).addFacet(OsmorcFacetType.getInstance(), "OSGi", null);
        }
  @NotNull
  private static AppEngineGradleFacet addAppEngineGradleFacet(
      IdeaAppEngineProject ideaAppEngineProject, Module appEngineModule) {
    FacetManager facetManager = FacetManager.getInstance(appEngineModule);
    ModifiableFacetModel model = facetManager.createModifiableModel();
    AppEngineGradleFacet facet = AppEngineGradleFacet.getInstance(appEngineModule);
    if (facet == null) {
      // Module does not have AppEngine-Gradle facet. Create one and add it.
      try {
        facet =
            facetManager.createFacet(
                AppEngineGradleFacet.getFacetType(), AppEngineGradleFacet.NAME, null);
        model.addFacet(facet);
      } finally {
        model.commit();
      }
    }

    // deserialize state from ideaAppEngineProject into facet config.
    if (facet != null) {
      facet.getConfiguration().getState().APPENGINE_SDKROOT =
          ideaAppEngineProject.getDelegate().getAppEngineSdkRoot();
      facet.getConfiguration().getState().HTTP_ADDRESS =
          ideaAppEngineProject.getDelegate().getHttpAddress();
      facet.getConfiguration().getState().HTTP_PORT =
          ideaAppEngineProject.getDelegate().getHttpPort();
      facet.getConfiguration().getState().JVM_FLAGS.clear();
      for (String flag : ideaAppEngineProject.getDelegate().getJvmFlags()) {
        facet.getConfiguration().getState().JVM_FLAGS.add(flag);
      }
      facet.getConfiguration().getState().WAR_DIR =
          ideaAppEngineProject.getDelegate().getWarDir().getAbsolutePath();
      facet.getConfiguration().getState().WEB_APP_DIR =
          ideaAppEngineProject.getDelegate().getWebAppDir().getAbsolutePath();
      facet.getConfiguration().getState().DISABLE_UPDATE_CHECK =
          ideaAppEngineProject.getDelegate().isDisableUpdateCheck();
    }
    return facet;
  }
  private static void addRootsFromModule(Module module, Collection<String> pythonPathList) {

    // for Jython
    final CompilerModuleExtension extension = CompilerModuleExtension.getInstance(module);
    if (extension != null) {
      final VirtualFile path = extension.getCompilerOutputPath();
      if (path != null) {
        pythonPathList.add(path.getPath());
      }
      final VirtualFile pathForTests = extension.getCompilerOutputPathForTests();
      if (pathForTests != null) {
        pythonPathList.add(pathForTests.getPath());
      }
    }

    // additional paths from facets (f.e. buildout)
    final Facet[] facets = FacetManager.getInstance(module).getAllFacets();
    for (Facet facet : facets) {
      if (facet instanceof PythonPathContributingFacet) {
        List<String> more_paths = ((PythonPathContributingFacet) facet).getAdditionalPythonPath();
        if (more_paths != null) pythonPathList.addAll(more_paths);
      }
    }
  }
Ejemplo n.º 9
0
  @Override
  public void projectOpened() {
    for (Module module : ModuleManager.getInstance(myProject).getModules()) {
      MPSFacet moduleMPSFacet = FacetManager.getInstance(module).getFacetByType(MPSFacetType.ID);
      if (moduleMPSFacet == null) continue;
      final Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
      if (sdk == null) continue;

      // HACK temporary
      if (sdk.getName().equals("1.6")) continue;

      if (mySdkSolutions.get(sdk) == null) {
        ModelAccess.instance()
            .runWriteAction(
                new Runnable() {
                  @Override
                  public void run() {
                    Solution solution = addSolution(sdk);
                    mySdkSolutions.put(sdk, solution);
                  }
                });
      }
    }
  }
 private boolean hasGoFacet(Module module) {
   return FacetManager.getInstance(module).getFacetByType(GoFacetType.GO_FACET_TYPE_ID) != null;
 }
Ejemplo n.º 11
0
  private void updateFields(AnActionEvent e) {
    // cleaning all local fields
    myOperationContext = null;
    myModelDescriptor = null;
    myConceptFqNameToNodePointerMap.clear();
    myProject = e.getData(PlatformDataKeys.PROJECT);

    if (myProject == null) {
      return;
    }
    jetbrains.mps.project.Project mpsProject = ProjectHelper.toMPSProject(myProject);
    if (mpsProject == null) {
      return;
    }

    Module module = e.getData(LangDataKeys.MODULE);
    VirtualFile[] vFiles = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY);
    if (module == null || vFiles == null || vFiles.length != 1) {
      return;
    }

    MPSFacet mpsFacet = FacetManager.getInstance(module).getFacetByType(MPSFacetType.ID);
    if (mpsFacet == null || !mpsFacet.wasInitialized()) {
      return;
    }

    String url = vFiles[0].getUrl();
    if (!LocalFileSystem.PROTOCOL.equals(VirtualFileManager.extractProtocol(url))) {
      return;
    }
    String path = VirtualFileManager.extractPath(url);
    for (ModelRoot root : mpsFacet.getSolution().getModelRoots()) {
      if (!(root instanceof DefaultModelRoot)) continue;
      DefaultModelRoot modelRoot = (DefaultModelRoot) root;
      for (String sourceRoot : modelRoot.getFiles(DefaultModelRoot.SOURCE_ROOTS)) {
        if (path.startsWith(sourceRoot)) {
          Solution solution = mpsFacet.getSolution();
          myOperationContext = new ModuleContext(solution, mpsProject);
          myModelDescriptor =
              (EditableSModel)
                  SModelFileTracker.getInstance()
                      .findModel(FileSystem.getInstance().getFileByPath(vFiles[0].getPath()));
          if (myModelDescriptor != null) {
            mpsProject
                .getModelAccess()
                .runReadAction(
                    new Runnable() {
                      @Override
                      public void run() {
                        SModel model = myModelDescriptor;
                        List<Language> modelLanguages = SModelOperations.getLanguages(model);
                        for (Language language : modelLanguages) {
                          for (SNode concept : language.getConceptDeclarations()) {
                            String conceptFqName = NameUtil.nodeFQName(concept);
                            if (ModelConstraints.canBeRoot(conceptFqName, model, null)) {
                              myConceptFqNameToNodePointerMap.put(
                                  conceptFqName, new jetbrains.mps.smodel.SNodePointer(concept));
                            }
                          }
                        }
                      }
                    });
          } else {
            myNewModel = true;
          }
          return;
        }
      }
    }
  }
Ejemplo n.º 12
0
 private MPSFacet getMpsFacet(Module mod) {
   Collection<MPSFacet> mpsFacets = FacetManager.getInstance(mod).getFacetsByType(MPSFacetType.ID);
   if (mpsFacets != null && mpsFacets.size() > 0) return mpsFacets.iterator().next();
   else return null;
 }
Ejemplo n.º 13
0
 private boolean hasMPSFacet(Module mod) {
   Collection<MPSFacet> mpsFacets = FacetManager.getInstance(mod).getFacetsByType(MPSFacetType.ID);
   return (mpsFacets != null && mpsFacets.size() > 0);
 }
Ejemplo n.º 14
0
 /**
  * Gets the StrutsFacet for the given module.
  *
  * @param module Module to check.
  * @return Instance or <code>null</code> if none configured.
  */
 @Nullable
 public static OfbizFacet getInstance(@NotNull final Module module) {
   return FacetManager.getInstance(module).getFacetByType(FACET_TYPE_ID);
 }