Package org.aspectj.org.eclipse.jdt.internal.core.util

Examples of org.aspectj.org.eclipse.jdt.internal.core.util.CodeSnippetParsingUtil


      String lineSeparator) {

    if (offset < 0 || length < 0 || length > source.length()) {
      throw new IllegalArgumentException();
    }
    this.codeSnippetParsingUtil = new CodeSnippetParsingUtil();
    switch(kind) {
      case K_CLASS_BODY_DECLARATIONS :
        return formatClassBodyDeclarations(source, indentationLevel, lineSeparator, offset, length);
      case K_COMPILATION_UNIT :
        return formatCompilationUnit(source, indentationLevel, lineSeparator, offset, length);
View Full Code Here


    ast.setBindingResolver(new BindingResolver());
    if (this.statementsRecovery) {
      ast.setFlag(ICompilationUnit.ENABLE_STATEMENTS_RECOVERY);
    }
    converter.setAST(ast);
    CodeSnippetParsingUtil codeSnippetParsingUtil = new CodeSnippetParsingUtil();
    CompilationUnit compilationUnit = ast.newCompilationUnit();
    if (this.sourceLength == -1) {
      this.sourceLength = this.rawSource.length;
    }
    switch(this.astKind) {
      case K_STATEMENTS :
        ConstructorDeclaration constructorDeclaration = codeSnippetParsingUtil.parseStatements(this.rawSource, this.sourceOffset, this.sourceLength, this.compilerOptions, true, this.statementsRecovery);
        RecoveryScannerData data = constructorDeclaration.compilationResult.recoveryScannerData;
        if(data != null) {
          Scanner scanner = converter.scanner;
          converter.scanner = new RecoveryScanner(scanner, data.removeUnused());
          converter.docParser.scanner = converter.scanner;
          converter.scanner.setSource(scanner.source);
        }
        RecordedParsingInformation recordedParsingInformation = codeSnippetParsingUtil.recordedParsingInformation;
        int[][] comments = recordedParsingInformation.commentPositions;
        if (comments != null) {
          converter.buildCommentsTable(compilationUnit, comments);
        }
        compilationUnit.setLineEndTable(recordedParsingInformation.lineEnds);
        Block block = ast.newBlock();
        block.setSourceRange(this.sourceOffset, this.sourceOffset + this.sourceLength);
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement[] statements = constructorDeclaration.statements;
        if (statements != null) {
          int statementsLength = statements.length;
          for (int i = 0; i < statementsLength; i++) {
            if (statements[i] instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) {
              converter.checkAndAddMultipleLocalDeclaration(statements, i, block.statements());
            } else {
              Statement statement = converter.convert(statements[i]);
              if (statement != null) {
                block.statements().add(statement);
              }
            }
          }
        }
        rootNodeToCompilationUnit(ast, compilationUnit, block, recordedParsingInformation, data);
        ast.setDefaultNodeFlag(0);
        ast.setOriginalModificationCount(ast.modificationCount());
        return block;
      case K_EXPRESSION :
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression = codeSnippetParsingUtil.parseExpression(this.rawSource, this.sourceOffset, this.sourceLength, this.compilerOptions, true);
        recordedParsingInformation = codeSnippetParsingUtil.recordedParsingInformation;
        comments = recordedParsingInformation.commentPositions;
        if (comments != null) {
          converter.buildCommentsTable(compilationUnit, comments);
        }
        compilationUnit.setLineEndTable(recordedParsingInformation.lineEnds);
        if (expression != null) {
          Expression expression2 = converter.convert(expression);
          rootNodeToCompilationUnit(expression2.getAST(), compilationUnit, expression2, codeSnippetParsingUtil.recordedParsingInformation, null);
          ast.setDefaultNodeFlag(0);
          ast.setOriginalModificationCount(ast.modificationCount());
          return expression2;
        } else {
          CategorizedProblem[] problems = recordedParsingInformation.problems;
          if (problems != null) {
            compilationUnit.setProblems(problems);
          }
          ast.setDefaultNodeFlag(0);
          ast.setOriginalModificationCount(ast.modificationCount());
          return compilationUnit;
        }
      case K_CLASS_BODY_DECLARATIONS :
        final org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode[] nodes = codeSnippetParsingUtil.parseClassBodyDeclarations(this.rawSource, this.sourceOffset, this.sourceLength, this.compilerOptions, true);
        recordedParsingInformation = codeSnippetParsingUtil.recordedParsingInformation;
        comments = recordedParsingInformation.commentPositions;
        if (comments != null) {
          converter.buildCommentsTable(compilationUnit, comments);
        }
View Full Code Here

TOP

Related Classes of org.aspectj.org.eclipse.jdt.internal.core.util.CodeSnippetParsingUtil

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.