Examples of CodeSnippetParsingUtil


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

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

    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

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

   *
   * @param javaSource String containing Java source to parse
   * @return a CompilationUnitDeclaration or null if parsing failed
   */
  private static CompilationUnitDeclaration parseJava(String javaSource) {
    CodeSnippetParsingUtil parsingUtil = new CodeSnippetParsingUtil();
    CompilerOptions options = new CompilerOptions();
    options.complianceLevel = ClassFileConstants.JDK1_5;
    options.sourceLevel = ClassFileConstants.JDK1_5;
    CompilationUnitDeclaration unit = parsingUtil.parseCompilationUnit(
        javaSource.toString().toCharArray(), options.getMap(), true);
    if (unit.compilationResult().hasProblems()) {
      return null;
    }
    return unit;
View Full Code Here

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

  public TextEdit format(int kind, String source, IRegion[] regions, int indentationLevel, String lineSeparator) {
    if (!regionsSatisfiesPreconditions(regions, source.length())) {
      throw new IllegalArgumentException();
    }

    this.codeSnippetParsingUtil = new CodeSnippetParsingUtil();
    boolean includeComments =  (kind & F_INCLUDE_COMMENTS) != 0;
    switch(kind & K_MASK) {
      case K_CLASS_BODY_DECLARATIONS :
        return formatClassBodyDeclarations(source, indentationLevel, lineSeparator, regions, includeComments);
      case K_COMPILATION_UNIT :
View Full Code Here

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

        this.preferences.line_separator = lineSeparator;
      } else {
        this.preferences.line_separator = Util.LINE_SEPARATOR;
      }
      this.preferences.initial_indentation_level = indentationLevel;
      if (this.codeSnippetParsingUtil == null) this.codeSnippetParsingUtil = new CodeSnippetParsingUtil();
      this.codeSnippetParsingUtil.parseCompilationUnit(source.toCharArray(), getDefaultCompilerOptions(), true);
      this.newCodeFormatter = new CodeFormatterVisitor(this.preferences, this.options, regions, this.codeSnippetParsingUtil, true);
      IRegion coveredRegion = getCoveredRegion(regions);
      int start = coveredRegion.getOffset();
      int end = start + coveredRegion.getLength();
View Full Code Here

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

    ast.setBindingResolver(new BindingResolver());
    if ((this.bits & CompilationUnitResolver.STATEMENT_RECOVERY) != 0) {
      ast.setFlag(ICompilationUnit.ENABLE_STATEMENTS_RECOVERY);
    }
    converter.setAST(ast);
    CodeSnippetParsingUtil codeSnippetParsingUtil = new CodeSnippetParsingUtil((this.bits & CompilationUnitResolver.IGNORE_METHOD_BODIES) != 0);
    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.bits & CompilationUnitResolver.STATEMENT_RECOVERY) != 0);
        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);
         
          compilationUnit.setStatementsRecoveryData(data);
        }
        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.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.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.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.eclipse.jdt.internal.compiler.ast.ASTNode[] nodes =
          codeSnippetParsingUtil.parseClassBodyDeclarations(
              this.rawSource,
              this.sourceOffset,
              this.sourceLength,
              this.compilerOptions,
              true,
View Full Code Here

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

   *
   * @param javaSource String containing Java source to parse
   * @return a CompilationUnitDeclaration or null if parsing failed
   */
  private static CompilationUnitDeclaration parseJava(String javaSource) {
    CodeSnippetParsingUtil parsingUtil = new CodeSnippetParsingUtil();
    CompilerOptions options = new CompilerOptions();
    options.complianceLevel = ClassFileConstants.JDK1_5;
    options.sourceLevel = ClassFileConstants.JDK1_5;
    CompilationUnitDeclaration unit = parsingUtil.parseCompilationUnit(
        javaSource.toString().toCharArray(), options.getMap(), true);
    if (unit.compilationResult().hasProblems()) {
      return null;
    }
    return unit;
View Full Code Here

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

   *
   * @param javaSource String containing Java source to parse
   * @return a CompilationUnitDeclaration or null if parsing failed
   */
  private static CompilationUnitDeclaration parseJava(String javaSource) {
    CodeSnippetParsingUtil parsingUtil = new CodeSnippetParsingUtil(true);
    CompilerOptions options = new CompilerOptions();
    options.complianceLevel = ClassFileConstants.JDK1_6;
    options.originalSourceLevel = ClassFileConstants.JDK1_6;
    options.sourceLevel = ClassFileConstants.JDK1_6;
    CompilationUnitDeclaration unit = parsingUtil.parseCompilationUnit(
        javaSource.toString().toCharArray(), options.getMap(), true);
    if (unit.compilationResult().hasProblems()) {
      return null;
    }
    return unit;
View Full Code Here

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

    ast.setBindingResolver(new BindingResolver());
    if ((this.bits & CompilationUnitResolver.STATEMENT_RECOVERY) != 0) {
      ast.setFlag(ICompilationUnit.ENABLE_STATEMENTS_RECOVERY);
    }
    converter.setAST(ast);
    CodeSnippetParsingUtil codeSnippetParsingUtil = new CodeSnippetParsingUtil((this.bits & CompilationUnitResolver.IGNORE_METHOD_BODIES) != 0);
    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.bits & CompilationUnitResolver.STATEMENT_RECOVERY) != 0);
        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);
         
          compilationUnit.setStatementsRecoveryData(data);
        }
        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.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.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.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.eclipse.jdt.internal.compiler.ast.ASTNode[] nodes =
          codeSnippetParsingUtil.parseClassBodyDeclarations(
              this.rawSource,
              this.sourceOffset,
              this.sourceLength,
              this.compilerOptions,
              true,
View Full Code Here

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

  public TextEdit format(int kind, String source, IRegion[] regions, int indentationLevel, String lineSeparator) {
    if (!regionsSatisfiesPreconditions(regions, source.length())) {
      throw new IllegalArgumentException();
    }

    this.codeSnippetParsingUtil = new CodeSnippetParsingUtil();
    boolean includeComments =  (kind & F_INCLUDE_COMMENTS) != 0;
    switch(kind & K_MASK) {
      case K_CLASS_BODY_DECLARATIONS :
        return formatClassBodyDeclarations(source, indentationLevel, lineSeparator, regions, includeComments);
      case K_COMPILATION_UNIT :
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.