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

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


    Assert.assertTrue(fieldBinding.getKind() == IBinding.VARIABLE);
  }

  public void testStaticConstantAccessBinding() throws Exception {
    String str = "<?php class MyClass { const A = 4; } ; /**/MyClass::A;?>";
    Program program = createAndParse(str);

    final ExpressionStatement statement = (ExpressionStatement) program
        .statements().get(2);
    final StaticConstantAccess constantAccess = (StaticConstantAccess) statement
        .getExpression();
    IVariableBinding fieldBinding = (IVariableBinding) constantAccess
        .resolveFieldBinding();
View Full Code Here


    Assert.assertTrue(fieldBinding.isField());
  }

  public void testIncludeBinding() throws Exception {
    String str = "<?php include('myFile.php');?>";
    Program program = createAndParse(str);

    IFile myFile = project.getFile("myFile.php");
    myFile.create(new ByteArrayInputStream(new byte[] {}), true,
        new NullProgressMonitor());
    try {

      ExpressionStatement statement = (ExpressionStatement) program
          .statements().get(0);
      Include include = (Include) statement.getExpression();

      IBinding sourceBinding = include.resolveBinding();
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();
View Full Code Here

    Assert.assertTrue(returnTypes[0].getName().equals("SoapClient"));
  }

  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();
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();
View Full Code Here

  // Assert.assertTrue(parameterTypes.length == 1);
  // }

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

    ExpressionStatement statement = (ExpressionStatement) program
        .statements().get(1);
    FunctionInvocation functionInvocation = (FunctionInvocation) statement
        .getExpression();

    IFunctionBinding functionBinding = functionInvocation
View Full Code Here

  // Assert.assertTrue(parameterTypes.length == 0);
  // }

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

    ExpressionStatement statement = (ExpressionStatement) program
        .statements().get(2);
    MethodInvocation methodInvocation = (MethodInvocation) statement
        .getExpression();

    IMethodBinding methodBinding = methodInvocation.resolveMethodBinding();
View Full Code Here

  // Assert.assertTrue(parameterTypes.length == 1);
  // }

  public void testStaticMethodInvocationBinding() throws Exception {
    String str = "<?php class MyClass { static function foo(){} } MyClass::foo($a); ?>";
    Program program = createAndParse(str);

    ExpressionStatement statement = (ExpressionStatement) program
        .statements().get(1);
    StaticMethodInvocation staticMethodInvocation = (StaticMethodInvocation) statement
        .getExpression();

    IMethodBinding methodBinding = staticMethodInvocation
View Full Code Here

  // // String
  // }

  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"));
View Full Code Here

    Assert.assertTrue(binding.isClass());
  }

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

    InterfaceDeclaration interfaceDeclaration = (InterfaceDeclaration) program
        .statements().get(0);
    ITypeBinding binding = interfaceDeclaration.resolveTypeBinding();

    Assert.assertNotNull(binding);
    Assert.assertTrue(binding.getName().equals("A"));
View Full Code Here

TOP

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

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.