예제 #1
0
 private static IParserNode tryToBuildAst(final IFlexFile file)
     throws IOException, TokenException {
   IParserNode rootNode;
   final IAS3Parser parser = new AS3Parser();
   if (file instanceof IMxmlFile) {
     rootNode = parser.buildAst(file.getFilePath(), ((IMxmlFile) file).getScriptBlock());
   } else {
     rootNode = parser.buildAst(file.getFilePath());
   }
   return rootNode;
 }
예제 #2
0
  /**
   * @param file
   * @return
   * @throws PMDException
   */
  public static IParserNode buildAst(final IFlexFile file) throws PMDException {
    IParserNode rootNode = null;

    try {
      rootNode = tryToBuildAst(file);
    } catch (final IOException e) {
      throw new PMDException("While building AST: Cannot read " + file.getFullyQualifiedName(), e);
    } catch (final TokenException e) {
      throw new PMDException(
          "TokenException thrown while building AST on "
              + file.getFullyQualifiedName()
              + " with message: "
              + e.getMessage(),
          e);
    }
    return rootNode;
  }
예제 #3
0
  /**
   * @param files
   * @return
   * @throws PMDException
   */
  public static Map<String, IPackage> computeAsts(final Map<String, IFlexFile> files)
      throws PMDException {
    final Map<String, IPackage> asts = new LinkedHashMap<String, IPackage>();

    for (final Entry<String, IFlexFile> fileEntry : files.entrySet()) {
      final IFlexFile file = fileEntry.getValue();

      try {
        final IParserNode node = buildThreadedAst(file);

        asts.put(file.getFullyQualifiedName(), NodeFactory.createPackage(node));
      } catch (final InterruptedException e) {
        LOGGER.warning(buildLogMessage(file, e.getMessage()));
      } catch (final NoClassDefFoundError e) {
        LOGGER.warning(buildLogMessage(file, e.getMessage()));
      } catch (final ExecutionException e) {
        LOGGER.warning(buildLogMessage(file, e.getMessage()));
      } catch (final CancellationException e) {
        LOGGER.warning(buildLogMessage(file, e.getMessage()));
      }
    }
    return asts;
  }
예제 #4
0
 /**
  * @param file
  * @param message
  * @return
  */
 protected static String buildLogMessage(final IFlexFile file, final String message) {
   return "While building AST on "
       + file.getFullyQualifiedName()
       + ", an error occured: "
       + message;
 }