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

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


      throw new RefactoringStatusException("The script must be on the build path of a project.");
    }
   
    try {
      // parse the php code and create a program
      ASTParser parser = ASTParser.newParser(fSourceModule);
      fProgram = parser.createAST(null);
    } catch(Exception e) {
      throw new RefactoringStatusException(RefactoringMessages.ExtractMethodInputPage_errorCouldNotParseSourceCode);
    }
   
    // Get covering namespace/class/method/function declaration
View Full Code Here


  public String getMethodSignature() {
   
    try {
     
      StringReader stringReader = new StringReader(new String());
      ASTParser previewParser = ASTParser.newParser(stringReader, ProjectOptions.getPhpVersion(fSourceModule), false);
      Program previewProgram = previewParser.createAST(null);
     
      previewProgram.recordModifications();
      AST previewAST = previewProgram.getAST();
     
      FunctionDeclaration function = previewAST.newFunctionDeclaration(previewAST.newIdentifier(fMethodName), computeArguments(previewAST), previewAST.newBlock(), false);
View Full Code Here

    String name = type.getElementName().replace("$", "");     
    StringBuffer buffer = new StringBuffer(name);     
    buffer.replace(0, 1, Character.toString(Character.toUpperCase(name.charAt(0))));     
    name = buffer.toString();     
         
    ASTParser parser = ASTParser.newParser(source);
    parser.setSource(document.get().toCharArray());
   
    Program program = parser.createAST(new NullProgressMonitor());     
//    program.recordModifications();   
//    AST ast = program.getAST();   

    ISourceRange range = type.getSourceRange();   
    ASTNode node = program.getElementAt(range.getOffset());
View Full Code Here

      fos.close();
      DLTKUIPlugin.getDocumentProvider().connect(input);
      final ISourceModule sourceModule = DLTKUIPlugin
          .getDocumentProvider().getWorkingCopy(input);
      if (sourceModule != null) {
        ASTParser parser = ASTParser.newParser(PHPVersion.PHP5_5,
            sourceModule);
        parser.setSource(fDocument.get().toCharArray());

        final Program program = parser.createAST(null);
        List<AbstractSemanticHighlighting> highlightings = new ArrayList<AbstractSemanticHighlighting>();

        highlightings.add(new StaticFieldHighlighting() {
          @Override
          protected Program getProgram(
View Full Code Here

    PHPCoreTests.waitForAutoBuild();

    PHPVersion version = ProjectOptions.getDefaultPhpVersion();
    ISourceModule sourceModule = null;
    sourceModule = DLTKCore.createSourceModuleFrom(testFile);
    ASTParser parser = ASTParser.newParser(
        new InputStreamReader(testFile.getContents()), version, false,
        sourceModule);
    return parser.createAST(new NullProgressMonitor());
  }
View Full Code Here

   */
  private void initialize(String content, PHPVersion phpVersion)
      throws Exception {
    document = new Document(content);

    ASTParser parser = ASTParser.newParser(phpVersion,
        ProjectOptions.useShortTags((IProject) null));
    parser.setSource(document.get().toCharArray());
    program = parser.createAST(new NullProgressMonitor());
    ast = program.getAST();

    program.recordModifications();
  }
View Full Code Here

  /**
   * Set the content into the document and initialize the parser, the program
   * and the ast.
   */
  private Program initialize(IDocument document) throws Exception {
    ASTParser parser = ASTParser.newParser(getPHPVersion(),
        ProjectOptions.useShortTags((IProject) null));
    parser.setSource(document.get().toCharArray());
    Program program = parser.createAST(new NullProgressMonitor());

    program.recordModifications();
    return program;
  }
View Full Code Here

    TestSuite suite = new TestSuite("DOM Parser Tests");

    for (final PHPVersion phpVersion : TESTS.keySet()) {
      TestSuite phpVerSuite = new TestSuite(phpVersion.getAlias());
      final ASTParser newParser = ASTParser.newParser(phpVersion,
          ProjectOptions.useShortTags((IProject) null));

      for (String testsDirectory : TESTS.get(phpVersion)) {

        for (final String fileName : getPDTTFiles(testsDirectory)) {
          try {
            final PdttFile pdttFile = new PdttFile(fileName);
            phpVerSuite.addTest(new DomParserTests(phpVersion
                .getAlias() + " - /" + fileName) {

              protected void runTest() throws Throwable {
                newParser.setSource(pdttFile.getFile().trim()
                    .toCharArray());
                Program program = newParser
                    .createAST(new NullProgressMonitor());

                assertContents(pdttFile.getExpected(),
                    program.toString());
              }
View Full Code Here

    if (project != null) {
      version = ProjectOptions.getPhpVersion(project);
    } else {
      version = ProjectOptions.getDefaultPhpVersion();
    }
    ASTParser newParser = ASTParser.newParser(version,
        (ISourceModule) source);
    return newParser.createAST(null);
  }
View Full Code Here

      }

      if (initialReconcile || astProvider.isActive(unit)) {
        PHPVersion phpVersion = ProjectOptions.getPhpVersion(unit
            .getScriptProject().getProject());
        ASTParser newParser = ASTParser.newParser(phpVersion, unit);
        createdAST = newParser.createAST(null);
        if (createdAST != null && document != null) {
          createdAST.setSourceModule(unit);
          createdAST.setSourceRange(0, document.getLength());
          createdAST.setLineEndTable(Util.lineEndTable(document));
        }
View Full Code Here

TOP

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

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.