Exemplo n.º 1
0
    protected void reconcile() {
      if (fDocument != null && fModel != null && fModel.isHandlingDynamicProblems()) {
        IFile file = ((IFileEditorInput) fEditor.getEditorInput()).getFile();
        IProject proj = file.getProject();
        IWorkingCopy[] currRegedWCs = EGLCore.getSharedWorkingCopies(EGLUI.getBufferFactory());
        IEGLElement eglFile = EGLCore.create(file);
        if (eglFile instanceof IEGLFile) {
          String pkgName;
          IPackageFragment packageFragment =
              (IPackageFragment) eglFile.getAncestor(IEGLElement.PACKAGE_FRAGMENT);
          if (packageFragment.isDefaultPackage()) {
            pkgName = "";
          } else {
            pkgName = packageFragment.getElementName();
          }
          ReconcilerProblemRequestorFactory problemFactory =
              new ReconcilerProblemRequestorFactory(file);

          IDocument document = fProvider.getDocument(fEditor.getEditorInput());
          if (document != null) {
            WorkingCopyCompiler.getInstance()
                .compileAllParts(
                    proj,
                    pkgName,
                    file,
                    currRegedWCs,
                    new IWorkingCopyCompileRequestor() {
                      public void acceptResult(WorkingCopyCompilationResult result) {}
                    },
                    problemFactory);

            List reportedProblems = new ArrayList();
            List errors = problemFactory.problemRequestor.getProblems();
            List syntaxErrors = problemFactory.syntaxErrorRequestor.getProblems();

            // create EGLProblemMarker objects from errors
            String filePath = file.getFullPath().toOSString();
            IEditorInput editorInput = fEditor.getEditorInput();
            if (editorInput == null) {
              System.out.println("Null editor input");
            }
            buildProblemList(document, filePath, reportedProblems, syntaxErrors, "SYN");
            buildProblemList(document, filePath, reportedProblems, errors, "VAL");

            fModel.reportProblems(reportedProblems);
          }
        }
      }
    }
Exemplo n.º 2
0
  public int[] moveWidget(
      final int oldContainerOffset,
      final int oldContainerLength,
      final int oldContainerIndex,
      final int newContainerOffset,
      final int newContainerLength,
      final int newContainerIndex) {
    try {
      IEGLFile modelFile = (IEGLFile) EGLCore.create(currentFile);
      IEGLFile sharedWorkingCopy =
          (IEGLFile) modelFile.getSharedWorkingCopy(null, EGLUI.getBufferFactory(), null);
      sharedWorkingCopy.open(null);
      sharedWorkingCopy.reconcile(false, null);

      try {
        final Node oldContainer =
            DocumentUtil.getWidgetNode(currentDocument, oldContainerOffset, oldContainerLength);
        final Node newContainer =
            DocumentUtil.getWidgetNode(currentDocument, newContainerOffset, newContainerLength);
        final int newIndex =
            calculateNewIndex(oldContainer, newContainer, oldContainerIndex, newContainerIndex);
        oldContainer.accept(
            new DefaultASTVisitor() {
              public boolean visit(Handler handler) {
                // Assume this is a RUIHandler
                EGLRUIHandlerLocatorStrategy strategy = new EGLRUIHandlerLocatorStrategy(handler);
                final Node nodeToMove = strategy.locateIndex(oldContainerIndex);
                MoveNodeOperation moveOp =
                    new MoveNodeOperation(
                        oldContainerOffset,
                        oldContainerLength,
                        oldContainerIndex,
                        newContainerOffset,
                        newContainerIndex,
                        newIndex);
                nodeToMove.accept(moveOp);
                return false;
              }

              public boolean visit(final NewExpression newExpression) {
                EGLContainerLocatorStrategy strategy =
                    new EGLContainerLocatorStrategy(oldContainer);
                final Node nodeToMove = strategy.locateIndex(oldContainerIndex);
                MoveNodeOperation moveOp =
                    new MoveNodeOperation(
                        oldContainerOffset,
                        oldContainerLength,
                        oldContainerIndex,
                        newContainerOffset,
                        newContainerIndex,
                        newIndex);
                nodeToMove.accept(moveOp);
                return false;
              }

              public boolean visit(final SimpleName simpleName) {
                EGLContainerLocatorStrategy strategy =
                    new EGLContainerLocatorStrategy(oldContainer);
                final Node nodeToMove = strategy.locateIndex(oldContainerIndex);
                MoveNodeOperation moveOp =
                    new MoveNodeOperation(
                        oldContainerOffset,
                        oldContainerLength,
                        oldContainerIndex,
                        newContainerOffset,
                        newContainerIndex,
                        newIndex);
                nodeToMove.accept(moveOp);
                return false;
              }
            });
      } catch (Exception e) {
        Activator.getDefault()
            .getLog()
            .log(
                new Status(
                    Status.ERROR,
                    Activator.PLUGIN_ID,
                    "Move Widget Reference: Error moving reference",
                    e));
      } finally {
        sharedWorkingCopy.destroy();
      }
    } catch (EGLModelException e) {
      Activator.getDefault()
          .getLog()
          .log(
              new Status(
                  Status.ERROR,
                  Activator.PLUGIN_ID,
                  "Move Widget Reference: Error creating working copy",
                  e));
    }
    return charactersChanged;
  }