/*package*/ static String getExpandedIconPath_id5FstybB4d94(@NotNull SNode __thisNode__) {
   SModule module =
       jetbrains
           .mps
           .lang
           .smodel
           .generator
           .smodelAdapter
           .SNodeOperations
           .getModel(__thisNode__)
           .getModule();
   if (!(module instanceof AbstractModule)) {
     return null;
   }
   return MacrosFactory.forModule((AbstractModule) module)
       .expandPath(
           SPropertyOperations.getString(
               __thisNode__,
               MetaAdapterFactory.getProperty(
                   0x28f9e4973b424291L,
                   0xaeba0a1039153ab1L,
                   0x5adc7622e710bddcL,
                   0x5adc7622e710cf6eL,
                   "icon")));
 }
 private static boolean renderingCondition_rpujt6_a1b0(SNode node, EditorContext editorContext) {
   String path = null;
   SModule module = SNodeOperations.getModel(node).getModule();
   if (module instanceof AbstractModule) {
     path =
         MacrosFactory.forModule((AbstractModule) module)
             .expandPath(SPropertyOperations.getString(node, "iconPath"));
   }
   return path != null && FileSystem.getInstance().getFileByPath(path).exists();
 }
 private static boolean renderingCondition_fl5ndt_a2b1b0(
     SNode node, EditorContext editorContext, IScope scope) {
   String path = null;
   IModule module = SNodeOperations.getModel(node).getModelDescriptor().getModule();
   if (module != null) {
     path =
         MacrosFactory.forModuleFile(module.getDescriptorFile())
             .expandPath(SPropertyOperations.getString(node, "icon"));
   }
   return path != null && FileSystem.getInstance().getFileByPath(path).exists();
 }
  public static Map<String, Library> readBuiltInLibraries() {
    Map<String, Library> result = new HashMap<String, Library>();

    URL resource = BuiltInLibrariesIO.class.getResource(CONFIG_FILE_WHOLE_NAME);
    if (resource == null) return result;

    InputStream in = null;
    try {
      in = resource.openStream();
      Document document = JDOMUtil.loadDocument(in);
      Element element = document.getRootElement();
      List children = element.getChildren(LIBRARY_TAG);
      for (Object childObj : children) {
        Element child = (Element) childObj;
        String name = child.getAttribute(LIBRARY_NAME_TAG).getValue();
        String path = child.getAttribute(LIBRARY_PATH_TAG).getValue();
        final String realPath =
            MacrosFactory.mpsHomeMacros().expandPath(path, new File(PathManager.getHomePath()));

        Library predefinedLibrary =
            new Library(name) {
              @NotNull
              @Override
              public String getPath() {
                return realPath;
              }
            };
        result.put(name, predefinedLibrary);
      }
    } catch (JDOMException e) {
      LOG.error(e);
    } catch (IOException e) {
      LOG.error(e);
    } finally {
      if (in != null) {
        try {
          in.close();
        } catch (IOException e) {
          LOG.error(e);
        }
      }
    }
    return result;
  }
Exemple #5
0
  /**
   * Convert path from sources module descriptor for using on distribution /classes && /classes_gen
   * converts to bundle home path
   *
   * @param originalPath Original path from sources module descriptor
   * @return Converted path, null if path meaningless on packaged module
   */
  @Nullable
  private String convertPath(
      String originalPath,
      IFile bundleHome,
      IFile sourcesDescriptorFile,
      ModuleDescriptor descriptor) {
    MacroHelper macroHelper = MacrosFactory.forModuleFile(sourcesDescriptorFile);

    String canonicalPath = FileUtil.getCanonicalPath(originalPath).toLowerCase();

    // /classes && /classes_gen hack
    String suffix = descriptor.getCompileInMPS() ? CLASSES_GEN : CLASSES;
    if (canonicalPath.endsWith(suffix)) {
      // MacrosFactory based on original descriptor file because we use original descriptor file for
      // ModuleDescriptor reading, so all paths expanded to original descriptor file
      String classes = macroHelper.expandPath("${module}/" + suffix);
      if (FileUtil.getCanonicalPath(classes).equalsIgnoreCase(canonicalPath)) {
        return bundleHome.getPath();
      }
    } else if (FileUtil.getCanonicalPath(bundleHome.getPath()).equalsIgnoreCase(canonicalPath)) {
      return bundleHome.getPath();
    }

    // ${mps_home}/lib
    String mpsHomeLibPath =
        FileUtil.getCanonicalPath(PathManager.getHomePath() + File.separator + "lib").toLowerCase();
    if (canonicalPath.startsWith(mpsHomeLibPath)) {
      return canonicalPath;
    }

    // we used to keep originalPath if it has a macro not known to MPS here.
    // However, the check has been deprecated in 2012 and thus removed. I'm not 100% sure what
    // 'meaningless' in the contract of the method means. Of course, unknown macros make no sense
    // for us
    // and thus null is legitimate answer, OTOH, custom macros might have a lot of meaning to
    // someone else.
    //
    // ignore paths starts from ${module}/${project} etc
    return null;
  }
Exemple #6
0
    private void load(File file, Element root) {
      Macros macros = MacrosFactory.projectDescriptor();
      FileMPSProject.ProjectDescriptor result_dkknya_a1a1a = this;
      final String result_dkknya_a0a1a1a = file.getName();
      result_dkknya_a1a1a.setName(result_dkknya_a0a1a1a);

      if (root == null) {
        return;
      }

      List<Element> moduleList = ListSequence.fromList(new ArrayList<Element>());
      ListSequence.fromList(moduleList)
          .addSequence(
              ListSequence.fromList(
                  AttributeUtils.elementChildren(
                      ListSequence.fromList(
                              AttributeUtils.elementChildren(root, "projectSolutions"))
                          .first(),
                      "solutionPath")));
      ListSequence.fromList(moduleList)
          .addSequence(
              ListSequence.fromList(
                  AttributeUtils.elementChildren(
                      ListSequence.fromList(
                              AttributeUtils.elementChildren(root, "projectLanguages"))
                          .first(),
                      "languagePath")));
      ListSequence.fromList(moduleList)
          .addSequence(
              ListSequence.fromList(
                  AttributeUtils.elementChildren(
                      ListSequence.fromList(AttributeUtils.elementChildren(root, "projectDevkits"))
                          .first(),
                      "devkitPath")));
      ListSequence.fromList(moduleList)
          .addSequence(
              ListSequence.fromList(
                  AttributeUtils.elementChildren(
                      ListSequence.fromList(AttributeUtils.elementChildren(root, "projectModules"))
                          .first(),
                      "modulePath")));
      for (Element moduleElement : ListSequence.fromList(moduleList)) {
        Path modulePath = new Path();
        Path result_dkknya_a1a9a1a1a = modulePath;
        final String result_dkknya_a0a1a9a1a1a =
            macros.expandPath(moduleElement.getAttributeValue("path"), file);
        result_dkknya_a1a9a1a1a.setPath(result_dkknya_a0a1a9a1a1a);
        final String result_dkknya_a1a1a9a1a1a = moduleElement.getAttributeValue("folder");
        result_dkknya_a1a9a1a1a.setMPSFolder(result_dkknya_a1a1a9a1a1a);
        result_dkknya_a1a1a.addModule(modulePath);
      }

      for (Element e :
          ListSequence.fromList(
              AttributeUtils.elementChildren(
                  ListSequence.fromList(AttributeUtils.elementChildren(root, "genConfs")).first(),
                  "genConfModels"))) {
        ModelsTestConfiguration tc = new ModelsTestConfiguration();
        tc.setName(e.getAttributeValue("name"));
        for (Element me :
            ListSequence.fromList(
                AttributeUtils.elementChildren(
                    ListSequence.fromList(AttributeUtils.elementChildren(e, "models")).first(),
                    "model"))) {
          tc.addModel(SModelReference.fromString(me.getAttributeValue("modelRef")));
        }
        result_dkknya_a1a1a.getTestConfiturations().add(tc);
      }
      for (Element e :
          ListSequence.fromList(
              AttributeUtils.elementChildren(
                  ListSequence.fromList(AttributeUtils.elementChildren(root, "genConfs")).first(),
                  "genConfModule"))) {
        ModuleTestConfiguration tc = new ModuleTestConfiguration();
        tc.setName(e.getAttributeValue("name"));
        if (e.getAttributeValue("moduleRef") != null) {
          tc.setModuleRef(ModuleReference.fromString(e.getAttributeValue("moduleRef")));
          result_dkknya_a1a1a.getTestConfiturations().add(tc);
        }
      }
    }
    private void load(File file, Element root) {
      FileMPSProject.ProjectDescriptor result_dkknya_a0a5o = this;
      final String result_dkknya_a0a0a5o = file.getName();
      result_dkknya_a0a5o.setName(result_dkknya_a0a0a5o);

      if (root == null) {
        return;
      }

      List<Element> moduleList = ListSequence.fromList(new ArrayList<Element>());
      ListSequence.fromList(moduleList)
          .addSequence(
              Sequence.fromIterable(
                  XmlUtil.children(XmlUtil.first(root, "projectSolutions"), "solutionPath")));
      ListSequence.fromList(moduleList)
          .addSequence(
              Sequence.fromIterable(
                  XmlUtil.children(XmlUtil.first(root, "projectLanguages"), "languagePath")));
      ListSequence.fromList(moduleList)
          .addSequence(
              Sequence.fromIterable(
                  XmlUtil.children(XmlUtil.first(root, "projectDevkits"), "devkitPath")));
      ListSequence.fromList(moduleList)
          .addSequence(
              Sequence.fromIterable(
                  XmlUtil.children(XmlUtil.first(root, "projectModules"), "modulePath")));
      for (Element moduleElement : ListSequence.fromList(moduleList)) {
        Path modulePath = new Path();
        Path result_dkknya_a1a9a0a5o = modulePath;
        final String result_dkknya_a0a1a9a0a5o =
            MacrosFactory.forProjectFile(FileSystem.getInstance().getFileByPath(file.getPath()))
                .expandPath(moduleElement.getAttributeValue("path"));
        result_dkknya_a1a9a0a5o.setPath(result_dkknya_a0a1a9a0a5o);
        final String result_dkknya_a1a1a9a0a5o = moduleElement.getAttributeValue("folder");
        result_dkknya_a1a9a0a5o.setMPSFolder(result_dkknya_a1a1a9a0a5o);
        result_dkknya_a0a5o.addModule(modulePath);
      }

      for (Element e :
          Sequence.fromIterable(
              XmlUtil.children(XmlUtil.first(root, "genConfs"), "genConfModels"))) {
        ModelsTestConfiguration tc = new ModelsTestConfiguration();
        tc.setName(e.getAttributeValue("name"));
        for (Element me :
            Sequence.fromIterable(XmlUtil.children(XmlUtil.first(e, "models"), "model"))) {
          tc.addModel(SModelReference.fromString(me.getAttributeValue("modelRef")));
        }
        result_dkknya_a0a5o.getTestConfigurations().add(tc);
      }

      for (Element e :
          Sequence.fromIterable(
              XmlUtil.children(XmlUtil.first(root, "genConfs"), "genConfModule"))) {
        ModuleTestConfiguration tc = new ModuleTestConfiguration();
        tc.setName(e.getAttributeValue("name"));
        String moduleRef = e.getAttributeValue("moduleRef");
        if (moduleRef != null) {
          tc.setModuleRef(ModuleReference.fromString(moduleRef));
          result_dkknya_a0a5o.getTestConfigurations().add(tc);
        }
      }
    }
Exemple #8
0
 @NotNull
 private MacroHelper createMacroHelper() {
   return MacrosFactory.forProjectFile(new IoFile(getProjectFile().getPath()));
 }
 @Override
 protected String removeMacros(String path) {
   return MacrosFactory.forProjectFile(getAnchorIFile()).expandPath(path);
 }
 @Override
 protected String addMacros(String path) {
   return MacrosFactory.forProjectFile(getAnchorIFile()).shrinkPath(path);
 }