@Override
 public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {
   DartX.todo("indent");
   String partitioning = getConfiguredDocumentPartitioning(sourceViewer);
   if (DartPartitions.DART_DOC.equals(contentType)
       || DartPartitions.DART_MULTI_LINE_COMMENT.equals(contentType)) {
     return new IAutoEditStrategy[] {new DartDocAutoIndentStrategy(partitioning)};
   } else if (DartPartitions.DART_MULTI_LINE_STRING.equals(contentType)) {
     return new IAutoEditStrategy[] {
       new SmartSemicolonAutoEditStrategy(partitioning),
       new DartStringAutoIndentStrategy(partitioning)
     };
   } else if (DartPartitions.DART_STRING.equals(contentType)) {
     return new IAutoEditStrategy[] {
       new SmartSemicolonAutoEditStrategy(partitioning),
       new DartStringAutoIndentStrategy(partitioning)
     };
   } else if (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType)) {
     return new IAutoEditStrategy[] {
       new SmartSemicolonAutoEditStrategy(partitioning),
       new DartAutoIndentStrategy(partitioning, getProject(), sourceViewer)
     };
   } else {
     return new IAutoEditStrategy[] {
       new DartAutoIndentStrategy(partitioning, getProject(), sourceViewer)
     };
   }
 }
Exemplo n.º 2
0
  /** Selects a Dart Element in an editor */
  public static void revealInEditor(IEditorPart part, Object element) {
    if (element == null) {
      return;
    }

    // TODO(scheglov) to be removed with method
    //    if (part instanceof DartEditor) {
    //      ((DartEditor) part).setSelection(element);
    //      return;
    //    }

    // Support for non-Dart editor
    try {
      SourceRange range = null;
      DartX.todo();
      if (element instanceof SourceReference) {
        range = ((SourceReference) element).getSourceRange();
      }

      if (range != null) {
        revealInEditor(part, range.getOffset(), range.getLength());
      }
    } catch (DartModelException e) {
      // don't reveal
    }
  }
Exemplo n.º 3
0
  /**
   * Opens the editor currently associated with the given element (DartElement, IFile, IStorage...)
   *
   * @return an open editor or <code>null</code> if an external editor was opened
   * @throws PartInitException if the editor could not be opened or the input element is not valid
   */
  public static IEditorPart openInEditor(Object inputElement, boolean activate)
      throws DartModelException, PartInitException {

    if (inputElement instanceof IFile) {
      return openInEditor((IFile) inputElement, activate);
    }
    DartX.todo();
    if (inputElement instanceof ImportElement) {
      inputElement = ((ImportElement) inputElement).getImportedLibrary();
    }
    if (inputElement instanceof Element) {
      CompilationUnitElement cu = getCompilationUnit((Element) inputElement);
      IWorkbenchPage page = DartToolsPlugin.getActivePage();
      if (cu != null && page != null) {
        IEditorPart editor = page.getActiveEditor();
        if (editor != null) {
          Element editorCU = EditorUtility.getEditorInputDartElement2(editor, false);
          if (cu.equals(editorCU)) {
            if (activate && page.getActivePart() != editor) {
              page.activate(editor);
            }
            return editor;
          }
        }
      }
    }

    IEditorInput input = getEditorInput(inputElement);

    if (input == null) {
      return null;
    }

    return openInEditor(input, getEditorID(input), activate);
  }
 static DartNode[] getSiblingNodes(DartNode node) {
   DartX.notYet();
   // DartNode parent = node.getParent();
   // StructuralPropertyDescriptor locationInParent =
   // node.getLocationInParent();
   // if (locationInParent.isChildListProperty()) {
   // List siblings = (List) parent.getStructuralProperty(locationInParent);
   // return (DartNode[]) siblings.toArray(new DartNode[siblings.size()]);
   // }
   return null;
 }
  static SourceRange newSourceRange(final int offset, final int length) {
    DartX.todo();
    return new SourceRange() {
      @Override
      public int getLength() {
        return length;
      }

      @Override
      public int getOffset() {
        return offset;
      }
    };
  }
  @Override
  public IReconciler getReconciler(ISourceViewer sourceViewer) {

    DartX.todo("spelling");
    final ITextEditor editor = getEditor();
    if (editor != null) {

      DartCompositeReconcilingStrategy strategy =
          new DartCompositeReconcilingStrategy(
              sourceViewer, editor, getConfiguredDocumentPartitioning(sourceViewer));
      DartReconciler reconciler = new DartReconciler(editor, strategy, false);
      reconciler.setIsIncrementalReconciler(false);
      reconciler.setIsAllowedToModifyDocument(false);
      reconciler.setProgressMonitor(new NullProgressMonitor());
      reconciler.setDelay(500);

      return reconciler;
    }
    return null;
  }
 /*
  * (non-Javadoc) Method declared in ActionGroup
  */
 @Override
 public void fillContextMenu(IMenuManager menu) {
   super.fillContextMenu(menu);
   String menuText = ActionMessages.SourceMenu_label;
   if (fQuickAccessAction != null) {
     // TODO port QuickAccessMenu from JSDT
     DartX.todo();
     //      menuText = fQuickAccessAction.addShortcut(menuText);
   }
   IMenuManager subMenu = new MenuManager(menuText, MENU_ID);
   int added = 0;
   if (isEditorOwner()) {
     added = fillEditorSubMenu(subMenu);
   } else {
     added = fillViewSubMenu(subMenu);
   }
   if (added > 0) {
     menu.appendToGroup(fGroupName, subMenu);
   }
 }
Exemplo n.º 8
0
 @Override
 public boolean affectsBehavior(PropertyChangeEvent event) {
   DartX.todo();
   return super.affectsBehavior(event);
 }
Exemplo n.º 9
0
 @Override
 public void adaptToPreferenceChange(PropertyChangeEvent event) {
   DartX.todo();
   super.adaptToPreferenceChange(event);
 }
 /**
  * Fills the view menu. Clients can extend or override.
  *
  * @param viewMenu the menu manager that manages the menu
  */
 protected void fillViewMenu(IMenuManager viewMenu) {
   DartX.todo();
   //    fCustomFiltersActionGroup.fillViewMenu(viewMenu);
 }
  /**
   * Create the main content for this information control.
   *
   * @param parent The parent composite
   * @return The control representing the main content.
   */
  @Override
  protected Control createDialogArea(Composite parent) {
    fTreeViewer = createTreeViewer(parent, fTreeStyle);

    DartX.todo();
    //    fCustomFiltersActionGroup = new CustomFiltersActionGroup(getId(),
    //        fTreeViewer);

    final Tree tree = fTreeViewer.getTree();
    tree.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.character == 0x1B) {
              dispose();
            }
          }

          @Override
          public void keyReleased(KeyEvent e) {
            // do nothing
          }
        });

    tree.addSelectionListener(
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            gotoSelectedElement();
          }

          @Override
          public void widgetSelected(SelectionEvent e) {
            // do nothing
          }
        });

    tree.addMouseMoveListener(
        new MouseMoveListener() {
          TreeItem fLastItem = null;

          @Override
          public void mouseMove(MouseEvent e) {
            if (tree.equals(e.getSource())) {
              Object o = tree.getItem(new Point(e.x, e.y));
              if (o instanceof TreeItem) {
                if (!o.equals(fLastItem)) {
                  fLastItem = (TreeItem) o;
                  tree.setSelection(new TreeItem[] {fLastItem});
                }
              }
            }
          }
        });

    tree.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent e) {

            if (tree.getSelectionCount() < 1) {
              return;
            }

            if (e.button != 1) {
              return;
            }

            if (tree.equals(e.getSource())) {
              Object o = tree.getItem(new Point(e.x, e.y));
              TreeItem selection = tree.getSelection()[0];
              if (selection.equals(o)) {
                gotoSelectedElement();
              }
            }
          }
        });

    installFilter();

    addDisposeListener(this);
    return fTreeViewer.getControl();
  }
Exemplo n.º 12
0
  /**
   * Note: This constructor is for internal use only. Clients should not call this constructor.
   *
   * @param editor the compilation unit editor
   * @param groupName the group name to add the action to
   */
  public GenerateActionGroup(CompilationUnitEditor editor, String groupName) {
    fSite = editor.getSite();
    fEditor = editor;
    fGroupName = groupName;

    DartX.todo();
    //    fSortMembers = new MultiSortMembersAction(editor);
    //    fSortMembers.setActionDefinitionId(DartEditorActionDefinitionIds.SORT_MEMBERS);
    //    editor.setAction("SortMembers", fSortMembers); //$NON-NLS-1$

    //		IAction pastAction=
    // editor.getAction(ITextEditorActionConstants.PASTE);//IWorkbenchActionDefinitionIds.PASTE);
    //		fCopyQualifiedNameAction= new CopyQualifiedNameAction(editor, null, pastAction);
    //
    //	fCopyQualifiedNameAction.setActionDefinitionId(CopyQualifiedNameAction.JAVA_EDITOR_ACTION_DEFINITIONS_ID);
    //		editor.setAction("CopyQualifiedName", fCopyQualifiedNameAction); //$NON-NLS-1$

    //    if (IUIConstants.SUPPORT_REFACTORING) {
    //      fOverrideMethods = new OverrideMethodsAction(editor);
    //      fOverrideMethods.setActionDefinitionId(DartEditorActionDefinitionIds.OVERRIDE_METHODS);
    //      editor.setAction("OverrideMethods", fOverrideMethods); //$NON-NLS-1$
    //
    //      fAddGetterSetter = new AddGetterSetterAction(editor);
    //
    // fAddGetterSetter.setActionDefinitionId(DartEditorActionDefinitionIds.CREATE_GETTER_SETTER);
    //      editor.setAction("AddGetterSetter", fAddGetterSetter); //$NON-NLS-1$
    //
    //      fAddDelegateMethods = new AddDelegateMethodsAction(editor);
    //
    // fAddDelegateMethods.setActionDefinitionId(DartEditorActionDefinitionIds.CREATE_DELEGATE_METHODS);
    //      editor.setAction("AddDelegateMethods", fAddDelegateMethods); //$NON-NLS-1$
    //
    ////		fAddUnimplementedConstructors= new AddUnimplementedConstructorsAction(editor);
    ////
    //	fAddUnimplementedConstructors.setActionDefinitionId(DartEditorActionDefinitionIds.ADD_UNIMPLEMENTED_CONTRUCTORS);
    ////		editor.setAction("AddUnimplementedConstructors", fAddUnimplementedConstructors);
    // //$NON-NLS-1$
    //
    //      fGenerateConstructorUsingFields = new GenerateNewConstructorUsingFieldsAction(
    //          editor);
    //
    // fGenerateConstructorUsingFields.setActionDefinitionId(DartEditorActionDefinitionIds.GENERATE_CONSTRUCTOR_USING_FIELDS);
    //      editor.setAction(
    //          "GenerateConstructorUsingFields", fGenerateConstructorUsingFields); //$NON-NLS-1$
    //    }

    //		fHashCodeEquals= new GenerateHashCodeEqualsAction(editor);
    //
    //	fHashCodeEquals.setActionDefinitionId(DartEditorActionDefinitionIds.GENERATE_HASHCODE_EQUALS);
    //		editor.setAction("GenerateHashCodeEquals", fHashCodeEquals); //$NON-NLS-1$

    //    fAddJavaDocStub = new AddJavaDocStubAction(editor);
    //    fAddJavaDocStub.setActionDefinitionId(DartEditorActionDefinitionIds.ADD_JAVADOC_COMMENT);
    //    editor.setAction("AddJavadocComment", fAddJavaDocStub); //$NON-NLS-1$

    //    fCleanUp = new AllCleanUpsAction(editor);
    //    fCleanUp.setActionDefinitionId(DartEditorActionDefinitionIds.CLEAN_UP);
    //    editor.setAction("CleanUp", fCleanUp); //$NON-NLS-1$

    //    if (IUIConstants.SUPPORT_REFACTORING) {
    //      fExternalizeStrings = new ExternalizeStringsAction(editor);
    //
    // fExternalizeStrings.setActionDefinitionId(DartEditorActionDefinitionIds.EXTERNALIZE_STRINGS);
    //      editor.setAction("ExternalizeStrings", fExternalizeStrings); //$NON-NLS-1$
    //    }

    installQuickAccessAction();
  }
Exemplo n.º 13
0
  public DartDocHelpContext(IContext context, Object[] elements) throws DartModelException {
    Assert.isNotNull(elements);
    if (context instanceof IContext2) {
      fTitle = ((IContext2) context).getTitle();
    }

    List<IHelpResource> helpResources = new ArrayList<IHelpResource>();

    String javadocSummary = null;
    for (int i = 0; i < elements.length; i++) {
      if (elements[i] instanceof DartElement) {
        DartElement element = (DartElement) elements[i];
        // if element isn't on the build path skip it
        if (!ActionUtil.isOnBuildPath(element)) {
          continue;
        }

        // Create Javadoc summary
        if (BUG_85719_FIXED) {
          if (javadocSummary == null) {
            javadocSummary = retrieveText(element);
            if (javadocSummary != null) {
              String elementLabel =
                  DartElementLabels.getTextLabel(element, DartElementLabels.ALL_DEFAULT);

              // FIXME: needs to be NLSed once the code becomes active
              javadocSummary =
                  "<b>DartDoc for "
                      + elementLabel
                      + ":</b><br>"
                      + javadocSummary; //$NON-NLS-1$//$NON-NLS-2$
            }
          } else {
            javadocSummary = ""; // no Javadoc summary for multiple selection //$NON-NLS-1$
          }
        }

        URL url = DartUI.getDartDocLocation(element, true);
        if (url == null || doesNotExist(url)) {
          DartX.todo();
          //          IPackageFragmentRoot root = DartModelUtil.getPackageFragmentRoot(element);
          //          if (root != null) {
          //            url = DartUI.getJSdocBaseLocation(element);
          //            if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
          //              element = element.getDartProject();
          //            } else {
          //              element = root;
          //            }
          //            url = DartUI.getJSdocLocation(element, false);
          //          }
        }
        if (url != null) {
          IHelpResource javaResource = new JavaUIHelpResource(element, getURLString(url));
          helpResources.add(javaResource);
        }
      }
    }

    // Add static help topics
    if (context != null) {
      IHelpResource[] resources = context.getRelatedTopics();
      if (resources != null) {
        for (int j = 0; j < resources.length; j++) {
          helpResources.add(resources[j]);
        }
      }
    }

    fHelpResources = helpResources.toArray(new IHelpResource[helpResources.size()]);

    if (context != null) {
      fText = context.getText();
    }

    if (BUG_85719_FIXED) {
      if (javadocSummary != null && javadocSummary.length() > 0) {
        if (fText != null) {
          fText = context.getText() + "<br><br>" + javadocSummary; // $NON-NLS-1$
        } else {
          fText = javadocSummary;
        }
      }
    }

    if (fText == null) {
      fText = ""; // $NON-NLS-1$
    }
  }