Package org.aspectj.org.eclipse.jdt.internal.compiler.parser

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.parser.Parser


  }

  public static void parse(ICompilationUnit[] compilationUnits, ASTRequestor astRequestor, int apiLevel, Map options, int flags, IProgressMonitor monitor) {
    try {
      CompilerOptions compilerOptions = new CompilerOptions(options);
      Parser parser = new CommentRecorderParser(
        new ProblemReporter(
            DefaultErrorHandlingPolicies.proceedWithAllProblems(),
            compilerOptions,
            new DefaultProblemFactory()),
        false);
      int length = compilationUnits.length;
      if (monitor != null) monitor.beginTask("", length); //$NON-NLS-1$
      for (int i = 0; i < length; i++) {
        org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = (org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit) compilationUnits[i];
        CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit);
        CompilationUnitDeclaration compilationUnitDeclaration = parser.dietParse(sourceUnit, compilationResult);

        if (compilationUnitDeclaration.ignoreMethodBodies) {
          compilationUnitDeclaration.ignoreFurtherInvestigation = true;
          // if initial diet parse did not work, no need to dig into method bodies.
          continue;
View Full Code Here


    }
    CompilerOptions compilerOptions = new CompilerOptions(settings);
    boolean statementsRecovery = (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0;
    compilerOptions.performMethodsFullRecovery = statementsRecovery;
    compilerOptions.performStatementsRecovery = statementsRecovery;
    Parser parser = new CommentRecorderParser(
      new ProblemReporter(
          DefaultErrorHandlingPolicies.proceedWithAllProblems(),
          compilerOptions,
          new DefaultProblemFactory()),
      false);
    CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit);
    CompilationUnitDeclaration compilationUnitDeclaration = parser.dietParse(sourceUnit, compilationResult);

    if (compilationUnitDeclaration.ignoreMethodBodies) {
      compilationUnitDeclaration.ignoreFurtherInvestigation = true;
      // if initial diet parse did not work, no need to dig into method bodies.
      return null;
View Full Code Here

    le.factory = factory;
    pr.factory = factory;

    forCompiler.lookupEnvironment = le;

    forCompiler.parser = new Parser(pr, forCompiler.options.parseLiteralExpressionsAsConstants);
    if (getBcelWorld().shouldPipelineCompilation()) {
      IMessage message = MessageUtil.info("Pipelining compilation");
      handler.handleMessage(message);
      return new AjPipeliningCompilerAdapter(forCompiler, batchCompile, getBcelWorld(), getWeaver(), factory,
          getInterimResultRequestor(), progressListener,
View Full Code Here

        focusOpenable = (Openable)focus.getCompilationUnit();
      }
    }
   
    // build type bindings
    Parser parser = new Parser(this.lookupEnvironment.problemReporter, true);
    for (int i = 0; i < openablesLength; i++) {
      Openable openable = openables[i];
      if (openable instanceof org.aspectj.org.eclipse.jdt.core.ICompilationUnit) {
        org.aspectj.org.eclipse.jdt.core.ICompilationUnit cu = (org.aspectj.org.eclipse.jdt.core.ICompilationUnit)openable;

        // contains a potential subtype as a local or anonymous type?
        boolean containsLocalType = false;
        if (localTypes == null) { // case of hierarchy on region
          containsLocalType = true;
        } else {
          IPath path = cu.getPath();
          containsLocalType = localTypes.contains(path.toString());
        }
       
        // build parsed unit
        CompilationUnitDeclaration parsedUnit = null;
        if (cu.isOpen()) {
          // create parsed unit from source element infos
          CompilationResult result = new CompilationResult(((ICompilationUnit)cu).getFileName(), i, openablesLength, this.options.maxProblemsPerUnit);
          SourceTypeElementInfo[] typeInfos = null;
          try {
            IType[] topLevelTypes = cu.getTypes();
            int topLevelLength = topLevelTypes.length;
            if (topLevelLength == 0) continue; // empty cu: no need to parse (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=65677)
            typeInfos = new SourceTypeElementInfo[topLevelLength];
            for (int j = 0; j < topLevelLength; j++) {
              IType topLevelType = topLevelTypes[j];
              typeInfos[j] = (SourceTypeElementInfo)((JavaElement)topLevelType).getElementInfo();
            }
          } catch (JavaModelException e) {
            // types/cu exist since cu is opened
          }
          int flags = !containsLocalType
            ? SourceTypeConverter.MEMBER_TYPE
            : SourceTypeConverter.FIELD_AND_METHOD | SourceTypeConverter.MEMBER_TYPE | SourceTypeConverter.LOCAL_TYPE;
          parsedUnit =
            SourceTypeConverter.buildCompilationUnit(
              typeInfos,
              flags,
              this.lookupEnvironment.problemReporter,
              result);
          if (containsLocalType)   parsedUnit.bits |= ASTNode.HasAllMethodBodies;
        } else {
          // create parsed unit from file
          IFile file = (IFile) cu.getResource();
          ICompilationUnit sourceUnit = this.builder.createCompilationUnitFromPath(openable, file);
         
          CompilationResult unitResult = new CompilationResult(sourceUnit, i, openablesLength, this.options.maxProblemsPerUnit);
          parsedUnit = parser.dietParse(sourceUnit, unitResult);
        }

        if (parsedUnit != null) {
          hasLocalType[unitsIndex] = containsLocalType;
          cus[unitsIndex] = cu;
          parsedUnits[unitsIndex++] = parsedUnit;
          try {
            this.lookupEnvironment.buildTypeBindings(parsedUnit, null /*no access restriction*/);
            if (openable.equals(focusOpenable)) {
              focusUnit = parsedUnit;
            }
          } catch (AbortCompilation e) {
            // classpath problem for this type: ignore
          }
        }
      } else {
        // cache binary type binding
        ClassFile classFile = (ClassFile)openable;
        IBinaryType binaryType = null;
        if (classFile.isOpen()) {
          // create binary type from info
          IType type = classFile.getType();
          try {
            binaryType = (IBinaryType)((JavaElement)type).getElementInfo();
          } catch (JavaModelException e) {
            // type exists since class file is opened
          }
        } else {
          // create binary type from file
          if (classFile.getPackageFragmentRoot().isArchive()) {
            binaryType = this.builder.createInfoFromClassFileInJar(classFile);
          } else {
            IResource file = classFile.getResource();
            binaryType = this.builder.createInfoFromClassFile(classFile, file);
          }
        }
        if (binaryType != null) {
          try {
            BinaryTypeBinding binaryTypeBinding = this.lookupEnvironment.cacheBinaryType(binaryType, false/*don't need field and method (bug 125067)*/, null /*no access restriction*/);
            remember(binaryType, binaryTypeBinding);
            if (openable.equals(focusOpenable)) {
              focusBinaryBinding = binaryTypeBinding;
            }
          } catch (AbortCompilation e) {
            // classpath problem for this type: ignore
          }
        }
      }
    }
   
    for (int i = 0; i <= this.typeIndex; i++) {
      IGenericType suppliedType = this.typeModels[i];
      if (suppliedType != null && suppliedType.isBinaryType()) {
        // fault in its hierarchy...
        try {
          ReferenceBinding typeBinding = this.typeBindings[i];
          typeBinding.superclass();
          typeBinding.superInterfaces();
        } catch (AbortCompilation e) {
          // classpath problem for this type: ignore
        }
      }
    }   
   
    // complete type bindings (ie. connect super types)
    for (int i = 0; i < unitsIndex; i++) {
      CompilationUnitDeclaration parsedUnit = parsedUnits[i];
      if (parsedUnit != null) {
        try {
          boolean containsLocalType = hasLocalType[i];
          if (containsLocalType) { // NB: no-op if method bodies have been already parsed
            parser.getMethodBodies(parsedUnit);
          }
          // complete type bindings and build fields and methods only for local types
          // (in this case the constructor is needed when resolving local types)
          // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=145333)
          this.lookupEnvironment.completeTypeBindings(parsedUnit, containsLocalType);
View Full Code Here

      ProblemReporter problemReporter =
        new ProblemReporter(
          DefaultErrorHandlingPolicies.proceedWithAllProblems(),
          this.compilerOptions,
          new DefaultProblemFactory());
      this.parser = new Parser(problemReporter, true);
    }
    return this.parser;
  }
View Full Code Here

                  nameRequestor.acceptType(type.getFlags(), packageDeclaration, simpleName, enclosingTypeNames, path, null);
                }
              }
            }
          } else {
            Parser basicParser = getParser();
            org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit unit = (org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit) workingCopy;
            CompilationResult compilationUnitResult = new CompilationResult(unit, 0, 0, this.compilerOptions.maxProblemsPerUnit);
            CompilationUnitDeclaration parsedUnit = basicParser.dietParse(unit, compilationUnitResult);
            if (parsedUnit != null) {
              final char[] packageDeclaration = parsedUnit.currentPackage == null ? CharOperation.NO_CHAR : CharOperation.concatWith(parsedUnit.currentPackage.getImportName(), '.');
              class AllTypeDeclarationsVisitor extends ASTVisitor {
                public boolean visit(TypeDeclaration typeDeclaration, BlockScope blockScope) {
                  return false; // no local/anonymous type
View Full Code Here

              if (pattern.matchesDecodedKey(new QualifiedTypeDeclarationPattern(qualification, simpleName, suffix, matchRule))) {
                nameRequestor.acceptType(type.getFlags(), packageDeclaration, simpleName, enclosingTypeNames, path, null);
              }
            }
          } else {
            Parser basicParser = getParser();
            org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit unit = (org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit) workingCopy;
            CompilationResult compilationUnitResult = new CompilationResult(unit, 0, 0, this.compilerOptions.maxProblemsPerUnit);
            CompilationUnitDeclaration parsedUnit = basicParser.dietParse(unit, compilationUnitResult);
            if (parsedUnit != null) {
              final char[] packageDeclaration = parsedUnit.currentPackage == null
                ? CharOperation.NO_CHAR
                : CharOperation.concatWith(parsedUnit.currentPackage.getImportName(), '.');
              class AllTypeDeclarationsVisitor extends ASTVisitor {
View Full Code Here

    pr.factory = factory;
   
    forCompiler.lookupEnvironment = le;
   
    forCompiler.parser =
      new Parser(
        pr,
        forCompiler.options.parseLiteralExpressionsAsConstants);
   
    return new AjCompilerAdapter(forCompiler,batchCompile,getBcelWorld(),getWeaver(),
            factory,
View Full Code Here

TOP

Related Classes of org.aspectj.org.eclipse.jdt.internal.compiler.parser.Parser

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.