Package org.eclipse.jdt.core.dom

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


      return arguments.get(1);
    }

    @Override
    public void setValue(Object value) throws Exception {
      final MethodInvocation invocation = getInvocation();
      final List<Expression> arguments = DomGenerics.arguments(invocation);
      final AstEditor editor = m_this.getEditor();
      // prepare new value
      String newValue = (String) value;
      // process empty string as null
View Full Code Here


    @Override
    public void setValue(Object valueObject) throws Exception {
      String valueString = valueObject instanceof String ? (String) valueObject : null;
      final AstEditor editor = m_this.getEditor();
      final MethodInvocation invocation = getInvocation();
      final String signaturePrefix = "setColumnWidth(com.google.gwt.user.cellview.client.Column,";
      // remove value
      if (StringUtils.isEmpty(valueString)) {
        if (invocation != null) {
          ExecutionUtils.run(m_this, new RunnableEx() {
            public void run() throws Exception {
              editor.removeEnclosingStatement(invocation);
            }
          });
        }
        return;
      }
      // new value
      if (invocation == null) {
        final String valueSource = StringConverter.INSTANCE.toJavaSource(m_this, valueString);
        ExecutionUtils.run(m_this, new RunnableEx() {
          public void run() throws Exception {
            StatementTarget target = new StatementTarget(getAssociation().getStatement(), false);
            String signature = signaturePrefix + "java.lang.String)";
            String argumentsSource = TemplateUtils.format("{0}, {1}", m_this, valueSource);
            MethodInvocation newInvocation =
                getParentJava().addMethodInvocation(target, signature, argumentsSource);
            addRelatedNodes(newInvocation);
          }
        });
        return;
View Full Code Here

    boolean hasSize =
        hasMethodInvocations(new String[]{"setSize(int,int)", "setWidth(int)", "setHeight(int)"});
    // process "xxx%" size specification
    if (!hasSize) {
      {
        MethodInvocation invocation =
            m_component.getMethodInvocation("setSize(java.lang.String,java.lang.String)");
        if (invocation != null) {
          List<Expression> arguments = DomGenerics.arguments(invocation);
          String width = (String) JavaInfoEvaluationHelper.getValue(arguments.get(0));
          String height = (String) JavaInfoEvaluationHelper.getValue(arguments.get(1));
          if (width.endsWith("%") || height.endsWith("%")) {
            // size is not set at actual value
            return false;
          }
          hasSize = true;
        }
      }
      {
        MethodInvocation invocation = m_component.getMethodInvocation("setWidth(java.lang.String)");
        if (invocation != null) {
          List<Expression> arguments = DomGenerics.arguments(invocation);
          String width = (String) JavaInfoEvaluationHelper.getValue(arguments.get(0));
          if (width.endsWith("%")) {
            // size is not set at actual value
            return false;
          }
          hasSize = true;
        }
      }
      {
        MethodInvocation invocation =
            m_component.getMethodInvocation("setHeight(java.lang.String)");
        if (invocation != null) {
          List<Expression> arguments = DomGenerics.arguments(invocation);
          String height = (String) JavaInfoEvaluationHelper.getValue(arguments.get(0));
          if (height.endsWith("%")) {
View Full Code Here

    return setSizeExpression(signature, index, expression);
  }

  private boolean setSizeExpression(String signature, int index, String expression)
      throws Exception {
    MethodInvocation invocation = m_widget.getMethodInvocation(signature);
    if (invocation != null) {
      AstEditor editor = m_widget.getEditor();
      editor.replaceInvocationArgument(invocation, index, expression);
      return true;
    }
View Full Code Here

      openCommand(description, arguments);
    }
    if (getCreationSupport() instanceof ImplicitFactoryCreationSupport) {
      ImplicitFactoryCreationSupport creationSupport =
          (ImplicitFactoryCreationSupport) getCreationSupport();
      MethodInvocation invocation = creationSupport.getInvocation();
      AbstractInvocationDescription description = creationSupport.getDescription();
      List<Expression> arguments = DomGenerics.arguments(invocation);
      openCommand(description, arguments);
    }
  }
View Full Code Here

  }

  public void setEdge(WidgetInfo widget, String edge) throws Exception {
    if (widget.getAssociation() instanceof InvocationChildAssociation) {
      InvocationChildAssociation association = (InvocationChildAssociation) widget.getAssociation();
      MethodInvocation invocation = association.getInvocation();
      // add/remove "size" argument
      String oldMethodName = invocation.getName().getIdentifier();
      if (!edge.equals("CENTER") && oldMethodName.equals("add")) {
        getEditor().addInvocationArgument(invocation, 1, "1.0");
        setReasonableSize(widget);
      } else if (edge.equals("CENTER") && !oldMethodName.equals("add")) {
        getEditor().removeInvocationArgument(invocation, 1);
View Full Code Here

   * @return the {@link Expression} of size argument of association. May be <code>null</code>.
   */
  private Expression getSizeExpression(WidgetInfo widget) {
    if (widget.getAssociation() instanceof InvocationChildAssociation) {
      InvocationChildAssociation association = (InvocationChildAssociation) widget.getAssociation();
      MethodInvocation invocation = association.getInvocation();
      List<Expression> arguments = DomGenerics.arguments(invocation);
      if (arguments.size() == 2) {
        return arguments.get(1);
      }
    }
View Full Code Here

      return getInvocation() != null;
    }

    @Override
    public Object getValue() throws Exception {
      MethodInvocation invocation = getInvocation();
      if (invocation != null) {
        return "<comparator>";
      }
      return "<empty>";
    }
View Full Code Here

      return "<empty>";
    }

    @Override
    public void setValue(Object value) throws Exception {
      MethodInvocation invocation = getInvocation();
      // remove value
      if (value == UNKNOWN_VALUE) {
        if (invocation != null) {
          removeInvocation(invocation);
        }
View Full Code Here

    private MethodInvocation getInvocation() {
      String signature =
          "setComparator(com.google.gwt.user.cellview.client.Column,java.util.Comparator)";
      for (ASTNode node : getRelatedNodes()) {
        if (node.getLocationInParent() == MethodInvocation.ARGUMENTS_PROPERTY) {
          MethodInvocation invocation = (MethodInvocation) node.getParent();
          if (AstNodeUtils.getMethodSignature(invocation).equals(signature)) {
            List<Expression> arguments = DomGenerics.arguments(invocation);
            Expression columnExpression = arguments.get(0);
            if (isRepresentedBy(columnExpression)) {
              return invocation;
View Full Code Here

TOP

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

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.