Пример #1
0
 protected void readModules(FileMPSProject.ProjectDescriptor projDesc) {
   myErrors = null;
   //  load solutions
   Set<SModuleReference> existingModules = getModuleReferences();
   for (Path modulePath : projDesc.getModules()) {
     String path = modulePath.getPath();
     IFile descriptorFile = FileSystem.getInstance().getFileByPath(path);
     if (descriptorFile.exists()) {
       ModuleDescriptor descriptor =
           ModulesMiner.getInstance().loadModuleDescriptor(descriptorFile);
       if (descriptor != null) {
         ModulesMiner.ModuleHandle moduleHandle =
             new ModulesMiner.ModuleHandle(descriptorFile, descriptor);
         SModule m = ModuleRepositoryFacade.createModule(moduleHandle, this);
         SModuleReference moduleReference = m.getModuleReference();
         if (!(existingModules.remove(moduleReference))) {
           super.addModule(moduleReference);
         }
       } else {
         error("Can't load module from " + descriptorFile.getPath() + " Unknown file type.");
       }
     } else {
       error("Can't load module from " + descriptorFile.getPath() + " File doesn't exist.");
     }
   }
   for (SModuleReference ref : existingModules) {
     super.removeModule(ref);
   }
 }
Пример #2
0
 public void collectRequired(Iterable<SModule> pool) {
   Set<SModuleReference> allRequired =
       SetSequence.fromSetWithValues(
           new HashSet<SModuleReference>(),
           Sequence.fromIterable(MapSequence.fromMap(allDeps).values())
               .translate(
                   new ITranslator2<ModulesCluster.ModuleDeps, SModuleReference>() {
                     public Iterable<SModuleReference> translate(ModulesCluster.ModuleDeps dep) {
                       return dep.required;
                     }
                   }));
   List<SModule> available = Sequence.fromIterable(pool).toListSequence();
   int atSize;
   do {
     atSize = MapSequence.fromMap(allDeps).count();
     for (Iterator<SModule> it = ListSequence.fromList(available).iterator(); it.hasNext(); ) {
       SModule mod = it.next();
       SModuleReference mr = mod.getModuleReference();
       if (SetSequence.fromSet(allRequired).contains(mr)) {
         primAdd(mod);
         SetSequence.fromSet(allRequired)
             .addSequence(ListSequence.fromList(MapSequence.fromMap(allDeps).get(mr).required));
         it.remove();
       }
     }
   } while (atSize < MapSequence.fromMap(allDeps).count());
 }
Пример #3
0
  private static SModule getModuleForModel(MPSProject project, SModel model) {
    // language's and solution's own models (+generator models in language)
    SModule owner = model.getModule();
    SModule mainModule =
        owner instanceof Generator ? ((Generator) owner).getSourceLanguage() : owner;
    if (project.isProjectModule(mainModule)) return owner;

    // accessories models in languages
    /*
      //with this enabled, alt-f1 does not work in case node is in non-owned accessory model to a project language
      for (Language l : project.getProjectLanguages()) {
        if (l.isAccessoryModel(model.getSModelReference())) return l;
      }
    */

    // runtime models in languages
    for (Language l : project.getProjectModules(Language.class)) {
      for (SModuleReference depModule : l.getRuntimeModulesReferences()) {
        if (depModule.equals(mainModule.getModuleReference())) return owner;
      }
    }

    // accessories models in devkits

    // runtime models in devkits

    return owner;
  }
 @Override
 @Nullable
 public WarningPanel getWarningPanel(@NotNull SNode node, @NotNull Project project) {
   SModel model = node.getModel();
   if (model != null) {
     SModule module = model.getModule();
     if (module != null && module.isReadOnly()) {
       return new WarningPanel(
           this, "Warning: the node is in a read-only model. Your changes won't be saved");
     }
   }
   return null;
 }
Пример #5
0
 private void primAdd(SModule mod) {
   SModuleReference mr = mod.getModuleReference();
   if (!(MapSequence.fromMap(modulesView).containsKey(mr))) {
     MapSequence.fromMap(modulesView).put(mr, mod);
     updateDeps(mod);
   }
 }
Пример #6
0
 @Override
 public Iterable<SModel> loadModels() {
   List<SModel> result = new ArrayList<SModel>();
   Map<String, String> options = new HashMap<String, String>();
   String contentHome = getContentRoot();
   SModule module = getModule();
   if (module != null) {
     options.put(ModelFactory.OPTION_MODULEREF, module.getModuleReference().toString());
   }
   for (String path : getFiles(SOURCE_ROOTS)) {
     String relativePath = contentHome != null ? makeRelative(contentHome, path) : null;
     collectModels(
         FileSystem.getInstance().getFileByPath(path), "", relativePath, options, result);
   }
   return result;
 }
Пример #7
0
 public RelativePathHelper getRelativePathHelper(@NotNull SModel model) {
   if (model.getModule() instanceof TransientModelsModule && myGenerationContext != null) {
     model = myGenerationContext.getOriginalInputModel();
   }
   SModel modelDescriptor = model;
   if (model.getModule() instanceof TransientModelsModule || modelDescriptor == null) {
     return null;
   }
   SModule module = modelDescriptor.getModule();
   if (module == null
       || ((AbstractModule) module).getDescriptorFile() == null
       || module.isPackaged()) {
     return null;
   }
   String basePath = ((AbstractModule) module).getDescriptorFile().getParent().getPath();
   return new RelativePathHelper(basePath);
 }
Пример #8
0
 /**
  * has a fallback if the dependency is absent in the module descriptor. if it happens then returns
  * simply the current dep. module version
  *
  * @param check is whether to show error for not found version
  */
 public int getDependencyVersion(@NotNull SModule dependency, boolean check) {
   ModuleDescriptor moduleDescriptor = getModuleDescriptor();
   if (!checkDescriptorNotNull(moduleDescriptor)) {
     return -1;
   }
   Integer res = moduleDescriptor.getDependencyVersions().get(dependency.getModuleReference());
   if (res == null) {
     if (check) {
       LOG.error(
           "#getDependencyVersion can't find a version for module "
               + dependency.getModuleName()
               + " in module "
               + getModuleName()
               + "."
               + " This can either mean that the module is not visible from this module or that "
               + "#validateDependencyVersions() was not called on this module in appropriate moment.",
           new Throwable());
     }
     return ((AbstractModule) dependency).getModuleVersion();
   }
   return res;
 }
Пример #9
0
  public void clean(final Set<? extends SModule> modules, @NotNull final ProgressMonitor monitor) {
    monitor.start("Cleaning...", modules.size());
    try {
      for (SModule module : modules) {
        if (isExcluded(module)) {
          monitor.advance(1);
          continue;
        }
        if (monitor.isCanceled()) break;

        monitor.step(module.getModuleName());
        JavaModuleFacet facet = module.getFacet(JavaModuleFacet.class);
        assert facet != null && facet.getClassesGen() != null;
        String path = facet.getClassesGen().getPath();
        FileUtil.delete(new File(path));
        ClassPathFactory.getInstance().invalidate(Collections.singleton(path));
        monitor.advance(1);
      }
    } finally {
      monitor.done();
    }
  }
 public void handleAction_impl(
     SModule parameterObject,
     SNode node,
     SModel model,
     IOperationContext operationContext,
     EditorContext editorContext) {
   SPropertyOperations.set(
       node,
       MetaAdapterFactory.getProperty(
           0x7866978ea0f04cc7L,
           0x81bc4d213d9375e1L,
           0x38130dc4e3db5af1L,
           0x38130dc4e3db5af3L,
           "moduleId"),
       parameterObject.getModuleReference().getModuleId().toString());
 }
Пример #11
0
 public static boolean findInModule(SModule module, String modelName, String rootName) {
   for (SModel d : module.getModels()) {
     if (d.getModelName().equals(modelName)) {
       for (SNode _n : d.getRootNodes()) {
         SNode n = (SNode) _n;
         if (SNodeOperations.isInstanceOf(n, "jetbrains.mps.baseLanguage.structure.Classifier")
             && SPropertyOperations.getString(
                     SNodeOperations.cast(n, "jetbrains.mps.baseLanguage.structure.Classifier"),
                     "name")
                 .equals(rootName)) {
           return true;
         }
       }
     }
   }
   return false;
 }
Пример #12
0
  public synchronized Set<SModelReference> resolveModel(
      SModule module, String name, @Nullable SNodeId nodeId) {
    Pair<SModuleReference, String> key =
        new Pair<SModuleReference, String>(module.getModuleReference(), name);
    ensureInitialized(key);

    Set<SModelReference> models = myStubModulesCache.get(key);
    if (nodeId == null) return new HashSet<SModelReference>(models);

    Set<SModelReference> result = new HashSet<SModelReference>();
    for (SModelReference ref : models) {
      SModel m = SModelRepository.getInstance().getModelDescriptor(ref);
      if (m.getNode(nodeId) != null) {
        result.add(ref);
      }
    }

    return result;
  }
Пример #13
0
 public void updateDeps(SModule mod) {
   SModuleReference mr = mod.getModuleReference();
   ModulesCluster.ModuleDeps deps = MapSequence.fromMap(allDeps).get(mr);
   if (deps == null) {
     deps = new ModulesCluster.ModuleDeps(mr);
     MapSequence.fromMap(allDeps).put(mr, deps);
   }
   ListSequence.fromList(deps.required).addSequence(Sequence.fromIterable(required(mod)));
   for (SModuleReference req : deps.required) {
     if (MapSequence.fromMap(allDeps).containsKey(req)) {
       ListSequence.fromList(MapSequence.fromMap(allDeps).get(req).dependent).addElement(mr);
     }
   }
   for (IMapping<SModuleReference, ModulesCluster.ModuleDeps> m :
       MapSequence.fromMap(allDeps).mappingsSet()) {
     if (ListSequence.fromList(m.value().required).contains(mr)
         && !(ListSequence.fromList(deps.dependent).contains(m.key()))) {
       ListSequence.fromList(deps.dependent).addElement(m.key());
     }
   }
 }
Пример #14
0
 /** Build set of dependencies for the given module, grouped under a fake root container */
 public DepLink build(SModule module) {
   DepLink rv = new DepLink(module.getModuleReference(), DependencyUtil.Role.None, null);
   List<DepLink> queue = ListSequence.fromList(new LinkedList<DepLink>());
   ListSequence.fromList(queue).addElement(rv);
   Map<Dependency, DepLink> visited = MapSequence.fromMap(new HashMap<Dependency, DepLink>());
   while (ListSequence.fromList(queue).isNotEmpty()) {
     DepLink e = ListSequence.fromList(queue).removeElementAt(0);
     List<DepLink> dependencies = dependencies(e.role, e.module);
     for (DepLink d : ListSequence.fromList(dependencies)) {
       d.myParent = e;
       ListSequence.fromList(e.children()).addElement(d);
       Dependency key = d.getRoleModuleKey();
       if (MapSequence.fromMap(visited).containsKey(key)) {
         d.setReused(MapSequence.fromMap(visited).get(key));
       } else {
         MapSequence.fromMap(visited).put(key, d);
         ListSequence.fromList(queue).addElement(d);
       }
     }
   }
   return rv;
 }
Пример #15
0
 /**
  * FIXME Obviously it must be internal module method: it must be done on the fs update (actually
  * it is #update method here) Nobody must recount the module dependency versions from the outside
  * AP
  *
  * <p>Currently happens only during migration;
  *
  * @deprecated please do not use
  */
 @Deprecated
 @ToRemove(version = 3.4)
 public void validateDependencyVersions() {
   assertCanChange();
   ModuleDescriptor md = getModuleDescriptor();
   if (md == null) {
     return;
   }
   Map<SModuleReference, Integer> oldDepVersions = md.getDependencyVersions();
   Map<SModuleReference, Integer> newDepVersions = new HashMap<SModuleReference, Integer>();
   Set<SModule> visible = new LinkedHashSet<SModule>();
   visible.add(this);
   PostingWarningsErrorHandler handler = new PostingWarningsErrorHandler();
   Collection<SModule> dependentModules =
       new GlobalModuleDependenciesManager(this, handler).getModules(Deptype.VISIBLE);
   if (handler.hasErrors()) {
     return;
   }
   visible.addAll(dependentModules);
   if (!md.hasDependencyVersions()) {
     for (SModule dep : visible) {
       newDepVersions.put(dep.getModuleReference(), 0);
     }
     md.setHasDependencyVersions(true);
   } else {
     for (SModule dep : visible) {
       if (oldDepVersions.containsKey(dep.getModuleReference())) {
         newDepVersions.put(
             dep.getModuleReference(), oldDepVersions.get(dep.getModuleReference()));
       } else {
         newDepVersions.put(dep.getModuleReference(), ((AbstractModule) dep).getModuleVersion());
         setChanged();
       }
     }
     if (oldDepVersions.size() != newDepVersions.size()) {
       setChanged();
     }
   }
   oldDepVersions.clear();
   oldDepVersions.putAll(newDepVersions);
 }
Пример #16
0
 @Override
 public Set<SLanguage> getUsedLanguages() {
   return myPeer.getUsedLanguages();
 }
Пример #17
0
 private boolean isExcluded(@NotNull SModule m) {
   return m.isReadOnly() || !SModuleOperations.isCompileInMps(m);
 }
Пример #18
0
  @Override
  protected void executeTask(Project project, MpsWorker.ObjectsToProcess go) {
    Set<SModule> toCompile = SetSequence.fromSet(new LinkedHashSet<SModule>());
    SetSequence.fromSet(toCompile).addSequence(SetSequence.fromSet(go.getModules()));
    for (Project p : go.getProjects()) {
      SetSequence.fromSet(toCompile).addSequence(SetSequence.fromSet(go.getModules()));
    }
    for (final SModel modelDescriptor : go.getModels()) {
      SModule owningModule =
          ModelAccess.instance()
              .runReadAction(
                  new Computable<SModule>() {
                    public SModule compute() {
                      return modelDescriptor.getModule();
                    }
                  });
      SetSequence.fromSet(toCompile).addElement(owningModule);
    }
    final Set<SModule> finalToCompile =
        CollectionUtil.filter(
            toCompile,
            new Condition<SModule>() {
              public boolean met(SModule module) {
                boolean compileInMps =
                    !(module instanceof IModule) || ((IModule) module).isCompileInMPS();
                return compileInMps && !(module.isPackaged());
              }
            });
    if (finalToCompile.isEmpty()) {
      return;
    }
    info("Starting compilation:");
    StringBuffer sb = new StringBuffer();
    for (SModule m : finalToCompile) {
      sb.append("    ");
      sb.append(m.getModuleName());
      sb.append("\n");
    }
    info(sb.toString());
    MPSCompilationResult result =
        ModelAccess.instance()
            .runReadAction(
                new Computable<MPSCompilationResult>() {
                  public MPSCompilationResult compute() {
                    return new ModuleMaker()
                        .make(
                            finalToCompile,
                            new EmptyProgressMonitor() {
                              @Override
                              public void step(String text) {
                                info("    " + text);
                              }

                              @Override
                              public void start(String taskName, int work) {
                                info(taskName);
                              }
                            });
                  }
                });
    info(result.toString());
  }
Пример #19
0
  private MPSCompilationResult compile(Set<SModule> modules, JavaCompilerOptions compilerOptions) {
    boolean hasAnythingToCompile = false;
    List<IMessage> messages = new ArrayList<IMessage>();

    for (SModule m : modules) {
      if (isExcluded(m)) continue;

      hasAnythingToCompile = true;
    }

    if (!hasAnythingToCompile) {
      return new MPSCompilationResult(0, 0, false, Collections.<SModule>emptySet());
    }

    JavaCompiler compiler = new JavaCompiler();
    boolean hasJavaToCompile = false;
    boolean hasFilesToCopyOrDelete = false;

    myTracer.push("preparing to compile", false);
    Set<SModule> modulesWithRemovals = new HashSet<SModule>();
    for (SModule m : modules) {
      if (areClassesUpToDate(m)) continue;

      if (!getJavaFacet(m).isCompileInMps()) {
        String text =
            "Module which compiled in IDEA depends on module which has to be compiled in MPS:"
                + m.getModuleName();
        messages.add(createMessage(MessageKind.WARNING, text, m));
        myHandler.handle(createMessage(MessageKind.INFORMATION, text, m));
        continue;
      }

      ModuleSources sources = getModuleSources(m);
      hasFilesToCopyOrDelete |= !sources.isResourcesUpToDate();
      hasJavaToCompile |= !sources.isJavaUpToDate();

      for (File f : sources.getFilesToDelete()) {
        //noinspection ResultOfMethodCallIgnored
        f.delete();
        modulesWithRemovals.add(m);
      }

      for (JavaFile f : sources.getFilesToCompile()) {
        compiler.addSource(f.getClassName(), f.getContents());
        myContainingModules.put(f.getClassName(), m);
      }
    }
    myTracer.pop();

    if (!hasJavaToCompile && !hasFilesToCopyOrDelete) {
      return new MPSCompilationResult(0, 0, false, Collections.<SModule>emptySet(), messages);
    }

    myTracer.push("invalidating classpath", false);
    for (SModule module : modulesWithRemovals) {
      invalidateCompiledClasses(module);
    }
    myTracer.pop();

    Set<SModule> changedModules = new HashSet<SModule>();
    MyCompilationResultAdapter listener = null;
    if (hasJavaToCompile) {
      myTracer.push("compiling java", false);
      IClassPathItem classPathItems = computeDependenciesClassPath(modules);
      listener = new MyCompilationResultAdapter(modules, classPathItems, messages);
      compiler.addCompilationResultListener(listener);
      myTracer.push("eclipse compiler", true);

      if (compilerOptions == null) {
        compiler.compile(classPathItems);
      } else {
        compiler.compile(classPathItems, compilerOptions);
      }
      myTracer.pop();
      changedModules.addAll(listener.myChangedModules);
      compiler.removeCompilationResultListener(listener);
      myTracer.pop();
    }

    myTracer.push("copying resources", false);
    for (SModule module : modules) {
      ModuleSources sources = getModuleSources(module);
      IFile classesGen = getJavaFacet(module).getClassesGen();
      if (classesGen == null) {
        continue;
      }
      for (ResourceFile toCopy : sources.getResourcesToCopy()) {
        String fqName = toCopy.getPath();

        fqName = fqName.substring(0, fqName.length() - toCopy.getFile().getName().length());
        String path = fqName.replace('/', File.separatorChar) + toCopy.getFile().getName();

        if (new File(toCopy.getFile().getAbsolutePath()).exists()) {
          FileUtil.copyFile(
              new File(toCopy.getFile().getAbsolutePath()),
              new File(classesGen.getDescendant(path).getPath()));
        }
      }
    }
    myTracer.pop();

    myTracer.push("updating classpath", false);
    for (SModule module : changedModules) {
      invalidateCompiledClasses(module);
    }
    myTracer.pop();

    for (SModule module : modulesWithRemovals) {
      if (!changedModules.contains(module)) {
        myHandler.handle(
            createMessage(
                MessageKind.WARNING,
                "Module with removals not in changed modules: " + module,
                module));
      }
    }

    // todo: check possibility of this statements
    if (hasJavaToCompile && changedModules.isEmpty()) {
      myHandler.handle(
          createMessage(
              MessageKind.ERROR, "has java to compile but changed modules is empty", null));
    }
    if (!hasJavaToCompile && !changedModules.isEmpty()) {
      myHandler.handle(
          createMessage(
              MessageKind.ERROR, "has not java to compile but changed modules is not empty", null));
    }

    return new MPSCompilationResult(
        listener == null ? 0 : listener.getErrorCount(), 0, false, changedModules, messages);
  }
Пример #20
0
 @Override
 public Iterable<SDependency> getDeclaredDependencies() {
   return myPeer.getDeclaredDependencies();
 }
 public String getMatchingText_internal(SModule parameterObject) {
   return parameterObject.getModuleName();
 }
Пример #22
0
 public static SModuleReference createReference(String moduleName) {
   // TODO use SRepository?
   SModuleReference ref = new ModuleReference(moduleName);
   SModule module = getInstance().getModule(ref);
   return module != null ? module.getModuleReference() : ref;
 }
Пример #23
0
  public int getModelKind(SModel model, @Nullable SReference reference) {
    DataSource source = (model != null ? model.getSource() : null);
    IFile modelFile =
        (source instanceof FileDataSource ? ((FileDataSource) source).getFile() : null);
    if (modelFile != null) {
      String filePath = modelFile.getAbsolutePath().replace('\\', '/');
      if (filePath.startsWith(languagesUtilPath)) {
        return OTHER;
      }
    }

    SModule module = model.getModule();
    if (module instanceof Language) {
      LanguageAspect aspect = Language.getModelAspect(model);
      if (aspect != null) {
        switch (aspect) {
          case ACTIONS:
            return EDITOR;
          case BEHAVIOR:
            return CORE;
          case CONSTRAINTS:
            return CORE;
          case DATA_FLOW:
            return CORE;
          case EDITOR:
            return EDITOR;
          case FIND_USAGES:
            return CORE;
          case INTENTIONS:
            return EDITOR;
          case PLUGIN:
            return WORKBENCH;
          case REFACTORINGS:
            return CORE;
          case SCRIPTS:
            return CORE;
          case STRUCTURE:
            return CORE;
          case STUBS:
            return CORE;
          case TEST:
            return EDITOR;
          case TEXT_GEN:
            return CORE;
          case TYPESYSTEM:
            return CORE;
          default:
        }
      }
      return CORE;

    } else if (module instanceof Solution) {

      String moduleFqName = module.getModuleName();
      if (moduleFqName.equals("JDK")) {
        return CORE;
      }
      if (moduleFqName.equals("MPS.Core")) {
        return CORE;
      }
      if (moduleFqName.equals("MPS.Editor")) {
        return EDITOR;
      }
      if (moduleFqName.equals("MPS.Workbench")) {
        return WORKBENCH;
      }
      if (moduleFqName.equals("MPS.Classpath")) {
        SNode refTargetRoot = reference.getTargetNode().getContainingRoot();
        if (SNodeOperations.isInstanceOf(
            refTargetRoot, "jetbrains.mps.baseLanguage.structure.Classifier")) {
          String cName =
              SPropertyOperations.getString(
                  SNodeOperations.cast(
                      refTargetRoot, "jetbrains.mps.baseLanguage.structure.Classifier"),
                  "name");
          String modelName = model.getModelName();
          if (findInModule(coreModule, modelName, cName)) {
            return CORE;
          }
          if (findInModule(editorModule, modelName, cName)) {
            return EDITOR;
          }
          return WORKBENCH;
        }
        return OTHER;
      }

      Solution sol = (Solution) module;
      switch (sol.getKind()) {
        case NONE:
          return OTHER;
        case PLUGIN_CORE:
          return CORE;
        case PLUGIN_EDITOR:
          return EDITOR;
        case PLUGIN_OTHER:
          return WORKBENCH;
        default:
      }
    }
    return OTHER;
  }
 public void applyRule(
     final SNode buildSolutionRunner,
     final TypeCheckingContext typeCheckingContext,
     IsApplicableStatus status) {
   final String className =
       BehaviorReflection.invokeVirtual(
           String.class,
           buildSolutionRunner,
           "virtual_getClassName_1350734474210951475",
           new Object[] {});
   final String methodName =
       BehaviorReflection.invokeVirtual(
           String.class,
           buildSolutionRunner,
           "virtual_getMethodName_1350734474210955274",
           new Object[] {});
   SModuleReference moduleReference =
       ModuleReference.parseReference(
           BuildMps_AbstractModule_Behavior.call_getModuleReference_4643216374596368935(
               SLinkOperations.getTarget(
                   buildSolutionRunner,
                   MetaAdapterFactory.getReferenceLink(
                       0x427a473d5177432cL,
                       0x9905bcbceb71b996L,
                       0x39ea87a41cc0827eL,
                       0x54b085b5945c6691L,
                       "solution"))));
   SModule module = GlobalScope.getInstance().resolve(moduleReference);
   if (module != null) {
     for (SModel m : module.getModels()) {
       if (SModelOperations.getModelName(m).equals(module.getModuleName())) {
         SNode classToRun =
             ListSequence.fromList(
                     SModelOperations.roots(
                         m,
                         MetaAdapterFactory.getConcept(
                             0xf3061a5392264cc5L,
                             0xa443f952ceaf5816L,
                             0xf8c108ca66L,
                             "jetbrains.mps.baseLanguage.structure.ClassConcept")))
                 .findFirst(
                     new IWhereFilter<SNode>() {
                       public boolean accept(SNode it) {
                         return SPropertyOperations.getString(
                                 it,
                                 MetaAdapterFactory.getProperty(
                                     0xceab519525ea4f22L,
                                     0x9b92103b95ca8c0cL,
                                     0x110396eaaa4L,
                                     0x110396ec041L,
                                     "name"))
                             .equals(className);
                       }
                     });
         if ((classToRun == null)) {
           continue;
         }
         SNode methodToRun =
             Sequence.fromIterable(
                     ClassConcept_Behavior.call_staticMethods_5292274854859435867(classToRun))
                 .findFirst(
                     new IWhereFilter<SNode>() {
                       public boolean accept(SNode it) {
                         return SPropertyOperations.getString(
                                     it,
                                     MetaAdapterFactory.getProperty(
                                         0xceab519525ea4f22L,
                                         0x9b92103b95ca8c0cL,
                                         0x110396eaaa4L,
                                         0x110396ec041L,
                                         "name"))
                                 .equals(methodName)
                             && SNodeOperations.isInstanceOf(
                                 SLinkOperations.getTarget(
                                     it,
                                     MetaAdapterFactory.getContainmentLink(
                                         0xf3061a5392264cc5L,
                                         0xa443f952ceaf5816L,
                                         0x112670d273fL,
                                         0x112670d886aL,
                                         "visibility")),
                                 MetaAdapterFactory.getConcept(
                                     0xf3061a5392264cc5L,
                                     0xa443f952ceaf5816L,
                                     0x10af9581ff1L,
                                     "jetbrains.mps.baseLanguage.structure.PublicVisibility"))
                             && ListSequence.fromList(
                                     SLinkOperations.getChildren(
                                         it,
                                         MetaAdapterFactory.getContainmentLink(
                                             0xf3061a5392264cc5L,
                                             0xa443f952ceaf5816L,
                                             0xf8cc56b1fcL,
                                             0xf8cc56b1feL,
                                             "parameter")))
                                 .isEmpty();
                       }
                     });
         if ((methodToRun != null)) {
           return;
         }
       }
     }
   }
   {
     MessageTarget errorTarget = new NodeMessageTarget();
     errorTarget = new ReferenceMessageTarget("solution");
     IErrorReporter _reporter_2309309498 =
         typeCheckingContext.reportTypeError(
             buildSolutionRunner,
             "Cannot find public static void "
                 + className
                 + "."
                 + methodName
                 + "() in "
                 + SPropertyOperations.getString(
                     SLinkOperations.getTarget(
                         buildSolutionRunner,
                         MetaAdapterFactory.getReferenceLink(
                             0x427a473d5177432cL,
                             0x9905bcbceb71b996L,
                             0x39ea87a41cc0827eL,
                             0x54b085b5945c6691L,
                             "solution")),
                     MetaAdapterFactory.getProperty(
                         0xceab519525ea4f22L,
                         0x9b92103b95ca8c0cL,
                         0x110396eaaa4L,
                         0x110396ec041L,
                         "name")),
             "r:6869e2b7-2b2d-443c-a462-ce5a9004892e(jetbrains.mps.build.mps.runner.typesystem)",
             "7415565752189086936",
             null,
             errorTarget);
   }
 }
Пример #25
0
 /**
  * Note: here we are interested in the actual status of module. (not {@link
  * ReferenceStorage#resolveRef}) if it has been already disposed but still remains in our graphs
  * (i.e. ClassLoader is not disposed yet [!]), we need to mark it invalid
  */
 private boolean isModuleDisposed(SModuleReference mRef) {
   SModule resolvedModule = mRef.resolve(myRepository);
   return (resolvedModule == null || resolvedModule.getRepository() == null);
 }
 public void applyRule(
     final SNode classifier,
     final TypeCheckingContext typeCheckingContext,
     IsApplicableStatus status) {
   if (SNodeOperations.isInstanceOf(
           classifier,
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x1107e0cb103L,
               "jetbrains.mps.baseLanguage.structure.AnonymousClass"))
       || SNodeOperations.isInstanceOf(
           classifier,
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0xfc367070a5L,
               "jetbrains.mps.baseLanguage.structure.EnumClass"))) {
     return;
   }
   if (SNodeOperations.isInstanceOf(
       SLinkOperations.getTarget(
           classifier,
           MetaAdapterFactory.getContainmentLink(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x112670d273fL,
               0x112670d886aL,
               "visibility")),
       MetaAdapterFactory.getConcept(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0x10af9586f0cL,
           "jetbrains.mps.baseLanguage.structure.PrivateVisibility"))) {
     return;
   }
   SModule module = classifier.getModel().getModule();
   GlobalModuleDependenciesManager depManager = new GlobalModuleDependenciesManager(module);
   Collection<SModule> deps =
       depManager.getModules(GlobalModuleDependenciesManager.Deptype.COMPILE);
   Collection<SModule> depsReexport = depManager.getOnlyReexportModules();
   for (SNode extendedClassifierType :
       Classifier__BehaviorDescriptor.getExtendedClassifierTypes_id1UeCwxlWKny.invoke(
           classifier)) {
     SNode extendedClassifier =
         SLinkOperations.getTarget(
             extendedClassifierType,
             MetaAdapterFactory.getReferenceLink(
                 0xf3061a5392264cc5L,
                 0xa443f952ceaf5816L,
                 0x101de48bf9eL,
                 0x101de490babL,
                 "classifier"));
     if (extendedClassifier
         == SNodeOperations.getNode(
             "6354ebe7-c22a-4a0f-ac54-50b52ab9b065/java:java.lang(JDK/)", "~Object")) {
       continue;
     }
     SModule classifierModule = extendedClassifier.getModel().getModule();
     assert classifierModule != null;
     if (deps.contains(classifierModule) && !(depsReexport.contains(classifierModule))) {
       {
         MessageTarget errorTarget = new NodeMessageTarget();
         IErrorReporter _reporter_2309309498 =
             typeCheckingContext.reportWarning(
                 classifier,
                 "Usages of this classifier outside of '"
                     + module.getModuleName()
                     + "' module requires setting 'Export' flag for the dependency on '"
                     + classifierModule.getModuleName()
                     + "' module",
                 "r:00000000-0000-4000-0000-011c895902c5(jetbrains.mps.baseLanguage.typesystem)",
                 "9721774220123915",
                 null,
                 errorTarget);
         {
           BaseQuickFixProvider intentionProvider =
               new BaseQuickFixProvider(
                   "jetbrains.mps.baseLanguage.typesystem.PutReexportForExtendedClassifier_QuickFix",
                   false);
           intentionProvider.putArgument("module", ((AbstractModule) module));
           intentionProvider.putArgument("moduleToImport", classifierModule);
           _reporter_2309309498.addIntentionProvider(intentionProvider);
         }
       }
     }
   }
 }
Пример #27
0
  private List<DepLink> dependencies(DependencyUtil.Role role, SModuleReference moduleRef) {
    List<DepLink> result = ListSequence.fromList(new ArrayList<DepLink>());
    SModule module = moduleRef.resolve(myRepo);
    ModuleDescriptor descr = ((AbstractModule) module).getModuleDescriptor();
    if (descr == null) {
      return result;
    }
    switch (role) {
      case OwnedGenerator:
      case None:
        // first step
        addDeps(
            result,
            descr.getUsedDevkits(),
            DependencyUtil.Role.UsedDevkit,
            DependencyUtil.LinkType.UsesDevkit);
        for (SLanguage lang : module.getUsedLanguages()) {
          SModule langModule = lang.getSourceModule();
          if (langModule != null) {
            ListSequence.fromList(result)
                .addElement(
                    new DepLink(
                        langModule.getModuleReference(),
                        DependencyUtil.Role.UsedLanguage,
                        DependencyUtil.LinkType.UsesLanguage));
          }
        }
        for (SDependency dep : module.getDeclaredDependencies()) {
          switch (dep.getScope()) {
            case EXTENDS:
              SModule t = dep.getTarget();
              if (t instanceof Language) {
                ListSequence.fromList(result)
                    .addElement(
                        new DepLink(
                            dep.getTargetModule(),
                            DependencyUtil.Role.RegularDependency,
                            DependencyUtil.LinkType.ExtendsLanguage));
              } else if (t instanceof Generator) {
                ListSequence.fromList(result)
                    .addElement(
                        new DepLink(
                            dep.getTargetModule(),
                            DependencyUtil.Role.RegularDependency,
                            DependencyUtil.LinkType.ExtendsGenerator));
              } else {
                // just in case module could not be resolved
                ListSequence.fromList(result)
                    .addElement(
                        new DepLink(
                            dep.getTargetModule(),
                            DependencyUtil.Role.RegularDependency,
                            DependencyUtil.LinkType.Depends));
              }
              break;
            case DESIGN:
              ListSequence.fromList(result)
                  .addElement(
                      new DepLink(
                          dep.getTargetModule(),
                          DependencyUtil.Role.RegularDependency,
                          DependencyUtil.LinkType.Depends));
              break;
            case RUNTIME:
              ListSequence.fromList(result)
                  .addElement(
                      new DepLink(
                          dep.getTargetModule(),
                          DependencyUtil.Role.RuntimeDependency,
                          DependencyUtil.LinkType.Depends));
              break;
            default:
              ListSequence.fromList(result)
                  .addElement(
                      new DepLink(
                          dep.getTargetModule(),
                          DependencyUtil.Role.RegularDependency,
                          (dep.isReexport()
                              ? DependencyUtil.LinkType.ReexportsDep
                              : DependencyUtil.LinkType.Depends)));
          }
        }
        if (module instanceof Language) {
          // generators and generators dependencies are now also added to language dependencies
          // (MPS-15883)
          for (Generator g : ((Language) module).getGenerators()) {
            ListSequence.fromList(result)
                .addElement(
                    new DepLink(
                        g.getModuleReference(),
                        DependencyUtil.Role.OwnedGenerator,
                        DependencyUtil.LinkType.Generator));
          }
        }
        if (module instanceof Generator) {
          Language srcLang = ((Generator) module).getSourceLanguage();
          ListSequence.fromList(result)
              .addElement(
                  new DepLink(
                      srcLang.getModuleReference(),
                      DependencyUtil.Role.SourceLanguage,
                      DependencyUtil.LinkType.GeneratorLanguage));
        }
        break;

      case UsedDevkit:
        // explicit use of devkit
      case DependencyDevkit:
        DevkitDescriptor devkit = as_he47wm_a0a0a3e0g(descr, DevkitDescriptor.class);
        if (devkit == null) {
          break;
        }
        boolean direct = role == DependencyUtil.Role.UsedDevkit;
        addDeps(
            result,
            devkit.getExtendedDevkits(),
            (direct ? DependencyUtil.Role.UsedDevkit : DependencyUtil.Role.DependencyDevkit),
            DependencyUtil.LinkType.ExtendsDevkit);
        addDeps(
            result,
            devkit.getExportedLanguages(),
            (direct ? DependencyUtil.Role.UsedLanguage : DependencyUtil.Role.DependencyLanguage),
            DependencyUtil.LinkType.ExportsLanguage);
        addDeps(
            result,
            devkit.getExportedSolutions(),
            (direct
                ? DependencyUtil.Role.RegularDependency
                : DependencyUtil.Role.RuntimeDependency),
            DependencyUtil.LinkType.ExportsSolution);
        break;

      case UsedLanguage:
        LanguageDescriptor lang = as_he47wm_a0a0a4e0g(descr, LanguageDescriptor.class);
        if (lang == null) {
          break;
        }
        addDeps(
            result,
            lang.getExtendedLanguages(),
            DependencyUtil.Role.UsedLanguage,
            DependencyUtil.LinkType.ExtendsLanguage);
        if (myNeedRuntime) {
          addDeps(
              result,
              lang.getRuntimeModules(),
              DependencyUtil.Role.RuntimeDependency,
              DependencyUtil.LinkType.ExportsRuntime);
        }
        break;

      case RegularDependency:
        addDeps(
            result,
            getReexportDeps(descr),
            DependencyUtil.Role.RegularDependency,
            DependencyUtil.LinkType.ReexportsDep);
        if (descr instanceof LanguageDescriptor) {
          addDeps(
              result,
              (as_he47wm_a0a1a0a1a5e0g(descr, LanguageDescriptor.class)).getExtendedLanguages(),
              DependencyUtil.Role.RegularDependency,
              DependencyUtil.LinkType.ExtendsLanguage);
        }
        if (myNeedRuntime) {
          addDeps(
              result,
              getNonreexportDeps(descr),
              DependencyUtil.Role.RuntimeDependency,
              DependencyUtil.LinkType.Depends);
          addDeps(
              result,
              descr.getUsedLanguages(),
              DependencyUtil.Role.DependencyLanguage,
              DependencyUtil.LinkType.UsesLanguage);
          addDeps(
              result,
              descr.getUsedDevkits(),
              DependencyUtil.Role.DependencyDevkit,
              DependencyUtil.LinkType.UsesDevkit);
        }
        break;

      case RuntimeDependency:
        if (myNeedRuntime) {
          addDeps(
              result,
              getReexportDeps(descr),
              DependencyUtil.Role.RuntimeDependency,
              DependencyUtil.LinkType.ReexportsDep);
          addDeps(
              result,
              getNonreexportDeps(descr),
              DependencyUtil.Role.RuntimeDependency,
              DependencyUtil.LinkType.Depends);
          addDeps(
              result,
              descr.getUsedLanguages(),
              DependencyUtil.Role.DependencyLanguage,
              DependencyUtil.LinkType.UsesLanguage);
          addDeps(
              result,
              descr.getUsedDevkits(),
              DependencyUtil.Role.DependencyDevkit,
              DependencyUtil.LinkType.UsesDevkit);
          if (descr instanceof LanguageDescriptor) {
            addDeps(
                result,
                (as_he47wm_a0a1a0a4a0a6e0g(descr, LanguageDescriptor.class)).getExtendedLanguages(),
                DependencyUtil.Role.RuntimeDependency,
                DependencyUtil.LinkType.ExtendsLanguage);
          }
          if (descr instanceof GeneratorDescriptor) {
            GeneratorDescriptor gen = (GeneratorDescriptor) descr;
            // generator languages are now also dependencies
            addDeps(
                result,
                gen.getDepGenerators(),
                DependencyUtil.Role.RuntimeDependency,
                DependencyUtil.LinkType.DependsOnGenerator);
            ListSequence.fromList(result)
                .addElement(
                    new DepLink(
                        (as_he47wm_a0a0a0a0a3a5a0a6e0g(module, Generator.class))
                            .getSourceLanguage()
                            .getModuleReference(),
                        DependencyUtil.Role.RuntimeDependency,
                        DependencyUtil.LinkType.GeneratorLanguage));
          }
        }
        break;

      case SourceLanguage:
        // dependency from generator to its source language
        addDeps(
            result,
            check_he47wm_b0b0h4a6(as_he47wm_a0b0b0h4a6(descr, LanguageDescriptor.class)),
            DependencyUtil.Role.SourceLanguage,
            DependencyUtil.LinkType.ExtendsLanguage);
        addDeps(
            result,
            check_he47wm_b0c0h4a6(as_he47wm_a0b0c0h4a6(descr, LanguageDescriptor.class)),
            DependencyUtil.Role.RuntimeDependency,
            DependencyUtil.LinkType.ExportsRuntime);
        break;

      case DependencyLanguage:
        addDeps(
            result,
            check_he47wm_b0a0i4a6(as_he47wm_a0b0a0i4a6(descr, LanguageDescriptor.class)),
            DependencyUtil.Role.DependencyLanguage,
            DependencyUtil.LinkType.ExtendsLanguage);
        addDeps(
            result,
            check_he47wm_b0b0i4a6(as_he47wm_a0b0b0i4a6(descr, LanguageDescriptor.class)),
            DependencyUtil.Role.RuntimeDependency,
            DependencyUtil.LinkType.ExportsRuntime);
        break;

      default:
    }
    return result;
  }