Examples of BodyDeclaration


Examples of org.eclipse.jdt.core.dom.BodyDeclaration

  public Object[] getElements(Object inputElement) {
    Search search = (Search) inputElement;
    ResultItem[] results = search.getSearchResult().getResultItems();
    ArrayList<BodyDeclaration> elements = new ArrayList<BodyDeclaration>();
    for (ResultItem result : results) {
      BodyDeclaration typeRoot = result.getTypeRoot();
      if (typeRoot != null)
        elements.add(typeRoot);
    }
    return elements.toArray();
  }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.BodyDeclaration

   * org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.
   * Object)
   */
  @Override
  public Object[] getChildren(Object parentElement) {
    BodyDeclaration element = (BodyDeclaration) parentElement;
    if (element.getNodeType() == ASTNode.TYPE_DECLARATION) {
      return ((TypeDeclaration) element).getMethods();
    }
    return null;
  }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.BodyDeclaration

   * org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.
   * Object)
   */
  @Override
  public boolean hasChildren(Object parentElement) {
    BodyDeclaration element = (BodyDeclaration) parentElement;

    // Only Classes may have children
    if (element.getNodeType() == ASTNode.TYPE_DECLARATION)
      if (((TypeDeclaration) element).getMethods().length > 0)
        return true;

    return false;
  }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.BodyDeclaration

    ITableLabelProvider, ITableColorProvider {

  @Override
  public Image getColumnImage(Object item, int columnIndex) {
    Image img = null;
    BodyDeclaration element = (BodyDeclaration) item;
    if (element.getNodeType() == ASTNode.TYPE_DECLARATION) {
      img = JavaUI.getSharedImages().getImage(
          ISharedImages.IMG_OBJS_CLASS);
    }
    if (element.getNodeType() == ASTNode.METHOD_DECLARATION) {
      MethodDeclaration method = (MethodDeclaration) element;
      if (method.isConstructor()) {
        img = JavaUI.getSharedImages().getImage(
            ISharedImages.IMG_OBJS_INNER_CLASS_DEFAULT);
      } else {
View Full Code Here

Examples of org.eclipse.jdt.core.dom.BodyDeclaration

    return img;
  }

  @Override
  public String getColumnText(Object item, int columnIndex) {
    BodyDeclaration element = (BodyDeclaration) item;
    if (element.getNodeType() == ASTNode.TYPE_DECLARATION) {
      return ((TypeDeclaration) element).getName()
          .getFullyQualifiedName();
    }
    if (element.getNodeType() == ASTNode.METHOD_DECLARATION) {
      return ((MethodDeclaration) element).getName()
          .getFullyQualifiedName();
    }
    return null;
  }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.BodyDeclaration

    return null;
  }

  @Override
  public Color getForeground(Object item, int columnIndex) {
    BodyDeclaration element = (BodyDeclaration) item;
    Color color = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
    String source = element.toString();
    if (source != null && !source.equals("")) {
      color = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
    } else {
      color = Display.getCurrent().getSystemColor(SWT.COLOR_GRAY);
    }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.BodyDeclaration

  protected IStatus run(IProgressMonitor monitor) {
    try {
      IPackageFragment pkg = (IPackageFragment) target;
      String uri = new String(source);
      Search search = CodeConjurer.getInstance().getActiveEditorSearch();
      BodyDeclaration selectedElement = search.getSearchResult()
          .find(uri);
      if (selectedElement.getNodeType() == BodyDeclaration.TYPE_DECLARATION) {
        TypeDeclaration typeDec = (TypeDeclaration) selectedElement;
        String name = typeDec.getName().toString();
        String sourceCode = (String) selectedElement
            .getProperty(ResultProperty.RAW_SOURCE.name());

        // If a CompilatonUnit with the same name exists and is
        // opened, we must close it before overwrite.
        ICompilationUnit icu = pkg.getCompilationUnit(name + ".java");
View Full Code Here

Examples of org.eclipse.jdt.core.dom.BodyDeclaration

   */
  protected void setPreview() {
    resultTree.refresh();
    TreeItem selection = resultTree.getSelectedElement();
    if (selection != null) {
      BodyDeclaration selected = (BodyDeclaration) selection.getData();
      // Show the source code of the selection
      if (preview != null) {
        if (selected != null) {
          String previewCode = "";
          String adapterCode = "";
          if (selected.getNodeType() == BodyDeclaration.TYPE_DECLARATION) {
            previewCode = (String) selected
                .getProperty(ResultProperty.RAW_SOURCE.name());
            adapterCode = (String) selected
                .getProperty(ResultProperty.TEST_RESULT.name());
          } else {
            previewCode = selected.toString();
            adapterCode = "// Adapter not available";
          }
          boolean showAdapter = Activator.getDefault()
              .getPreferenceStore()
              .getBoolean(PreferenceConstants.P_SHOW_ADAPTER);
          String searchKind = selected.getProperty(
              ResultProperty.SEARCH_KIND.name()).toString();
          if (showAdapter
              && searchKind.equals(String
                  .valueOf(Search.TEST_DRIVEN_SEARCH))) {
            preview.setCode(adapterCode);
View Full Code Here

Examples of org.eclipse.jdt.core.dom.BodyDeclaration

    } else {
      shortUrl = uri;
    }
    ResultItem result = getResultItem(shortUrl);
    if (result != null) {
      BodyDeclaration declaration = result.find(uri);
      return declaration;
    } else {
      return null;
    }
  }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.BodyDeclaration

   *         compilation unit was created from, or null if it was not created
   *         from a Java type root.
   */
  public BodyDeclaration getTypeRoot() {
    if (resultCompilationUnit != null) {
      BodyDeclaration declaration = null;
      for (Object typeObject : resultCompilationUnit.types()) {
        BodyDeclaration typeBodyDec = (BodyDeclaration) typeObject;
        if (typeBodyDec.getNodeType() == BodyDeclaration.TYPE_DECLARATION) {
          TypeDeclaration type = (TypeDeclaration) typeBodyDec;
          String typeName = type.getName().getFullyQualifiedName();
          String reportedName = getProperty(ResultProperty.NAME);
          if (typeName.equals(reportedName))
            declaration = type;
        }
        if (typeBodyDec.getNodeType() == BodyDeclaration.ENUM_DECLARATION) {
          EnumDeclaration type = (EnumDeclaration) typeBodyDec;
          if (type.getName().getFullyQualifiedName()
              .equals(getProperty(ResultProperty.NAME)))
            declaration = type;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.