コード例 #1
0
 public static String call_getOutputPath_WithMacro_202934866059116697(
     SNode thisNode, Context context) {
   if ((SNodeOperations.getParent(thisNode) != null)
       && SNodeOperations.isInstanceOf(
           SNodeOperations.getParent(thisNode),
           "jetbrains.mps.build.structure.BuildLayout_Container")) {
     String parentChildrenTargetDir =
         BuildLayout_Container_Behavior.call_getChildrenOutputDir_WithMacro_4701820937132344011(
             SNodeOperations.cast(
                 SNodeOperations.getParent(thisNode),
                 "jetbrains.mps.build.structure.BuildLayout_Container"),
             context);
     return parentChildrenTargetDir
         + "/"
         + BuildString_Behavior.call_getText_4380385936562005550(
             SLinkOperations.getTarget(thisNode, "fileName", true), context.getMacros(thisNode));
   }
   return null;
 }
コード例 #2
0
 public static String call_getOutputPath_WithMacro_280273048052535414(
     SNode thisNode, Context context) {
   if ((SNodeOperations.getParent(thisNode) != null)
       && SNodeOperations.isInstanceOf(
           SNodeOperations.getParent(thisNode),
           "jetbrains.mps.build.structure.BuildLayout_Container")) {
     String parentChildrenTargetDir =
         BehaviorReflection.invokeVirtual(
             String.class,
             SNodeOperations.cast(
                 SNodeOperations.getParent(thisNode),
                 "jetbrains.mps.build.structure.BuildLayout_Container"),
             "virtual_getChildrenOutputDir_WithMacro_4701820937132344011",
             new Object[] {context});
     return parentChildrenTargetDir
         + "/"
         + BuildString_Behavior.call_getText_4380385936562005550(
             SLinkOperations.getTarget(
                 SLinkOperations.getTarget(thisNode, "plugin", false), "containerName", true),
             context.getMacros(thisNode));
   }
   return null;
 }
コード例 #3
0
ファイル: ModuleLoaderUtils.java プロジェクト: sprig/MPS
    @Override
    public String expandPath(@Nullable String path) {
      if (path == null) {
        return null;
      }

      if (moduleSourceDir != null) {
        for (String macro : MacrosFactory.descriptors) {
          if (path.startsWith(macro)) {
            String relPath = path.substring(path.indexOf('}') + 1);
            return IFileUtils.getCanonicalPath(moduleSourceDir.getDescendant(relPath));
          }
        }
      }
      if (path.startsWith("${")) {
        int index = path.indexOf("}");
        if (index == -1) {
          reporter.report("invalid macro in `" + path + "'", null, null);
          return path;
        }

        String macroName = path.substring(2, index);
        SNode found = null;
        for (SNode macro :
            SLinkOperations.getTargets(
                SNodeOperations.getAncestor(
                    originalModule, "jetbrains.mps.build.structure.BuildProject", false, false),
                "macros",
                true)) {
          if (!(SNodeOperations.isInstanceOf(
              macro, "jetbrains.mps.build.structure.BuildFolderMacro"))) {
            continue;
          }

          if (eq_krgnbt_a0c0f0d0f4(SPropertyOperations.getString(macro, "name"), macroName)) {
            found = SNodeOperations.cast(macro, "jetbrains.mps.build.structure.BuildFolderMacro");
            break;
          }
        }
        if (found == null) {
          reporter.report("macro is not declared in build script: " + path, null, null);
          return path;
        }

        String localPath =
            BehaviorReflection.invokeVirtual(
                String.class,
                SLinkOperations.getTarget(found, "defaultPath", true),
                "virtual_getLocalPath_5481553824944787364",
                new Object[] {
                  (genContext != null
                      ? Context.defaultContext(genContext)
                      : Context.defaultContext())
                });
        if (localPath == null) {
          if (genContext != null) {
            genContext.showWarningMessage(
                found, "cannot resolve local path: " + path + ", macro has no default value");
          }
          return path;
        }

        String relPath = path.substring(index + 1);
        return IFileUtils.getCanonicalPath(
            FileSystem.getInstance().getFileByPath(localPath).getDescendant(relPath));
      }
      return path;
    }