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

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


   
    char indentChar = FormatterUtils
        .getFormatterCommonPrferences().getIndentationChar(document);
    String indent = String.valueOf(indentChar);
   
    ClassDeclaration clazz = (ClassDeclaration) node;
    Block body = clazz.getBody();
    List<Statement> bodyStatements = body.statements();
       

    int end = bodyStatements.get(bodyStatements.size()-1).getEnd();
   
View Full Code Here


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

    ClassDeclaration classDeclaration = (ClassDeclaration) program
        .statements().get(0);
    MethodDeclaration methodDeclaration = (MethodDeclaration) classDeclaration
        .getBody().statements().get(0);

    IMethodBinding methodBinding = methodDeclaration.resolveMethodBinding();
    Assert.assertNotNull(methodBinding);
    Assert.assertTrue(methodBinding.getName().equals("foo"));
View Full Code Here

  public void testMethodDeclarationGeneratorBinding() throws Exception {
    String str = "<?php class MyClass { function foo(){ yield 1; } } ?>";
    Program program = createAndParse(str);

    ClassDeclaration classDeclaration = (ClassDeclaration) program
        .statements().get(0);
    MethodDeclaration methodDeclaration = (MethodDeclaration) classDeclaration
        .getBody().statements().get(0);

    IMethodBinding methodBinding = methodDeclaration.resolveMethodBinding();
    Assert.assertNotNull(methodBinding);
    Assert.assertTrue(methodBinding.getName().equals("foo"));
View Full Code Here

  public void testClassDeclarationBinding() throws Exception {
    String str = "<?php class A {} ?>";
    Program program = createAndParse(str);

    ClassDeclaration classDeclaration = (ClassDeclaration) program
        .statements().get(0);
    ITypeBinding binding = classDeclaration.resolveTypeBinding();

    Assert.assertNotNull(binding);
    Assert.assertTrue(binding.getName().equals("A"));
    Assert.assertTrue(binding.getKind() == IBinding.TYPE);
    Assert.assertTrue(binding.isClass());
View Full Code Here

  public void testDeleteClassElements() throws Exception {
    String str = "<?php final class MyClass extends SuperClass implements Interface1, Interface2 { const MY_CONSTANT = 3; public static final $myVar = 5, $yourVar; var $anotherOne; private function myFunction(MyClass $a, $b = 6) { }  } ?>";
    String expected = "<?php final class MyClass extends SuperClass {  } ?>";
    parseAndCompare(str, expected, new ICodeManiplator() {
      public void manipulate(Program program) {
        ClassDeclaration statement = (ClassDeclaration) program
            .statements().get(0);
        statement.interfaces().remove(1);
        statement.interfaces().remove(0);
        statement.getBody().statements().remove(3);
        statement.getBody().statements().remove(2);
        statement.getBody().statements().remove(1);
        statement.getBody().statements().remove(0);
      }
    });
  }
View Full Code Here

        ProjectOptions.useShortTags((IProject) null)).createAST(
        new NullProgressMonitor());

    program.initCommentMapper(document, new PhpAstLexer(reader));

    final ClassDeclaration node = (ClassDeclaration) program.statements()
        .get(0);
    final Statement statement = node.getBody().statements().get(index);

    final int extendedLength = program.getExtendedLength(statement);

    assert extendedLength > statement.getLength();
  }
View Full Code Here

TOP

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

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.