Package org.eclipse.php.internal.core.ast.nodes

Examples of org.eclipse.php.internal.core.ast.nodes.FunctionDeclaration


   
    AST ast = fProgram.getAST();
    MethodDeclaration method = ast.newMethodDeclaration();
    Block extractedMethodBody = ast.newBlock();
       
    FunctionDeclaration functionDec = ast.newFunctionDeclaration(ast.newIdentifier(fMethodName), computeArguments(ast), extractedMethodBody, false);
    method.setModifier(fModifierAccessFlag);
    method.setFunction(functionDec);
   
    ASTRewrite rewriter = ASTRewrite.create(ast);
   
View Full Code Here


      Program previewProgram = previewParser.createAST(null);
     
      previewProgram.recordModifications();
      AST previewAST = previewProgram.getAST();
     
      FunctionDeclaration function = previewAST.newFunctionDeclaration(previewAST.newIdentifier(fMethodName), computeArguments(previewAST), previewAST.newBlock(), false);
      MethodDeclaration method = previewAST.newMethodDeclaration(fModifierAccessFlag, function);
      previewProgram.statements().add(method);
     
      Document myDoc = new Document();
      previewProgram.rewrite(myDoc, null).apply(myDoc);
View Full Code Here

  public void testFunctionDeclarationBinding() throws Exception {
    String str = "<?php function foo() { return new SoapClient(); } ?> ";
    Program program = createAndParse(str);

    FunctionDeclaration functionDeclaration = (FunctionDeclaration) program
        .statements().get(0);

    IFunctionBinding functionBinding = functionDeclaration
        .resolveFunctionBinding();

    Assert.assertNotNull(functionBinding);
    Assert.assertTrue(functionBinding.getName().equals("foo"));
View Full Code Here

  public void testDeleteFunctionFormalFirst() throws Exception {
    String str = "<?php function foo($a, $b, $c = 5) { $a= 5; $b = 6; $c = 7; } ?>";
    String expected = "<?php function foo($b, $c = 5) { $a= 5; $b = 6; $c = 7; } ?>";
    parseAndCompare(str, expected, new ICodeManiplator() {
      public void manipulate(Program program) {
        FunctionDeclaration statement = (FunctionDeclaration) program
            .statements().get(0);
        statement.formalParameters().remove(0);
      }
    });
  }
View Full Code Here

  public void testDeleteFunctionFormalLast() throws Exception {
    String str = "<?php function foo($a, $b, $c = 5) { $a= 5; $b = 6; $c = 7; } ?>";
    String expected = "<?php function foo($a, $b) { $a= 5; $b = 6; $c = 7; } ?>";
    parseAndCompare(str, expected, new ICodeManiplator() {
      public void manipulate(Program program) {
        FunctionDeclaration statement = (FunctionDeclaration) program
            .statements().get(0);
        statement.formalParameters().remove(2);
      }
    });
  }
View Full Code Here

  public void testDeleteFunctionFormalMiddle() throws Exception {
    String str = "<?php function foo($a, $b, $c = 5) { $a= 5; $b = 6; $c = 7; } ?>";
    String expected = "<?php function foo($a, $c = 5) { $a= 5; $b = 6; $c = 7; } ?>";
    parseAndCompare(str, expected, new ICodeManiplator() {
      public void manipulate(Program program) {
        FunctionDeclaration statement = (FunctionDeclaration) program
            .statements().get(0);
        statement.formalParameters().remove(1);
      }
    });
  }
View Full Code Here

  public void testDeleteFunctionBodyFirst() throws Exception {
    String str = "<?php function foo() { $a= 5; $b = 6; $c = 7; } ?>";
    String expected = "<?php function foo() { $b = 6; $c = 7; } ?>";
    parseAndCompare(str, expected, new ICodeManiplator() {
      public void manipulate(Program program) {
        FunctionDeclaration statement = (FunctionDeclaration) program
            .statements().get(0);
        statement.getBody().statements().remove(0);
      }
    });
  }
View Full Code Here

  public void testDeleteFunctionBodyLast() throws Exception {
    String str = "<?php function foo() { $a= 5; $b = 6; $c = 7; } ?>";
    String expected = "<?php function foo() { $a= 5; $b = 6; } ?>";
    parseAndCompare(str, expected, new ICodeManiplator() {
      public void manipulate(Program program) {
        FunctionDeclaration statement = (FunctionDeclaration) program
            .statements().get(0);
        statement.getBody().statements().remove(2);
      }
    });
  }
View Full Code Here

  public void testDeleteFunctionBodyMiddle() throws Exception {
    String str = "<?php function foo() { $a= 5; $b = 6; $c = 7; } ?>";
    String expected = "<?php function foo() { $a= 5; $c = 7; } ?>";
    parseAndCompare(str, expected, new ICodeManiplator() {
      public void manipulate(Program program) {
        FunctionDeclaration statement = (FunctionDeclaration) program
            .statements().get(0);
        statement.getBody().statements().remove(1);
      }
    });
  }
View Full Code Here

TOP

Related Classes of org.eclipse.php.internal.core.ast.nodes.FunctionDeclaration

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.