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

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


    }
  }

  public IMethod getOverriddenMethod() throws CoreException {
    try {
      Program ast = SharedASTProvider.getAST(method.getSourceModule(), SharedASTProvider.WAIT_YES, new NullProgressMonitor());
      if (ast != null) {
        OverriddenMethodFinder overriddenMethodFinder = new OverriddenMethodFinder();
        ast.accept(overriddenMethodFinder);

        return overriddenMethodFinder.getOverriddenMethod();
      }
    } catch (IOException e) {
      throw new CoreException(new Status(IStatus.ERROR, PEXCorePlugin.PLUGIN_ID, e.getMessage(), e));
View Full Code Here


   
    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);
      MethodDeclaration method = previewAST.newMethodDeclaration(fModifierAccessFlag, function);
      previewProgram.statements().add(method);
     
      Document myDoc = new Document();
      previewProgram.rewrite(myDoc, null).apply(myDoc);
     
      return myDoc.get().substring(0, myDoc.get().indexOf(METHOD_ARGUMENT_CLOSING_CHAR) + 1);
     
    } catch (Exception e) {
      return RefactoringMessages.ExtractMethodPreviewPage_NoSignaturePreviewAvailable;
View Full Code Here

    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());

    if (!(node instanceof ClassDeclaration)) {
      return ;       
    }
   
View Full Code Here

      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

   * @throws Exception
   */
  public void parseAndCompare(String string, String expected,
      ICodeManiplator manipulator) throws Exception {
    IDocument document = new Document(string);
    Program program = initialize(document);

    manipulator.manipulate(program);
    rewrite(program, document);

    String actual = document.get();
View Full Code Here

   */
  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

                .getAlias() + " - /" + fileName) {

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

                assertContents(pdttFile.getExpected(),
                    program.toString());
              }
            });
          } catch (final Exception e) {
            // dummy test indicating PDTT file parsing failure
            phpVerSuite.addTest(new TestCase(fileName) {
View Full Code Here

  }

  public final ISourceRange getNewSelectionRange(ISourceRange oldSourceRange,
      ISourceModule typeRoot) {
    try {
      Program root = getAST(typeRoot);
      if (root == null)
        return oldSourceRange;
      Selection selection = Selection.createFromStartLength(
          oldSourceRange.getOffset(), oldSourceRange.getLength());
      SelectionAnalyzer selAnalyzer = new SelectionAnalyzer(selection,
          true);
      root.accept(selAnalyzer);
      return internalGetNewSelectionRange(oldSourceRange, typeRoot,
          selAnalyzer);
    } catch (ModelException e) {
      return new SourceRange(oldSourceRange.getOffset(),
          oldSourceRange.getLength());
View Full Code Here

   */
  protected IModelElement getSelectionModelElement(int offset, int length,
      ISourceModule sourceModule) {
    IModelElement element = null;
    try {
      Program ast = SharedASTProvider.getAST(sourceModule,
          SharedASTProvider.WAIT_NO, null);
      if (ast != null) {
        ASTNode selectedNode = NodeFinder.perform(ast, offset, length);
        if (selectedNode != null
            && selectedNode.getType() == ASTNode.IDENTIFIER) {
View Full Code Here

   * @throws Exception
   */
  public void parseAndCompare(String programStr) throws Exception {
    final IDocument document = new Document(programStr);
    final Reader reader = new StringReader(programStr);
    Program program = ASTParser.newParser(reader, PHPVersion.PHP5,
        ProjectOptions.useShortTags((IProject) null)).createAST(
        new NullProgressMonitor());

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

    final Statement node = program.statements().get(0);
    final int extendedLength = program.getExtendedLength(node);

    assert extendedLength > node.getLength();
  }
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.