Package org.eclipse.jdt.core.dom

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


    IValueList extendedModifiers = parseExtendedModifiers(node.modifiers());
    IValue name = values.string(node.getName().getFullyQualifiedName());
   
    IValueList bodyDeclarations = new IValueList(values);
    for (Iterator it = node.bodyDeclarations().iterator(); it.hasNext();) {
      BodyDeclaration d = (BodyDeclaration) it.next();
      bodyDeclarations.add(visitChild(d));
    }
 
    ownValue = constructDeclarationNode("annotationType", name, bodyDeclarations.asList());
    setAnnotation("modifiers", extendedModifiers);
View Full Code Here


 
  public boolean visit(AnonymousClassDeclaration node) {
    IValueList bodyDeclarations = new IValueList(values);
 
    for (Iterator it = node.bodyDeclarations().iterator(); it.hasNext();) {
      BodyDeclaration b = (BodyDeclaration) it.next();
      bodyDeclarations.add(visitChild(b));
    }
    ownValue = constructDeclarationNode("class", bodyDeclarations.asList());
   
    return false;
View Full Code Here

    }
 
    IValueList bodyDeclarations = new IValueList(values);
    if (!node.bodyDeclarations().isEmpty()) {
      for (Iterator it = node.bodyDeclarations().iterator(); it.hasNext();) {
        BodyDeclaration d = (BodyDeclaration) it.next();
        bodyDeclarations.add(visitChild(d));
      }
    }
 
    ownValue = constructDeclarationNode("enum", name, implementedInterfaces.asList(), enumConstants.asList(), bodyDeclarations.asList());
View Full Code Here

      }
    }
   
    IValueList bodyDeclarations = new IValueList(values);
    for (Iterator it = node.bodyDeclarations().iterator(); it.hasNext();) {
      BodyDeclaration d = (BodyDeclaration) it.next();
      bodyDeclarations.add(visitChild(d));
    }
   
    ownValue = constructDeclarationNode(objectType, name, extendsClass.asList(), implementsInterfaces.asList(), bodyDeclarations.asList());
    setAnnotation("modifiers", extendedModifiers);
View Full Code Here

   */
  @Override
  public void selectionChanged(SelectionChangedEvent event) {
    IStructuredSelection selection = (IStructuredSelection) event
        .getSelection();
    BodyDeclaration selected = (BodyDeclaration) selection
        .getFirstElement();

    // 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 = "// No adapter code 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

   */
  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

  public void dragStart(DragSourceEvent event) {
    selection = viewer.getTree().getSelection();
    if (selection == null || selection.length == 0) {
      event.doit = false;
    }
    BodyDeclaration selectedElement = (BodyDeclaration) selection[0]
        .getData();
    logger.debug("URI: "
        + selectedElement.getProperty(ResultProperty.URI.name()));
  }
View Full Code Here

  @Override
  public void dragSetData(DragSourceEvent event) {
    logger.debug(event.dataType + " requested by drop target.");

    try {
      BodyDeclaration selectedElement = (BodyDeclaration) selection[0]
          .getData();
      if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
        // TextTransfer simply transfers the selected code element.
        event.data = selectedElement.toString();
        logger.debug("TextTransfer triggered");
      } else if (PluginTransfer.getInstance().isSupportedType(
          event.dataType)) {
        // For a PluginTransfer, we transmit the URI of the element.
        // The DropListener is responsible for handling this.
        Object uri = selectedElement.getProperty(ResultProperty.URI
            .name());
        if (uri != null)
          event.data = new PluginTransferData(
              "de.uni_mannheim.swt.codeconjurer.ui.dnd.pluginDropAction",
              (((String) uri).getBytes()));
View Full Code Here

      if (!Activator.getDefault().getPreferenceStore()
          .getBoolean(PreferenceConstants.P_SHOW_NEGATIVES)) {
        noShowNegatives = true;
      }
      for (ResultItem result : results) {
        BodyDeclaration typeRoot = result.getTypeRoot();
        if (noShowNegatives
            && result.getProperty(ResultProperty.TEST_RESULT)
                .startsWith("// No adapter created")) {
          logger.debug("Skip negative result.");
        } else {
          logger.debug("Add result.");
          if (typeRoot != null) {
            elements.add(typeRoot);
          }
        }
      }
    } else {
      for (ResultItem result : results) {
        BodyDeclaration typeRoot = result.getTypeRoot();
        if (typeRoot != null) {
          elements.add(typeRoot);
        }
      }
    }
View Full Code Here

   * org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.
   * Object)
   */
  @Override
  public Object[] getChildren(Object parentElement) {
    BodyDeclaration element = (BodyDeclaration) parentElement;
    ArrayList<MethodDeclaration> methods = new ArrayList<MethodDeclaration>();
    if (element.getNodeType() == ASTNode.TYPE_DECLARATION) {
      for (MethodDeclaration method : ((TypeDeclaration) element)
          .getMethods()) {
        // Copy properties from class to methods
        Set<?> properties = element.properties().keySet();
        for (String property : (String[]) properties
            .toArray(new String[element.properties().size()])) {
          method.setProperty(property, element.getProperty(property));
        }
        // Set a unique identifier (required for DND)
        String sign = "" + method.getReturnType2() + method.getName();
        for (Object p : method.parameters()) {
          sign += p.toString();
        }
        // Replace the copied parent's URI from above with a new URI
        // extended with the signature of the child and a mark
        method.setProperty(ResultProperty.URI.name(),
            method.getProperty(ResultProperty.URI.name())
                + CodeConjurer.URI_DELIMITER + sign);
        methods.add(method);
      }
      return methods.toArray();
    }
    if (element.getNodeType() == ASTNode.ENUM_DECLARATION) {
      for (Object declaration : ((EnumDeclaration) element)
          .bodyDeclarations()) {
        if (declaration instanceof MethodDeclaration) {
          MethodDeclaration method = (MethodDeclaration) declaration;
          // Copy properties from class to methods
          Set<?> properties = element.properties().keySet();
          for (String property : (String[]) properties
              .toArray(new String[element.properties().size()])) {
            method.setProperty(property,
                element.getProperty(property));
          }
          // Set a unique identifier (required for DND)
          String sign = "" + method.getReturnType2()
              + method.getName();
          for (Object p : method.parameters()) {
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.BodyDeclaration

Copyright © 2018 www.massapicom. 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.