Пример #1
0
  public void doExecute(@NotNull final AnActionEvent event, final Map<String, Object> _params) {
    try {
      final Wrappers._T<SNode> concept = new Wrappers._T<SNode>();
      ModelAccess.instance()
          .runReadAction(
              new Runnable() {
                public void run() {
                  concept.value =
                      SNodeOperations.getAncestor(
                          ((SNode) MapSequence.fromMap(_params).get("target")),
                          "jetbrains.mps.lang.structure.structure.AbstractConceptDeclaration",
                          false,
                          false);
                }
              });
      if ((concept.value == null)) {
        return;
      }

      final SNode targetConcept =
          MoveUpDialog.getConcept(
              ((MPSProject) MapSequence.fromMap(_params).get("project")).getProject(),
              ((SNode) MapSequence.fromMap(_params).get("target")),
              "property");
      if (targetConcept == null) {
        return;
      }
      ModelAccess.instance()
          .runReadInEDT(
              new Runnable() {
                public void run() {
                  SNode node = ((SNode) ((SNode) MapSequence.fromMap(_params).get("target")));
                  if (!(node.getModel() != null)
                      || jetbrains.mps.util.SNodeOperations.isDisposed(
                          ((SNode) ((SNode) MapSequence.fromMap(_params).get("target"))))) {
                    return;
                  }
                  SNode node1 = ((SNode) targetConcept);
                  if (!(node1.getModel() != null)
                      || jetbrains.mps.util.SNodeOperations.isDisposed(((SNode) targetConcept))) {
                    return;
                  }

                  RefactoringAccess.getInstance()
                      .getRefactoringFacade()
                      .execute(
                          RefactoringContext.createRefactoringContextByName(
                              "jetbrains.mps.lang.structure.refactorings.MovePropertyUp",
                              Arrays.asList("targetConcept"),
                              Arrays.asList(targetConcept),
                              ((SNode) MapSequence.fromMap(_params).get("target")),
                              ((MPSProject) MapSequence.fromMap(_params).get("project"))));
                }
              });

    } catch (Throwable t) {
      LOG.error("User's action execute method failed. Action:" + "MoveProperyUp", t);
    }
  }
 public static void call_setupSelection_6268941039745707957(
     final SNode thisNode,
     final NodeEditorComponent nodeEditorComponent,
     final SNode node,
     final Map<SNode, SNode> map) {
   final Wrappers._T<EditorComponent> editorComponent =
       new Wrappers._T<EditorComponent>(nodeEditorComponent);
   final Wrappers._T<EditorCell> cellWithId = new Wrappers._T<EditorCell>();
   ModelAccess.instance()
       .runReadAction(
           new Runnable() {
             public void run() {
               if (SPropertyOperations.getBoolean(thisNode, "isInInspector")) {
                 editorComponent.value =
                     AnonymousCellAnnotation_Behavior.call_setupInspector_5681471431307922086(
                         thisNode, node, nodeEditorComponent);
               }
               cellWithId.value =
                   editorComponent.value.findCellWithId(
                       node, SPropertyOperations.getString(thisNode, "cellId"));
               if (cellWithId.value == null) {
                 throw new RuntimeException("No cell " + thisNode);
               }
               AnonymousCellAnnotation_Behavior.call_setupCaretAndSelection_9114978211826243747(
                   thisNode, cellWithId.value);
             }
           });
   editorComponent.value.changeSelection(cellWithId.value);
   ModelAccess.instance()
       .runReadAction(
           new Runnable() {
             public void run() {
               if (SLinkOperations.getTarget(thisNode, "nodeRangeSelectionStart", false) != null) {
                 SNode selectionStart =
                     MapSequence.fromMap(map)
                         .get(
                             SLinkOperations.getTarget(
                                 thisNode, "nodeRangeSelectionStart", false));
                 SNode selectionEnd =
                     MapSequence.fromMap(map)
                         .get(SLinkOperations.getTarget(thisNode, "nodeRangeSelectionEnd", false));
                 SelectionManager selectionManager = editorComponent.value.getSelectionManager();
                 selectionManager.pushSelection(
                     selectionManager.createRangeSelection(selectionStart, selectionEnd));
               }
             }
           });
 }
Пример #3
0
 public void doExecute(@NotNull final AnActionEvent event, final Map<String, Object> _params) {
   try {
     NewSolutionDialog dialog =
         new NewSolutionDialog(((Frame) MapSequence.fromMap(_params).get("frame")));
     dialog.setProject(((MPSProject) MapSequence.fromMap(_params).get("project")));
     dialog.show();
     final Solution s = dialog.getResult();
     if (s == null) {
       return;
     }
     ModelAccess.instance()
         .runWriteAction(
             new Runnable() {
               public void run() {
                 ((StandaloneMPSProject)
                         ((MPSProject) MapSequence.fromMap(_params).get("project")))
                     .setFolderFor(
                         s,
                         (((String) MapSequence.fromMap(_params).get("namespace")) == null
                             ? ""
                             : ((String) MapSequence.fromMap(_params).get("namespace"))));
               }
             });
     ProjectPane projectPane =
         ProjectPane.getInstance(((Project) MapSequence.fromMap(_params).get("ideaProject")));
     projectPane.rebuildTree();
     projectPane.selectModule(s, false);
   } catch (Throwable t) {
     LOG.error("User's action execute method failed. Action:" + "NewSolution", t);
   }
 }
Пример #4
0
  private Iterable<SModule> loadModule(String modulePath) {
    final List<ModulesMiner.ModuleHandle> collectModules =
        ModulesMiner.getInstance()
            .collectModules(FileSystem.getInstance().getFileByPath(modulePath), false);

    if (collectModules.isEmpty()) {
      return ListSequence.fromList(new ArrayList<SModule>());
    }

    return ModelAccess.instance()
        .runWriteAction(
            new Computable<List<SModule>>() {
              public List<SModule> compute() {
                List<SModule> modules = new ArrayList<SModule>();
                BaseMPSModuleOwner owner = new BaseMPSModuleOwner() {};
                for (ModulesMiner.ModuleHandle moduleHandle : collectModules) {
                  SModule module = ModuleRepositoryFacade.createModule(moduleHandle, owner);
                  if (module != null) {
                    modules.add(module);
                  }
                }
                CleanupManager.getInstance().cleanup();
                ClassLoaderManager.getInstance().reloadAll(new EmptyProgressMonitor());
                return modules;
              }
            });
  }
Пример #5
0
 @Override
 protected RunnerAndConfigurationSettings createConfigurationByElement(
     Location location, ConfigurationContext context) {
   myContext = context;
   if (!((location instanceof MPSLocation))) {
     return null;
   }
   MPSLocation mpsLocation = (MPSLocation) location;
   final MPSPsiElement psiElement = mpsLocation.getPsiElement();
   RunConfiguration config =
       ModelAccess.instance()
           .runReadAction(
               new Computable<RunConfiguration>() {
                 @Override
                 public RunConfiguration compute() {
                   Object mpsItem = psiElement.getMPSItem();
                   if (mpsItem == null) {
                     return null;
                   }
                   if (!(isApplicable(mpsItem))) {
                     return null;
                   }
                   return doCreateConfiguration((T) psiElement.getMPSItem());
                 }
               });
   if (config == null) {
     return null;
   }
   return new RunnerAndConfigurationSettingsImpl(
       RunManagerImpl.getInstanceImpl(location.getProject()), config, false);
 }
Пример #6
0
    public void deleteElement(DataContext dataContext) {
      final VirtualFile[] files = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
      if (files == null || files.length == 0) return;

      String message = createConfirmationMessage(files);
      int returnValue = Messages.showYesNoDialog(message, "Delete", Messages.getQuestionIcon());
      if (returnValue != 0) return;

      Arrays.sort(files, FileComparator.getInstance());

      ModelAccess.instance()
          .runWriteAction(
              new Runnable() {
                public void run() {
                  for (final VirtualFile file : files) {
                    try {
                      file.delete(this);
                    } catch (IOException e) {
                      ApplicationManager.getApplication()
                          .invokeLater(
                              new Runnable() {
                                public void run() {
                                  Messages.showMessageDialog(
                                      "Could not erase file or folder: " + file.getName(),
                                      "Error",
                                      Messages.getErrorIcon());
                                }
                              });
                    }
                  }
                }
              });
    }
Пример #7
0
 static boolean substituteIfPossible(
     EditorCell cell,
     boolean canActivatePopup,
     final String pattern,
     List<SubstituteAction> matchingActions) {
   if (matchingActions.size() == 0 && canActivatePopup) {
     return false;
   }
   if (matchingActions.size() != 1) {
     if (canActivatePopup) {
       ((EditorComponent) cell.getEditorComponent()).activateNodeSubstituteChooser(cell, false);
     } else {
       return false;
     }
     return true;
   }
   final SubstituteAction action = matchingActions.get(0);
   Boolean canSubstitute =
       ModelAccess.instance()
           .runReadAction(
               new Computable<Boolean>() {
                 @Override
                 public Boolean compute() {
                   return action.canSubstitute(pattern);
                 }
               });
   if (canSubstitute) {
     action.substitute(cell.getContext(), pattern);
     return true;
   } else {
     return false;
   }
 }
Пример #8
0
  public static boolean validate(
      final EditorCell cell, final boolean strict, final boolean canActivatePopup) {
    final SubstituteInfo substituteInfo = cell.getSubstituteInfo();
    if (substituteInfo == null) {
      return false;
    }

    if (cell instanceof EditorCell_Collection) {
      return false;
    }
    final String pattern = cell.renderText().getText();

    if (pattern.equals("")) return false;

    List<SubstituteAction> matchingActions =
        ModelAccess.instance()
            .runReadAction(
                new Computable<List<SubstituteAction>>() {
                  @Override
                  public List<SubstituteAction> compute() {
                    return TypeContextManager.getInstance()
                        .runTypeCheckingComputation(
                            (ITypeContextOwner) cell.getEditorComponent(),
                            cell.getEditorComponent().getEditedNode(),
                            new Computation<List<SubstituteAction>>() {
                              @Override
                              public List<SubstituteAction> compute(TypeCheckingContext context) {
                                return substituteInfo.getMatchingActions(pattern, strict);
                              }
                            });
                  }
                });
    return substituteIfPossible(cell, canActivatePopup, pattern, matchingActions);
  }
 @Override
 @NotNull
 public FileEditor createEditor(@NotNull Project project, @NotNull final VirtualFile file) {
   MPSNodeVirtualFile mpsNodeVirtualFile =
       file instanceof MPSNodeVirtualFile
           ? (MPSNodeVirtualFile) file
           : ModelAccess.instance()
               .runReadAction(
                   new Computable<MPSNodeVirtualFile>() {
                     @Override
                     public MPSNodeVirtualFile compute() {
                       SModel descr =
                           SModelFileTracker.getInstance()
                               .findModel(VirtualFileUtils.toIFile(file.getParent()));
                       if (descr != null) {
                         for (SNode node : descr.getRootNodes()) {
                           if (node.getName().equals(file.getNameWithoutExtension())) {
                             return MPSNodesVirtualFileSystem.getInstance().getFileFor(node);
                           }
                         }
                       }
                       return null;
                     }
                   });
   return mpsNodeVirtualFile != null
       ? new MPSFileNodeEditor(project, mpsNodeVirtualFile)
       : new MPSFileNodeEditor(project, file);
 }
Пример #10
0
  public final void update(final AnActionEvent e) {
    super.update(e);

    ActionPlace place = e.getData(MPSDataKeys.PLACE);

    if (e.getInputEvent() instanceof KeyEvent) {
      if (!getPlaces().contains(null)) {
        if (!getPlaces().contains(place)) {
          disable(e.getPresentation());
          return;
        }
      }
    }

    // TODO rewrite! do not start read action in EDT directly (to avoid UI freeze)
    ModelAccess.instance()
        .runReadAction(
            new Runnable() {
              public void run() {
                if (myDisableOnNoProject && e.getData(PlatformDataKeys.PROJECT) == null) {
                  disable(e.getPresentation());
                  return;
                }
                THashMap<String, Object> params = new THashMap<String, Object>();
                if (!collectActionData(e, params)) {
                  disable(e.getPresentation());
                  return;
                }
                doUpdate(e, params);
              }
            });
  }
  @Override
  public TraceablePositionInfo getTargetCodePosition() {
    TraceablePositionInfo statementPositionInfo = getTargetCodePosition(getNodePointer());
    if (statementPositionInfo != null) {
      return statementPositionInfo;
    }

    final SNode statement = getNodePointer().getNode();
    if (statement == null) {
      return null;
    }

    return ModelAccess.instance()
        .tryRead(
            new Computable<TraceablePositionInfo>() {
              @Override
              public TraceablePositionInfo compute() {
                SNode statementList = statement.getParent();

                // Check if out statement is the first statement in the list
                if (statementList.getChildAt(0) == statement) {
                  // Return target code position for the statement list
                  return getTargetCodePosition(new SNodePointer(statementList));
                }

                return null;
              }
            });
  }
Пример #12
0
 private void rehighlightFeatureAndDescendants(@NotNull final Feature feature) {
   ModelAccess.instance()
       .runReadAction(
           new Runnable() {
             public void run() {
               synchronized (myFeaturesHolder) {
                 rehighlightFeature(feature);
                 SModelReference modelRef = feature.getModelReference();
                 for (Feature anotherFeature :
                     ListSequence.fromList(
                         myFeaturesHolder.getFeaturesByModelReference(modelRef))) {
                   if (Sequence.fromIterable(Sequence.fromArray(anotherFeature.getAncestors()))
                       .any(
                           new IWhereFilter<Feature>() {
                             public boolean accept(Feature a) {
                               return feature.equals(a);
                             }
                           })) {
                     rehighlightFeature(anotherFeature);
                   }
                 }
               }
             }
           });
 }
Пример #13
0
  public TransientModelsModule getModule(final IModule module) {
    TransientModelsModule transientModelsModule =
        ModelAccess.instance()
            .requireRead(
                new Computable<TransientModelsModule>() {
                  @Override
                  public TransientModelsModule compute() {
                    if (myModuleMap.containsKey(module)) {
                      return myModuleMap.get(module);
                    }

                    final TransientModelsModule transientModelsModule =
                        new TransientModelsModule(module, TransientModelsComponent.this);
                    // later
                    ModelAccess.instance()
                        .runWriteInEDT(
                            new Runnable() {
                              @Override
                              public void run() {
                                transientModelsModule.initModule();
                              }
                            });
                    myModuleMap.put(module, transientModelsModule);
                    return transientModelsModule;
                  }
                });
    return transientModelsModule;
  }
Пример #14
0
    @Override
    protected List<SNodeDescriptor> computeValue(@NotNull final FileContent inputData) {
      final List<SNodeDescriptor> descriptors = new ArrayList<SNodeDescriptor>();
      ModelAccess.instance()
          .runIndexing(
              new Runnable() {
                @Override
                public void run() {
                  try {
                    SModel model = doModelParsing(inputData);

                    for (final SNode node : getRootsToIterate(model)) {
                      String persistentName =
                          node.getProperty(SNodeUtil.property_INamedConcept_name);
                      String nodeName = (persistentName == null) ? "null" : persistentName;
                      String conceptFqName = node.getConcept().getQualifiedName();
                      SModelReference modelRef = model.getReference();
                      SNodeId id = node.getNodeId();
                      SNodeDescriptor value =
                          SNodeDescriptor.fromModelReference(nodeName, conceptFqName, modelRef, id);
                      descriptors.add(value);
                    }
                  } catch (Exception e) {
                    LOG.error(
                        "Cannot index model file "
                            + inputData.getFileName()
                            + "; "
                            + e.getMessage());
                  }
                }
              });
      return descriptors;
    }
Пример #15
0
  public DefaultCellInfo(final EditorCell cell) {
    ModelAccess.instance()
        .runReadAction(
            new Runnable() {
              @Override
              public void run() {
                SNode node = cell.getSNode();
                if (node == null || node.getModel() == null) {
                  myNodeReference = null;
                } else {
                  myNodeReference = node.getReference();
                }
              }
            });

    myCellId = cell.getCellId();

    EditorCell_Collection parent = (EditorCell_Collection) cell.getParent();
    if (parent != null && myCellId == null) {
      myParentInfo = parent.getCellInfo();
      myIsInList = parent.hasCellListHandler();
      if (myIsInList || myCellId == null) {
        myCellNumber = parent.getCellNumber(cell);
      }
    }
  }
Пример #16
0
  public static List<ModelRootManager> getManagers() {
    final List<ModelRootManager> result = ListSequence.fromList(new ArrayList<ModelRootManager>());
    ModelAccess.instance()
        .runReadAction(
            new Runnable() {
              public void run() {
                for (SNode node : ListSequence.fromList(getManagerNodes())) {
                  Language language =
                      Language.getLanguageFor(SNodeOperations.getModel(node).getModelDescriptor());

                  ModelRootManager manager =
                      new ModelRootManager(
                          SNodeOperations.getModel(node)
                              .getModelDescriptor()
                              .getModule()
                              .getModuleDescriptor()
                              .getId()
                              .toString(),
                          SNodeOperations.getModel(node).getLongName()
                              + "."
                              + NameUtil.toValidIdentifier(
                                  SPropertyOperations.getString(node, "name")));

                  ListSequence.fromList(result).addElement(manager);
                }
              }
            });

    // default
    ListSequence.fromList(result).addElement(null);

    return result;
  }
  private void openRule(String ruleModel, final String ruleID) {
    if (ruleModel == null || ruleID == null) return;
    final SModelReference modelUID =
        PersistenceFacade.getInstance().createModelReference(ruleModel);
    final SModel modelDescriptor =
        SModelRepository.getInstance()
            .getModelDescriptor(SModelStereotype.withoutStereotype(modelUID.getModelName()));
    if (modelDescriptor == null) {
      LOG.error("can't find rule's model " + ruleModel);
      return;
    }

    ModelAccess.instance()
        .runWriteInEDT(
            new Runnable() {
              @Override
              public void run() {
                jetbrains.mps.smodel.SNodeId nodeId =
                    jetbrains.mps.smodel.SNodeId.fromString(ruleID);
                assert nodeId != null : "wrong node id string";
                SNode rule = modelDescriptor.getNode(nodeId);
                if (rule == null) {
                  LOG.error(
                      "can't find rule with id " + ruleID + " in the model " + modelDescriptor);
                  return;
                }
                NavigationSupport.getInstance()
                    .openNode(
                        myOperationContext,
                        rule,
                        true,
                        !(rule.getModel() != null && rule.getParent() == null));
              }
            });
  }
Пример #18
0
 public boolean hasFailedTests() {
   for (final ITestNodeWrapper testCase :
       SetSequence.fromSet(MapSequence.fromMap(this.myState.getTestsMap()).keySet())) {
     if (testCase == null) {
       continue;
     }
     for (final ITestNodeWrapper method :
         ListSequence.fromList(MapSequence.fromMap(this.myState.getTestsMap()).get(testCase))) {
       final Wrappers._T<String> className = new Wrappers._T<String>();
       final Wrappers._T<String> methodName = new Wrappers._T<String>();
       ModelAccess.instance()
           .runReadAction(
               new Runnable() {
                 public void run() {
                   className.value = testCase.getFqName();
                   methodName.value = method.getName();
                 }
               });
       TestMethodTreeNode treeNode = this.myMap.get(className.value, methodName.value);
       if (method == null) {
         continue;
       }
       if (!(isPassed(treeNode))) {
         return true;
       }
     }
   }
   return false;
 }
Пример #19
0
 public void loadState(Element state) {
   synchronized (myBreakpoints) {
     clear();
     List breakpointsElement = state.getChildren();
     for (ListIterator it = breakpointsElement.listIterator(); it.hasNext(); ) {
       Element breakpointElement = (Element) it.next();
       try {
         IBreakpoint breakpoint = myBreakpointsIO.readBreakpoint(breakpointElement);
         if (breakpoint != null) {
           myBreakpoints.add(breakpoint);
         } else {
           myUnreadBreakpoints.add(breakpointElement);
         }
       } catch (Throwable t) {
         LOG.error("Error while loading breakpoint from " + breakpointElement, t);
       }
     }
   }
   ModelAccess.instance()
       .runReadAction(
           new Runnable() {
             @Override
             public void run() {
               synchronized (myBreakpoints) {
                 for (IBreakpoint breakpoint : myBreakpoints) {
                   if (breakpoint instanceof ILocationBreakpoint) {
                     addLocationBreakpoint((ILocationBreakpoint) breakpoint);
                   }
                 }
               }
             }
           });
 }
Пример #20
0
  /**
   * We can use this method to determine if we should redispatch insert event to the corresponding
   * child collection below the cell returned from cell.getPrevLeaf() or we should go on and insert
   * prev. child into a collection containing cell itself
   *
   * @return true if we should redispatch insert event to the prev. leaft cell
   */
  private static boolean hasSingleRolesAtLeftBoundary(EditorCell cell) {
    if (!(hasSingleRole(cell))) {
      return false;
    }

    if (isOnLeftBoundary(cell)) {
      final EditorCell_Collection parentCell = cell.getParent();
      if (parentCell != null) {
        final EditorCell prevLeaf = APICellAdapter.getPrevLeaf(cell);
        if (prevLeaf != null) {
          final Wrappers._boolean ancestor = new Wrappers._boolean(false);
          ModelAccess.instance()
              .runReadAction(
                  new Runnable() {
                    public void run() {
                      ancestor.value =
                          SNodeOperations.isAncestor(parentCell.getSNode(), prevLeaf.getSNode());
                    }
                  });
          if (ancestor.value) {
            return true;
          }
        }
        return hasSingleRolesAtLeftBoundary((jetbrains.mps.nodeEditor.cells.EditorCell) parentCell);
      }
    }
    return true;
  }
Пример #21
0
 public static boolean canBeMoved(final List<SNode> nodesToMove) {
   if (ListSequence.fromList(nodesToMove).isEmpty()) {
     return false;
   }
   final Wrappers._boolean result = new Wrappers._boolean();
   ModelAccess.instance()
       .runReadAction(
           new Runnable() {
             public void run() {
               SNode firstNode = ListSequence.fromList(nodesToMove).first();
               final SContainmentLink containmentLink = firstNode.getContainmentLink();
               final SNode parent = firstNode.getParent();
               final SModel model = firstNode.getModel();
               result.value =
                   ListSequence.fromList(nodesToMove)
                       .all(
                           new IWhereFilter<SNode>() {
                             public boolean accept(SNode it) {
                               return eq_92fyi8_a0a0a0a0a0a0a4a0a0a0a2a8(
                                       it.getContainmentLink(), containmentLink)
                                   && it.getParent() == parent
                                   && it.getModel() == model;
                             }
                           });
             }
           });
   return result.value;
 }
Пример #22
0
  public static boolean testRefactoringTestEnvironment(File projectDirectory) {
    IdeMain.setTestMode(TestMode.CORE_TEST);
    TestMain.configureMPS();
    final Project project = loadProject(new File(projectDirectory, REFACTORING_PROJECT));

    final boolean[] b = new boolean[] {true};
    ModelAccess.instance()
        .runReadAction(
            new Runnable() {
              public void run() {
                b[0] =
                    getModel(project, REFACTORING_SANDBOX[0]) != null
                        && getModel(project, REFACTORING_SANDBOX[1]) != null
                        && getLanguage(project, REFACTORING_LANGUAGE[0]) != null
                        && getLanguage(project, REFACTORING_LANGUAGE[1]) != null;
              }
            });

    ThreadUtils.runInUIThreadNoWait(
        new Runnable() {
          public void run() {
            project.dispose();
          }
        });
    return b[0];
  }
Пример #23
0
 @Override
 public SearchResults doGetResults(
     final SearchQuery query, @NotNull final ProgressMonitor monitor) {
   monitor.start(getTaskName() + " started", 5);
   try {
     final SearchResults[] results = new SearchResults[1];
     ModelAccess.instance()
         .runReadAction(
             new Runnable() {
               @Override
               public void run() {
                 SearchResults childRes = myChildren.get(0).getResults(query, monitor.subTask(4));
                 monitor.advance(0);
                 try {
                   results[0] = myFilter.filter(childRes);
                   monitor.advance(1);
                 } catch (Throwable t) {
                   LOG.error(t.getMessage(), t);
                   results[0] = childRes;
                 }
               }
             });
     return results[0];
   } finally {
     monitor.done();
   }
 }
Пример #24
0
 public static void showRootDifference(
     Project project,
     final SModel oldModel,
     final SModel newModel,
     final SNodeId rootId,
     String oldTitle,
     String newTitile,
     @Nullable final Bounds scrollTo,
     DiffRequest diffRequest) {
   final ModelDifferenceDialog dialog =
       new ModelDifferenceDialog(project, oldModel, newModel, oldTitle, newTitile, diffRequest);
   dialog.setCurrentRoot(rootId);
   dialog.closeTreeComponent();
   if (rootId == null) {
     dialog.setTitle("Metadata difference for model");
   } else {
     ModelAccess.instance()
         .runReadAction(
             new Runnable() {
               public void run() {
                 SNode node = newModel.getNode(rootId);
                 if (node == null) {
                   node = oldModel.getNode(rootId);
                 }
                 String rootName = (node == null ? "root" : node.getPresentation());
                 dialog.setTitle("Difference for " + rootName);
                 dialog.myRootDifferencePane.navigateInitial(scrollTo);
               }
             });
   }
   dialog.show();
 }
Пример #25
0
 public SolutionIdea(@NotNull Module module, SolutionDescriptor descriptor) {
   super(descriptor, null);
   myModule = module;
   // TODO: simply set solution descriptor local variable?
   setModuleDescriptor(descriptor);
   myConnection = myModule.getProject().getMessageBus().connect();
   myConnection.subscribe(ProjectTopics.PROJECT_ROOTS, new MyModuleRootListener());
   myConnection.subscribe(FacetManager.FACETS_TOPIC, new MyFacetManagerAdapter());
   final ProjectLibraryTable projectLibraryTable =
       (ProjectLibraryTable) ProjectLibraryTable.getInstance(myModule.getProject());
   ModelAccess.instance()
       .runReadAction(
           new Runnable() {
             @Override
             public void run() {
               for (final Library library : projectLibraryTable.getLibraries()) {
                 if (ModuleLibraryType.isModuleLibrary(library)) {
                   library.getRootProvider().addRootSetChangedListener(myRootSetListener);
                 }
               }
               for (SModel model : getModels()) {
                 ((SModelInternal) model).addModelListener(MODEL_RUNTIME_IMPORTER);
               }
             }
           });
   projectLibraryTable.addListener(myLibrariesListener);
   addModuleListener(myModule.getProject().getComponent(PsiModelReloadListener.class));
   addModuleListener(MODULE_RUNTIME_IMPORTER);
 }
Пример #26
0
  @Nullable
  /*package*/ SNode getTypeOf(final SNode node) {
    ModelAccess.assertLegalRead();
    if (node == null) return null;

    if (myTypeChecker.isGenerationMode()) {
      TypeCheckingContext context =
          myTypeChecker.hasPerformanceTracer()
              ? new TargetTypecheckingContext_Tracer(node, myTypeChecker)
              : new TargetTypecheckingContext(node, myTypeChecker);
      try {
        return context.getTypeOf_generationMode(node);
      } finally {
        context.dispose();
      }
    }
    // now we are not in generation mode

    final ITypeContextOwner contextOwner = myTypecheckingContextOwner.get();
    TypeCheckingContext context = acquireTypecheckingContext(node, contextOwner);
    if (context == null) {
      return TypesUtil.createRuntimeErrorType();
    }

    try {
      return context.getTypeOf(node, myTypeChecker);
    } finally {
      releaseTypecheckingContext(node, contextOwner);
    }
  }
Пример #27
0
 public void rehighlightAllFeaturesNow() {
   ModelAccess.assertLegalRead();
   synchronized (myFeaturesHolder) {
     for (Feature f : ListSequence.fromList(myFeaturesHolder.getAllModelFeatures())) {
       rehighlightFeatureAndDescendants(f);
     }
   }
 }
Пример #28
0
 public TypeCheckingContext createTypeCheckingContext(SNode node) {
   ModelAccess.assertLegalRead();
   if (myTypeChecker.isGenerationMode()) {
     return new TargetTypecheckingContext(node, myTypeChecker);
   } else {
     return new IncrementalTypecheckingContext(node, myTypeChecker);
   }
 }
Пример #29
0
 public void performAction() {
   ModelAccess.instance()
       .runWriteActionInCommand(
           new Runnable() {
             public void run() {
               myDialog.rollbackChanges(getChangeGroup().getChanges());
             }
           });
 }
Пример #30
0
  public static void assertDeepModelEquals(SModel expectedModel, SModel actualModel) {
    ModelAccess.instance().checkReadAccess();

    assertSameImports(expectedModel, actualModel);
    assertSameModelImports(expectedModel, actualModel);
    assertSameLanguageAspects(expectedModel, actualModel);

    assertSameNodesCollections("root", expectedModel.getRootNodes(), actualModel.getRootNodes());
  }