/** * @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; }
/** * @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; }
/** * @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; }