You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2014/04/25 08:18:31 UTC

[32/46] FlexPMD Donation from Adobe Systems Inc

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-cpd-maven-plugin/src/main/java/com/adobe/ac/cpd/maven/FlexCpdMojo.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd-maven-plugin/src/main/java/com/adobe/ac/cpd/maven/FlexCpdMojo.java b/FlexPMD/flex-pmd-cpd-maven-plugin/src/main/java/com/adobe/ac/cpd/maven/FlexCpdMojo.java
new file mode 100644
index 0000000..e7481e5
--- /dev/null
+++ b/FlexPMD/flex-pmd-cpd-maven-plugin/src/main/java/com/adobe/ac/cpd/maven/FlexCpdMojo.java
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.cpd.maven;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.Map.Entry;
+
+import net.sourceforge.pmd.PMDException;
+import net.sourceforge.pmd.cpd.CPD;
+import net.sourceforge.pmd.cpd.FileReporter;
+import net.sourceforge.pmd.cpd.Renderer;
+import net.sourceforge.pmd.cpd.ReportException;
+import net.sourceforge.pmd.cpd.XMLRenderer;
+
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.reporting.AbstractMavenReport;
+import org.apache.maven.reporting.MavenReportException;
+import org.codehaus.doxia.site.renderer.SiteRenderer;
+
+import com.adobe.ac.cpd.FlexLanguage;
+import com.adobe.ac.pmd.LoggerUtils;
+import com.adobe.ac.pmd.files.IFlexFile;
+import com.adobe.ac.pmd.files.impl.FileUtils;
+
+/**
+ * @author xagnetti
+ * @goal check
+ * @phase verify
+ */
+public class FlexCpdMojo extends AbstractMavenReport
+{
+   private static final String OUTPUT_NAME = "cpd";
+
+   protected static ResourceBundle getBundle( final Locale locale )
+   {
+      return ResourceBundle.getBundle( "flexPmd",
+                                       locale,
+                                       FlexCpdMojo.class.getClassLoader() ); // NOPMD
+   }
+
+   private final String encoding = System.getProperty( "file.encoding" );
+
+   /**
+    * Location of the file.
+    * 
+    * @parameter expression="25"
+    * @required
+    */
+   private int          minimumTokenCount;
+
+   /**
+    * Location of the file.
+    * 
+    * @parameter expression="${project.build.directory}"
+    * @required
+    */
+   private File         outputDirectory;
+
+   /**
+    * @parameter expression="${project}"
+    * @required
+    * @readonly
+    */
+   private MavenProject project;
+
+   /**
+    * @parameter 
+    *            expression="${component.org.codehaus.doxia.site.renderer.SiteRenderer}"
+    * @required
+    * @readonly
+    */
+   private SiteRenderer siteRenderer;
+
+   /**
+    * Specifies the location of the source files to be used.
+    * 
+    * @parameter expression="${project.build.sourceDirectory}"
+    * @required
+    * @readonly
+    */
+   private File         sourceDirectory;
+
+   public FlexCpdMojo()
+   {
+      super();
+   }
+
+   public FlexCpdMojo( final File outputDirectoryToBeSet,
+                       final File sourceDirectoryToBeSet,
+                       final MavenProject projectToBeSet )
+   {
+      super();
+      outputDirectory = outputDirectoryToBeSet;
+      sourceDirectory = sourceDirectoryToBeSet;
+      project = projectToBeSet;
+      minimumTokenCount = 25;
+   }
+
+   public String getDescription( final Locale locale )
+   {
+      return getBundle( locale ).getString( "report.flexCpd.description" );
+   }
+
+   public final String getName( final Locale locale )
+   {
+      return getBundle( locale ).getString( "report.flexCpd.name" );
+   }
+
+   public final String getOutputName()
+   {
+      return OUTPUT_NAME;
+   }
+
+   void setSiteRenderer( final SiteRenderer site )
+   {
+      siteRenderer = site;
+   }
+
+   @Override
+   protected void executeReport( final Locale locale ) throws MavenReportException
+   {
+      new LoggerUtils().loadConfiguration();
+
+      final CPD cpd = new CPD( minimumTokenCount, new FlexLanguage() );
+
+      try
+      {
+         final Map< String, IFlexFile > files = FileUtils.computeFilesList( sourceDirectory,
+                                                                            null,
+                                                                            "",
+                                                                            null );
+
+         for ( final Entry< String, IFlexFile > fileEntry : files.entrySet() )
+         {
+            cpd.add( new File( fileEntry.getValue().getFilePath() ) ); // NOPMD
+         }
+
+         cpd.go();
+
+         report( cpd );
+      }
+      catch ( final PMDException e )
+      {
+         throw new MavenReportException( "", e );
+      }
+      catch ( final IOException e )
+      {
+         throw new MavenReportException( "", e );
+      }
+      catch ( final ReportException e )
+      {
+         throw new MavenReportException( "", e );
+      }
+   }
+
+   @Override
+   protected String getOutputDirectory()
+   {
+      return outputDirectory.getAbsolutePath();
+   }
+
+   @Override
+   protected MavenProject getProject()
+   {
+      return project;
+   }
+
+   @Override
+   protected SiteRenderer getSiteRenderer()
+   {
+      return siteRenderer;
+   }
+
+   private void report( final CPD cpd ) throws ReportException
+   {
+      final Renderer renderer = new XMLRenderer( encoding );
+      final FileReporter reporter = new FileReporter( new File( outputDirectory.getAbsolutePath(),
+                                                                OUTPUT_NAME
+                                                                      + ".xml" ), encoding );
+      reporter.report( renderer.render( cpd.getMatches() ) );
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-cpd-maven-plugin/src/main/resources/flexPmd.properties
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd-maven-plugin/src/main/resources/flexPmd.properties b/FlexPMD/flex-pmd-cpd-maven-plugin/src/main/resources/flexPmd.properties
new file mode 100644
index 0000000..238be18
--- /dev/null
+++ b/FlexPMD/flex-pmd-cpd-maven-plugin/src/main/resources/flexPmd.properties
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+report.flexCpd.name=

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-cpd-maven-plugin/src/test/java/com/adobe/ac/cpd/maven/FlexCpdMojoTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd-maven-plugin/src/test/java/com/adobe/ac/cpd/maven/FlexCpdMojoTest.java b/FlexPMD/flex-pmd-cpd-maven-plugin/src/test/java/com/adobe/ac/cpd/maven/FlexCpdMojoTest.java
new file mode 100644
index 0000000..93d09cb
--- /dev/null
+++ b/FlexPMD/flex-pmd-cpd-maven-plugin/src/test/java/com/adobe/ac/cpd/maven/FlexCpdMojoTest.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.cpd.maven;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.codehaus.doxia.site.renderer.DefaultSiteRenderer;
+import org.junit.Test;
+
+import com.adobe.ac.pmd.FlexPmdTestBase;
+
+public class FlexCpdMojoTest extends FlexPmdTestBase
+{
+   @Test
+   public void testExecute() throws MojoExecutionException,
+                            IOException
+   {
+      final FlexCpdMojo mojo = new FlexCpdMojo( new File( "target" ),
+                                                getTestDirectory(),
+                                                new MavenProjectStub() );
+
+      mojo.setSiteRenderer( new DefaultSiteRenderer() );
+      mojo.execute();
+   }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-cpd/pom.xml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd/pom.xml b/FlexPMD/flex-pmd-cpd/pom.xml
new file mode 100644
index 0000000..c0ac9ec
--- /dev/null
+++ b/FlexPMD/flex-pmd-cpd/pom.xml
@@ -0,0 +1,93 @@
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>com.adobe.ac</groupId>
+	<artifactId>flex-pmd-cpd</artifactId>
+	<name>Adobe Flex CPD (Copy and Past Detector)</name>
+
+  <parent>
+	<groupId>com.adobe.ac</groupId>
+	<artifactId>flex-pmd-java-parent</artifactId>
+	<version>1.3-SNAPSHOT</version>
+	<relativePath>../flex-pmd-java-parent/pom.xml</relativePath>
+  </parent>
+  
+	<dependencies>
+
+		<dependency>
+			<groupId>pmd</groupId>
+			<artifactId>pmd</artifactId>
+			<version>${pmd.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>${project.groupId}</groupId>
+			<version>${project.parent.version}</version>
+			<artifactId>as3-parser</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>${project.parent.groupId}</groupId>
+			<artifactId>flex-pmd-test-resources</artifactId>
+			<version>${project.parent.version}</version>
+			<classifier>resources</classifier>
+			<type>zip</type>
+			<scope>provided</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>${project.groupId}</groupId>
+			<version>${project.version}</version>
+			<artifactId>flex-pmd-files</artifactId>
+		</dependency>
+
+	</dependencies>
+
+	<build>
+		<testResources>
+			<testResource>
+				<directory>${project.build.directory}/test/generated-resources</directory>
+			</testResource>
+		</testResources>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-dependency-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>unpack-test-resources</id>
+						<phase>generate-resources</phase>
+						<goals>
+							<goal>unpack-dependencies</goal>
+						</goals>
+						<configuration>
+							<includeGroupIds>${project.groupId}</includeGroupIds>
+							<includes>**/*.as,**/*.mxml</includes>
+							<outputDirectory>${project.build.directory}/test/generated-resources</outputDirectory>
+							<excludeTransitive>true</excludeTransitive>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+	
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexLanguage.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexLanguage.java b/FlexPMD/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexLanguage.java
new file mode 100644
index 0000000..b71ce3f
--- /dev/null
+++ b/FlexPMD/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexLanguage.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.cpd;
+
+import net.sourceforge.pmd.cpd.AbstractLanguage;
+
+public class FlexLanguage extends AbstractLanguage
+{
+   public FlexLanguage()
+   {
+      super( new FlexTokenizer(), "as", "mxml" );
+   }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexTokenizer.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexTokenizer.java b/FlexPMD/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexTokenizer.java
new file mode 100644
index 0000000..252009d
--- /dev/null
+++ b/FlexPMD/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexTokenizer.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.cpd;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+import net.sourceforge.pmd.cpd.SourceCode;
+import net.sourceforge.pmd.cpd.TokenEntry;
+import net.sourceforge.pmd.cpd.Tokenizer;
+import net.sourceforge.pmd.cpd.Tokens;
+
+import com.adobe.ac.pmd.files.IFlexFile;
+import com.adobe.ac.pmd.files.IMxmlFile;
+import com.adobe.ac.pmd.files.impl.FileUtils;
+import com.adobe.ac.pmd.parser.KeyWords;
+import com.adobe.ac.pmd.parser.Operators;
+
+import de.bokelberg.flex.parser.AS3Parser;
+import de.bokelberg.flex.parser.AS3Scanner;
+import de.bokelberg.flex.parser.AS3Scanner.Token;
+
+public class FlexTokenizer implements Tokenizer
+{
+   public static final int            DEFAULT_MINIMUM_TOKENS = 25;
+   private static final Set< String > IGNORED_TOKENS;
+   private static final Set< String > IGNORING_LINE_TOKENS;
+
+   static
+   {
+      IGNORED_TOKENS = new HashSet< String >();
+      IGNORED_TOKENS.add( Operators.SEMI_COLUMN.toString() );
+      IGNORED_TOKENS.add( Operators.LEFT_CURLY_BRACKET.toString() );
+      IGNORED_TOKENS.add( Operators.RIGHT_CURLY_BRACKET.toString() );
+      IGNORED_TOKENS.add( AS3Parser.NEW_LINE );
+      IGNORING_LINE_TOKENS = new HashSet< String >();
+      IGNORING_LINE_TOKENS.add( KeyWords.IMPORT.toString() );
+      IGNORING_LINE_TOKENS.add( KeyWords.PACKAGE.toString() );
+   }
+
+   private static boolean isTokenIgnored( final String tokenText )
+   {
+      return IGNORED_TOKENS.contains( tokenText )
+            || tokenText.startsWith( AS3Parser.MULTIPLE_LINES_COMMENT )
+            || tokenText.startsWith( AS3Parser.SINGLE_LINE_COMMENT );
+   }
+
+   private static boolean isTokenIgnoringLine( final String tokenText )
+   {
+      return IGNORING_LINE_TOKENS.contains( tokenText );
+   }
+
+   public void tokenize( final SourceCode tokens,
+                         final Tokens tokenEntries )
+   {
+      try
+      {
+         final AS3Scanner scanner = initializeScanner( tokens );
+         Token currentToken = scanner.moveToNextToken();
+         int inImportLine = 0;
+
+         while ( currentToken != null
+               && currentToken.getText().compareTo( KeyWords.EOF.toString() ) != 0 )
+         {
+            final String currentTokenText = currentToken.getText();
+            final int currentTokenLine = currentToken.getLine();
+
+            if ( !isTokenIgnored( currentTokenText ) )
+            {
+               if ( isTokenIgnoringLine( currentTokenText ) )
+               {
+                  inImportLine = currentTokenLine;
+               }
+               else
+               {
+                  if ( inImportLine == 0
+                        || inImportLine != currentTokenLine )
+                  {
+                     inImportLine = 0;
+                     tokenEntries.add( new TokenEntry( currentTokenText, // NOPMD
+                                                       tokens.getFileName(),
+                                                       currentTokenLine ) );
+                  }
+               }
+            }
+            currentToken = scanner.moveToNextToken();
+         }
+      }
+      catch ( final Exception e )
+      {
+      }
+      finally
+      {
+         tokenEntries.add( TokenEntry.getEOF() );
+      }
+   }
+
+   private AS3Scanner initializeScanner( final SourceCode tokens )
+   {
+      final AS3Scanner scanner = new AS3Scanner();
+
+      final IFlexFile flexFile = FileUtils.create( new File( tokens.getFileName() ),
+                                                   new File( "" ) );
+
+      if ( flexFile instanceof IMxmlFile )
+      {
+         final IMxmlFile mxml = ( IMxmlFile ) flexFile;
+
+         scanner.setLines( mxml.getScriptBlock() );
+      }
+      else
+      {
+         scanner.setLines( tokens.getCode().toArray( new String[ tokens.getCode().size() ] ) );
+      }
+      return scanner;
+   }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-cpd/src/test/java/com/adobe/ac/cpd/FlexCpdTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd/src/test/java/com/adobe/ac/cpd/FlexCpdTest.java b/FlexPMD/flex-pmd-cpd/src/test/java/com/adobe/ac/cpd/FlexCpdTest.java
new file mode 100644
index 0000000..09b7a75
--- /dev/null
+++ b/FlexPMD/flex-pmd-cpd/src/test/java/com/adobe/ac/cpd/FlexCpdTest.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.cpd;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+import net.sourceforge.pmd.cpd.CPD;
+import net.sourceforge.pmd.cpd.Match;
+
+import org.junit.Test;
+
+import com.adobe.ac.pmd.FlexPmdTestBase;
+import com.adobe.ac.pmd.files.IFlexFile;
+
+public class FlexCpdTest extends FlexPmdTestBase
+{
+   private class ExpectedMatchInformation
+   {
+      private final int lineCount;
+      private final int markCount;
+      private final int tokenCount;
+
+      public ExpectedMatchInformation( final int tokenCountToBeSet,
+                                       final int markCountToBeSet,
+                                       final int lineCountToBeSet )
+      {
+         lineCount = lineCountToBeSet;
+         tokenCount = tokenCountToBeSet;
+         markCount = markCountToBeSet;
+      }
+   }
+   final ExpectedMatchInformation[] EXPECTED = new ExpectedMatchInformation[]
+                                             { new ExpectedMatchInformation( 107, 2, 7 ),
+               new ExpectedMatchInformation( 79, 2, 17 ),
+               new ExpectedMatchInformation( 77, 2, 6 ),
+               new ExpectedMatchInformation( 76, 2, 18 ),
+               new ExpectedMatchInformation( 64, 2, 7 ),
+               new ExpectedMatchInformation( 60, 3, 14 ),
+               new ExpectedMatchInformation( 57, 2, 7 ),
+               new ExpectedMatchInformation( 54, 2, 9 ),
+               new ExpectedMatchInformation( 53, 2, 8 ),
+               new ExpectedMatchInformation( 48, 2, 18 ) };
+
+   @Test
+   public void test119() throws IOException
+   {
+      final CPD cpd = new CPD( 25, new FlexLanguage() );
+
+      cpd.add( new File( "src/test/resources/test/FlexPMD119.mxml" ) );
+      cpd.go();
+
+      final Iterator< Match > matchIterator = cpd.getMatches();
+      final Match match = matchIterator.next();
+
+      assertEquals( "The first mark is not correct",
+                    41,
+                    match.getFirstMark().getBeginLine() );
+      assertEquals( "The second mark is not correct",
+                    81,
+                    match.getSecondMark().getBeginLine() );
+   }
+
+   @Test
+   public void tokenize() throws IOException
+   {
+      final Iterator< Match > matchIterator = getMatchIterator();
+
+      for ( int currentIndex = 0; matchIterator.hasNext()
+            && currentIndex < EXPECTED.length; currentIndex++ )
+      {
+         final Match currentMatch = matchIterator.next();
+
+         assertEquals( "The token count is not correct on the "
+                             + currentIndex + "th index",
+                       EXPECTED[ currentIndex ].tokenCount,
+                       currentMatch.getTokenCount() );
+
+         assertEquals( "The mark count is not correct on the "
+                             + currentIndex + "th index",
+                       EXPECTED[ currentIndex ].markCount,
+                       currentMatch.getMarkCount() );
+
+         assertEquals( "The line count is not correct on the "
+                             + currentIndex + "th index",
+                       EXPECTED[ currentIndex ].lineCount,
+                       currentMatch.getLineCount() );
+      }
+   }
+
+   private Iterator< Match > getMatchIterator() throws IOException
+   {
+      final CPD cpd = new CPD( 25, new FlexLanguage() );
+
+      for ( final Entry< String, IFlexFile > includedFile : getTestFiles().entrySet() )
+      {
+         cpd.add( new File( includedFile.getValue().getFilePath() ) );
+      }
+      cpd.go();
+
+      return cpd.getMatches();
+   }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-cpd/src/test/resources/test/FlexPMD119.mxml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd/src/test/resources/test/FlexPMD119.mxml b/FlexPMD/flex-pmd-cpd/src/test/resources/test/FlexPMD119.mxml
new file mode 100644
index 0000000..1519ac1
--- /dev/null
+++ b/FlexPMD/flex-pmd-cpd/src/test/resources/test/FlexPMD119.mxml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+<mx:Canvas> 
+	
+	<mx:Script>
+		<![CDATA[
+		
+		// Handle the mouseDown event generated 
+		// by clicking in the application.
+		private function handleMouseDown(event:MouseEvent):void {
+		
+		// Convert the mouse position to global coordinates.
+		// The localX and localY properties of the mouse event contain
+		// the coordinates at which the event occurred relative to the
+		// event target, typically one of the 
+		// colored internal Canvas controls.
+		// A production version of this example could use the stageX 
+		// and stageY properties, which use the global coordinates, 
+		// and avoid this step.
+		// This example uses the localX and localY properties only to
+		// illustrate conversion between different frames of reference.
+		var pt:Point = new Point(event.localX, event.localY);
+		pt = event.target.localToGlobal(pt);
+		
+		// Convert the global coordinates to the content coordinates 
+		// inside the outer c1 Canvas control.
+		pt = c1.globalToContent(pt);
+		
+		// Figure out which quadrant was clicked.
+		var whichColor:String = "border area";
+		
+		if (pt.x < 150) {
+		if (pt.y < 150)
+		whichColor = "red";
+		else
+		whichColor = "blue";
+		}
+		else {
+		if (pt.y < 150)
+		whichColor = "green";
+		else
+		whichColor = "magenta";
+		}
+		
+		Alert.show("You clicked on the " + whichColor);
+		}
+		
+		// Handle the mouseDown event generated 
+		// by clicking in the application.
+		private function handleMouseDown(event:MouseEvent):void {
+		
+		// Convert the mouse position to global coordinates.
+		// The localX and localY properties of the mouse event contain
+		// the coordinates at which the event occurred relative to the
+		// event target, typically one of the 
+		// colored internal Canvas controls.
+		// A production version of this example could use the stageX 
+		// and stageY properties, which use the global coordinates, 
+		// and avoid this step.
+		// This example uses the localX and localY properties only to
+		// illustrate conversion between different frames of reference.
+		var pt:Point = new Point(event.localX, event.localY);
+		pt = event.target.localToGlobal(pt);
+		
+		// Convert the global coordinates to the content coordinates 
+		// inside the outer c1 Canvas control.
+		pt = c1.globalToContent(pt);
+		
+		// Figure out which quadrant was clicked.
+		var whichColor:String = "border area";
+		
+		if (pt.x < 150) {
+		if (pt.y < 150)
+		whichColor = "red";
+		else
+		whichColor = "blue";
+		}
+		else {
+		if (pt.y < 150)
+		whichColor = "green";
+		else
+		whichColor = "magenta";
+		}
+		
+		Alert.show("You clicked on the " + whichColor);
+		}
+		]]>
+	</mx:Script>
+	
+</mx:Canvas>

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-files/pom.xml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-files/pom.xml b/FlexPMD/flex-pmd-files/pom.xml
new file mode 100644
index 0000000..0ae0148
--- /dev/null
+++ b/FlexPMD/flex-pmd-files/pom.xml
@@ -0,0 +1,82 @@
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>com.adobe.ac</groupId>
+  <artifactId>flex-pmd-files</artifactId>
+  <name>Adobe Flex PMD Files</name>
+
+  <parent>
+	<groupId>com.adobe.ac</groupId>
+	<artifactId>flex-pmd-java-parent</artifactId>
+	<version>1.3-SNAPSHOT</version>
+	<relativePath>../flex-pmd-java-parent/pom.xml</relativePath>
+  </parent>
+  
+	<dependencies>
+		<dependency>
+			<groupId>commons-lang</groupId>
+			<artifactId>commons-lang</artifactId>
+			<version>${commons-lang.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>${project.parent.groupId}</groupId>
+			<artifactId>as3-plugin-utils</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>${project.parent.groupId}</groupId>
+			<artifactId>flex-pmd-test-resources</artifactId>
+			<version>${project.version}</version>
+			<classifier>resources</classifier>
+			<type>zip</type>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<testResources>
+			<testResource>
+				<directory>${project.build.directory}/test/generated-resources</directory>
+			</testResource>
+		</testResources>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-dependency-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>unpack-test-resources</id>
+						<phase>generate-resources</phase>
+						<goals>
+							<goal>unpack-dependencies</goal>
+						</goals>
+						<configuration>
+							<includeGroupIds>${project.groupId}</includeGroupIds>
+							<includes>**/*.as,**/*.mxml</includes>
+							<outputDirectory>${project.build.directory}/test/generated-resources</outputDirectory>
+							<excludeTransitive>true</excludeTransitive>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/FlexPmdTestBase.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/FlexPmdTestBase.java b/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/FlexPmdTestBase.java
new file mode 100644
index 0000000..c3e3b5d
--- /dev/null
+++ b/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/FlexPmdTestBase.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd;
+
+import java.io.File;
+import java.util.Map;
+
+import com.adobe.ac.pmd.files.IFlexFile;
+
+/**
+ * This is a base class for any FlexPMD rule test case.
+ * 
+ * @author xagnetti
+ */
+public class FlexPmdTestBase // NO_UCD
+{
+   protected static final String    BEGIN_LINE_NOT_CORRECT        = "Begining line is not correct";     // NO_UCD
+   protected static final String    END_LINE_NOT_CORRECT          = "Ending line is not correct";       // NO_UCD
+   protected static final String    VIOLATIONS_NUMBER_NOT_CORRECT = "Violations number is not correct"; // NO_UCD
+
+   /**
+    * Test files placeholder. The key is the qualified file name
+    */
+   private Map< String, IFlexFile > testFiles                     = ResourcesManagerTest.getInstance()
+                                                                                        .getTestFiles();
+
+   /**
+    * 
+    */
+   protected FlexPmdTestBase()
+   {
+   }
+
+   /**
+    * @return
+    */
+   protected File getTestDirectory() // NO_UCD
+   {
+      return ResourcesManagerTest.getInstance().getTestRootDirectory();
+   }
+
+   /**
+    * @return
+    */
+   protected final Map< String, IFlexFile > getTestFiles() // NO_UCD
+   {
+      return testFiles;
+   }
+
+   /**
+    * @param testFilesToBeSet
+    */
+   protected final void setTestFiles( final Map< String, IFlexFile > testFilesToBeSet )
+   {
+      testFiles = testFilesToBeSet;
+   }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/ResourcesManagerTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/ResourcesManagerTest.java b/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/ResourcesManagerTest.java
new file mode 100644
index 0000000..5986888
--- /dev/null
+++ b/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/ResourcesManagerTest.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import net.sourceforge.pmd.PMDException;
+
+import com.adobe.ac.pmd.files.IFlexFile;
+import com.adobe.ac.pmd.files.impl.FileUtils;
+import com.adobe.ac.utils.StackTraceUtils;
+
+/**
+ * Internal utility which finds out the test resources, and map them to their
+ * qualified names.
+ * 
+ * @author xagnetti
+ */
+public final class ResourcesManagerTest
+{
+   private static ResourcesManagerTest instance = null;
+   private static final Logger         LOGGER   = Logger.getLogger( ResourcesManagerTest.class.getName() );
+
+   /**
+    * @return
+    */
+   public static synchronized ResourcesManagerTest getInstance() // NOPMD
+   {
+      if ( instance == null )
+      {
+         try
+         {
+            new LoggerUtils().loadConfiguration();
+            instance = new ResourcesManagerTest( "/test" );
+         }
+         catch ( final URISyntaxException e )
+         {
+            LOGGER.warning( StackTraceUtils.print( e ) );
+         }
+         catch ( final PMDException e )
+         {
+            LOGGER.warning( StackTraceUtils.print( e ) );
+         }
+      }
+      return instance;
+   }
+
+   private final Map< String, IFlexFile > testFiles;
+   private final File                     testRootDirectory;
+
+   private ResourcesManagerTest( final String directory ) throws URISyntaxException,
+                                                         PMDException
+   {
+      final URL resource = this.getClass().getResource( directory );
+
+      if ( resource == null )
+      {
+         LOGGER.severe( directory
+               + " folder is not found in the resource" );
+         testRootDirectory = null;
+         testFiles = new LinkedHashMap< String, IFlexFile >();
+      }
+      else
+      {
+         testRootDirectory = new File( resource.toURI().getPath() );
+         testFiles = FileUtils.computeFilesList( testRootDirectory,
+                                                 null,
+                                                 "",
+                                                 null );
+      }
+   }
+
+   /**
+    * @return
+    */
+   public Map< String, IFlexFile > getTestFiles()
+   {
+      return testFiles;
+   }
+
+   protected File getTestRootDirectory()
+   {
+      return testRootDirectory;
+   }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IAs3File.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IAs3File.java b/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IAs3File.java
new file mode 100644
index 0000000..4997eeb
--- /dev/null
+++ b/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IAs3File.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.files;
+
+/**
+ * @author xagnetti
+ */
+public interface IAs3File extends IFlexFile
+{
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IFlexFile.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IFlexFile.java b/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IFlexFile.java
new file mode 100644
index 0000000..21adb01
--- /dev/null
+++ b/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IFlexFile.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.files;
+
+import java.util.Set;
+
+/**
+ * @author xagnetti
+ */
+public interface IFlexFile
+{
+   /**
+    * @param stringToLookup
+    * @param linesToBeIgnored
+    * @return
+    */
+   boolean contains( final String stringToLookup,
+                     final Set< Integer > linesToBeIgnored );
+
+   /**
+    * @return
+    */
+   String getClassName();
+
+   /**
+    * @return the token for comment closing
+    */
+   String getCommentClosingTag();
+
+   /**
+    * @return the token for comment opening
+    */
+   String getCommentOpeningTag();
+
+   /**
+    * @return java.io.File name
+    */
+   String getFilename();
+
+   /**
+    * @return java.io.File absolute path
+    */
+   String getFilePath();
+
+   /**
+    * @return
+    */
+   String getFullyQualifiedName();
+
+   /**
+    * @param lineIndex
+    * @return
+    */
+   String getLineAt( int lineIndex );
+
+   /**
+    * @return
+    */
+   int getLinesNb();
+
+   /**
+    * @return
+    */
+   String getPackageName();
+
+   /**
+    * @return the token for one line comment
+    */
+   String getSingleLineComment();
+
+   /**
+    * @return true if the file is a main MXML file
+    */
+   boolean isMainApplication();
+
+   /**
+    * @return true if the file is a MXML file
+    */
+   boolean isMxml();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IMxmlFile.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IMxmlFile.java b/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IMxmlFile.java
new file mode 100644
index 0000000..1d98c98
--- /dev/null
+++ b/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IMxmlFile.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.files;
+
+/**
+ * @author xagnetti
+ */
+public interface IMxmlFile extends IFlexFile
+{
+   /**
+    * @return
+    */
+   String[] getActualScriptBlock();
+
+   /**
+    * @return
+    */
+   int getBeginningScriptBlock();
+
+   /**
+    * @return
+    */
+   int getEndingScriptBlock();
+
+   /**
+    * @return
+    */
+   String[] getScriptBlock();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/AbstractFlexFile.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/AbstractFlexFile.java b/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/AbstractFlexFile.java
new file mode 100644
index 0000000..986f2a7
--- /dev/null
+++ b/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/AbstractFlexFile.java
@@ -0,0 +1,259 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.files.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import org.apache.commons.lang.StringUtils;
+
+import com.adobe.ac.pmd.files.IFlexFile;
+import com.adobe.ac.utils.StackTraceUtils;
+
+/**
+ * Abstract class representing a Flex File (either MXML or AS)
+ * 
+ * @author xagnetti
+ */
+abstract class AbstractFlexFile implements IFlexFile
+{
+   private static final Logger LOGGER = Logger.getLogger( AbstractFlexFile.class.getName() );
+
+   /**
+    * @param filePath
+    * @param rootPath
+    * @param className
+    * @param fileSeparator
+    * @return
+    */
+   protected static String computePackageName( final String filePath,
+                                               final CharSequence rootPath,
+                                               final String className,
+                                               final String fileSeparator )
+   {
+      String temporaryPackage;
+
+      temporaryPackage = filePath.replace( className,
+                                           "" ).replace( rootPath,
+                                                         "" ).replace( fileSeparator,
+                                                                       "." );
+      if ( temporaryPackage.endsWith( "." ) )
+      {
+         temporaryPackage = temporaryPackage.substring( 0,
+                                                        temporaryPackage.length() - 1 );
+      }
+      if ( temporaryPackage.length() > 0
+            && temporaryPackage.charAt( 0 ) == '.' )
+      {
+         temporaryPackage = temporaryPackage.substring( 1,
+                                                        temporaryPackage.length() );
+      }
+      return temporaryPackage;
+   }
+
+   private static boolean doesCurrentLineContain( final String line,
+                                                  final String search )
+   {
+      return line.contains( search );
+   }
+
+   private final String         className;
+   private final File           file;
+   private final List< String > lines;
+   private final String         packageName;
+
+   /**
+    * @param underlyingFile
+    * @param rootDirectory
+    */
+   protected AbstractFlexFile( final File underlyingFile,
+                               final File rootDirectory )
+   {
+      final String filePath = underlyingFile.getPath();
+      final CharSequence rootPath = rootDirectory == null ? ""
+                                                         : rootDirectory.getPath();
+
+      file = underlyingFile;
+      className = underlyingFile.getName();
+      packageName = computePackageName( filePath,
+                                        rootPath,
+                                        className,
+                                        System.getProperty( "file.separator" ) );
+      lines = new ArrayList< String >();
+      try
+      {
+         String[] linesArray;
+         linesArray = FileUtils.readLines( underlyingFile );
+         for ( final String string : linesArray )
+         {
+            lines.add( string );
+         }
+      }
+      catch ( final IOException e )
+      {
+         LOGGER.warning( StackTraceUtils.print( e ) );
+      }
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#contains(java.lang.String, int)
+    */
+   public final boolean contains( final String stringToLookup,
+                                  final Set< Integer > linesToBeIgnored )
+   {
+      int lineIndex = 1;
+      boolean found = false;
+
+      for ( final String line : lines )
+      {
+         if ( doesCurrentLineContain( line,
+                                      stringToLookup )
+               && !linesToBeIgnored.contains( lineIndex ) )
+         {
+            found = true;
+            break;
+         }
+         lineIndex++;
+      }
+      return found;
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see java.lang.Object#equals(java.lang.Object)
+    */
+   @Override
+   public final boolean equals( final Object obj )
+   {
+      return obj != null
+            && obj instanceof AbstractFlexFile && hashCode() == ( ( AbstractFlexFile ) obj ).hashCode();
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getClassName()
+    */
+   public final String getClassName()
+   {
+      return className;
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getCommentClosingTag()
+    */
+   public abstract String getCommentClosingTag();
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getCommentOpeningTag()
+    */
+   public abstract String getCommentOpeningTag();
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getFilename()
+    */
+   public final String getFilename()
+   {
+      return file.getName();
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getFilePath()
+    */
+   public final String getFilePath()
+   {
+      return file.toURI().getPath();
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getFullyQualifiedName()
+    */
+   public final String getFullyQualifiedName()
+   {
+      return ( StringUtils.isEmpty( packageName ) ? ""
+                                                 : packageName
+                                                       + "." )
+            + className;
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getLineAt(int)
+    */
+   public String getLineAt( final int lineIndex )
+   {
+      return lines.get( lineIndex - 1 );
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getLines()
+    */
+   public final List< String > getLines()
+   {
+      return lines;
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getLinesNb()
+    */
+   public int getLinesNb()
+   {
+      return lines.size();
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getPackageName()
+    */
+   public final String getPackageName()
+   {
+      return packageName;
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see java.lang.Object#hashCode()
+    */
+   @Override
+   public int hashCode()
+   {
+      return getFilePath().hashCode();
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#isMainApplication()
+    */
+   public abstract boolean isMainApplication();
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#isMxml()
+    */
+   public abstract boolean isMxml();
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/As3File.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/As3File.java b/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/As3File.java
new file mode 100644
index 0000000..d4a3c93
--- /dev/null
+++ b/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/As3File.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.files.impl;
+
+import java.io.File;
+
+import com.adobe.ac.pmd.files.IAs3File;
+
+/**
+ * @author xagnetti
+ */
+class As3File extends AbstractFlexFile implements IAs3File
+{
+   /**
+    * @param file
+    * @param rootDirectory
+    */
+   protected As3File( final File file,
+                      final File rootDirectory )
+   {
+      super( file, rootDirectory );
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.impl.AbstractFlexFile#getCommentClosingTag()
+    */
+   @Override
+   public final String getCommentClosingTag()
+   {
+      return "*/";
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.impl.AbstractFlexFile#getCommentOpeningTag()
+    */
+   @Override
+   public final String getCommentOpeningTag()
+   {
+      return "/*";
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getSingleLineComment()
+    */
+   public String getSingleLineComment()
+   {
+      return "//";
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.impl.AbstractFlexFile#isMainApplication()
+    */
+   @Override
+   public final boolean isMainApplication()
+   {
+      return false;
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.impl.AbstractFlexFile#isMxml()
+    */
+   @Override
+   public final boolean isMxml()
+   {
+      return false;
+   }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/FileUtils.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/FileUtils.java b/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/FileUtils.java
new file mode 100644
index 0000000..12450f8
--- /dev/null
+++ b/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/FileUtils.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.files.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.pmd.PMDException;
+
+import com.adobe.ac.ncss.filters.FlexFilter;
+import com.adobe.ac.pmd.files.IFlexFile;
+
+/**
+ * @author xagnetti
+ */
+public final class FileUtils
+{
+   /**
+    * @param source
+    * @param sourceList
+    * @param packageToExclude
+    * @param excludePatterns
+    * @return
+    * @throws PMDException
+    */
+   public static Map< String, IFlexFile > computeFilesList( final File source,
+                                                            final List< File > sourceList,
+                                                            final String packageToExclude,
+                                                            final List< String > excludePatterns ) throws PMDException
+   {
+      final Map< String, IFlexFile > files = new LinkedHashMap< String, IFlexFile >();
+      final FlexFilter flexFilter = new FlexFilter();
+      final Collection< File > foundFiles = getFlexFiles( source,
+                                                          sourceList,
+                                                          flexFilter );
+
+      for ( final File sourceFile : foundFiles )
+      {
+         final AbstractFlexFile file = create( sourceFile,
+                                               source );
+
+         if ( ( "".equals( packageToExclude ) || !file.getFullyQualifiedName().startsWith( packageToExclude ) )
+               && !currentPackageIncludedInExcludePatterns( file.getFullyQualifiedName(),
+                                                            excludePatterns ) )
+         {
+            files.put( file.getFullyQualifiedName(),
+                       file );
+         }
+      }
+
+      return files;
+   }
+
+   /**
+    * @param sourceFile
+    * @param sourceDirectory
+    * @return
+    */
+   public static AbstractFlexFile create( final File sourceFile,
+                                          final File sourceDirectory )
+   {
+      AbstractFlexFile file;
+
+      if ( sourceFile.getName().endsWith( ".as" ) )
+      {
+         file = new As3File( sourceFile, sourceDirectory );
+      }
+      else
+      {
+         file = new MxmlFile( sourceFile, sourceDirectory );
+      }
+
+      return file;
+   }
+
+   /**
+    * @param file
+    * @return
+    * @throws IOException
+    */
+   public static String[] readLines( final File file ) throws IOException
+   {
+      final List< String > lines = com.adobe.ac.ncss.utils.FileUtils.readFile( file );
+
+      return lines.toArray( new String[ lines.size() ] );
+   }
+
+   private static boolean currentPackageIncludedInExcludePatterns( final String fullyQualifiedName,
+                                                                   final List< String > excludePatterns )
+   {
+      if ( excludePatterns != null )
+      {
+         for ( final String excludePattern : excludePatterns )
+         {
+            if ( fullyQualifiedName.startsWith( excludePattern ) )
+            {
+               return true;
+            }
+         }
+      }
+      return false;
+   }
+
+   private static Collection< File > getFlexFiles( final File source,
+                                                   final List< File > sourceList,
+                                                   final FlexFilter flexFilter ) throws PMDException
+   {
+      if ( source == null
+            && sourceList == null )
+      {
+         throw new PMDException( "sourceDirectory is not specified", null );
+      }
+      Collection< File > foundFiles;
+      if ( source == null )
+      {
+         foundFiles = com.adobe.ac.ncss.utils.FileUtils.listFiles( sourceList,
+                                                                   flexFilter,
+                                                                   true );
+      }
+      else
+      {
+         if ( source.isDirectory() )
+         {
+            foundFiles = com.adobe.ac.ncss.utils.FileUtils.listFiles( source,
+                                                                      flexFilter,
+                                                                      true );
+         }
+         else
+         {
+            foundFiles = new ArrayList< File >();
+            foundFiles.add( source );
+         }
+      }
+      if ( foundFiles.isEmpty() )
+      {
+         return new ArrayList< File >();
+      }
+      return foundFiles;
+   }
+
+   private FileUtils()
+   {
+   }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/MxmlFile.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/MxmlFile.java b/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/MxmlFile.java
new file mode 100644
index 0000000..7438c53
--- /dev/null
+++ b/FlexPMD/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/MxmlFile.java
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.files.impl;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.adobe.ac.pmd.files.IMxmlFile;
+
+/**
+ * @author xagnetti
+ */
+class MxmlFile extends AbstractFlexFile implements IMxmlFile
+{
+   private static final String METADATA_TAG    = "Metadata";
+   private String[]            actualScriptBlock;
+   private int                 endLine;
+   private boolean             mainApplication = false;
+   private String[]            scriptBlock;
+   private int                 startLine;
+
+   /**
+    * @param file
+    * @param rootDirectory
+    */
+   protected MxmlFile( final File file,
+                       final File rootDirectory )
+   {
+      super( file, rootDirectory );
+
+      computeIfIsMainApplication();
+      if ( getLinesNb() > 0 )
+      {
+         extractScriptBlock();
+      }
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IMxmlFile#getActualScriptBlock()
+    */
+   public final String[] getActualScriptBlock()
+   {
+      return actualScriptBlock; // NOPMD
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IMxmlFile#getBeginningScriptBlock()
+    */
+   public int getBeginningScriptBlock()
+   {
+      return startLine;
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.impl.AbstractFlexFile#getCommentClosingTag()
+    */
+   @Override
+   public final String getCommentClosingTag()
+   {
+      return "-->";
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.impl.AbstractFlexFile#getCommentOpeningTag()
+    */
+   @Override
+   public final String getCommentOpeningTag()
+   {
+      return "<!--";
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IMxmlFile#getEndingScriptBlock()
+    */
+   public int getEndingScriptBlock()
+   {
+      return endLine;
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IMxmlFile#getScriptBlock()
+    */
+   public final String[] getScriptBlock()
+   {
+      return scriptBlock; // NOPMD by xagnetti on 7/7/09 3:15 PM
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getSingleLineComment()
+    */
+   public String getSingleLineComment()
+   {
+      return getCommentOpeningTag();
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.impl.AbstractFlexFile#isMainApplication()
+    */
+   @Override
+   public final boolean isMainApplication()
+   {
+      return mainApplication;
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.impl.AbstractFlexFile#isMxml()
+    */
+   @Override
+   public final boolean isMxml()
+   {
+      return true;
+   }
+
+   private void computeIfIsMainApplication()
+   {
+      for ( final String line : getLines() )
+      {
+         if ( line.contains( "Application " )
+               && line.charAt( 0 ) == '<' )
+         {
+            mainApplication = true;
+            break;
+         }
+      }
+   }
+
+   private int computeScriptOffSet( final int startingLineIndex )
+   {
+      int currentLineIndex = startingLineIndex + 1;
+      while ( getLines().get( currentLineIndex ).contains( "CDATA[" )
+            || getLines().get( currentLineIndex ).contains( "//" ) || containsCloseComment( currentLineIndex )
+            || getLines().get( currentLineIndex ).trim().equals( "" ) )
+      {
+         currentLineIndex++;
+      }
+      return currentLineIndex
+            - startingLineIndex;
+   }
+
+   private boolean containsCloseComment( final int currentLineIndex )
+   {
+      final boolean closedAsComment = getLines().get( currentLineIndex ).contains( "/*" )
+            && getLines().get( currentLineIndex ).contains( "*/" );
+      final boolean closeMxmlComment = getLines().get( currentLineIndex ).contains( "<!--" )
+            && getLines().get( currentLineIndex ).contains( "-->" );
+      return closedAsComment
+            || closeMxmlComment;
+   }
+
+   private void copyScriptLinesKeepingOriginalLineIndices()
+   {
+      final List< String > scriptLines = extractScriptLines();
+      final List< String > metaDataLines = extractMetaDataLines();
+      final String packageLine = "package "
+            + getPackageName() + "{";
+      final String classLine = "class "
+            + getClassName().split( "\\." )[ 0 ] + "{";
+
+      scriptLines.set( 0,
+                       packageLine );
+
+      if ( metaDataLines.isEmpty()
+            || metaDataLines.get( 0 ).compareTo( "HostComponent" ) == 0 )
+      {
+         if ( scriptLines.size() > 1 )
+         {
+            scriptLines.set( 1,
+                             classLine );
+         }
+      }
+      else
+      {
+         final int firstMetaDataLine = getFirstMetaDataLine( getLines() );
+
+         for ( int i = firstMetaDataLine; i < firstMetaDataLine
+               + metaDataLines.size(); i++ )
+         {
+            scriptLines.set( i,
+                             metaDataLines.get( i
+                                   - firstMetaDataLine ) );
+         }
+         scriptLines.set( firstMetaDataLine
+                                + metaDataLines.size(),
+                          classLine );
+      }
+
+      scriptLines.set( scriptLines.size() - 1,
+                       "}}" );
+      scriptBlock = scriptLines.toArray( new String[ scriptLines.size() ] );
+   }
+
+   private List< String > extractMetaDataLines()
+   {
+      final ArrayList< String > metaDataLines = new ArrayList< String >();
+      int currentLineIndex = 0;
+      int start = 0;
+      int end = 0;
+
+      for ( final String line : getLines() )
+      {
+         if ( line.contains( METADATA_TAG ) )
+         {
+            if ( line.contains( "</" ) )
+            {
+               end = currentLineIndex
+                     - ( getLines().get( currentLineIndex - 1 ).contains( "]]>" ) ? 1
+                                                                                 : 0 );
+               if ( line.contains( "<fx" )
+                     || line.contains( "<mx" ) )
+               {
+                  start = end;
+               }
+               break;
+            }
+            if ( line.contains( "<" ) )
+            {
+               start = currentLineIndex
+                     + ( getLines().get( currentLineIndex + 1 ).contains( "CDATA[" ) ? 2
+                                                                                    : 1 );
+            }
+         }
+         currentLineIndex++;
+      }
+      metaDataLines.addAll( getLines().subList( start,
+                                                end ) );
+      return metaDataLines;
+   }
+
+   private void extractScriptBlock()
+   {
+      int currentLineIndex = 0;
+      startLine = 0;
+      endLine = 0;
+
+      for ( final String line : getLines() )
+      {
+         if ( line.contains( "Script" ) )
+         {
+            if ( line.contains( "</" ) )
+            {
+               endLine = currentLineIndex
+                     - ( getLines().get( currentLineIndex - 1 ).contains( "]]>" ) ? 1
+                                                                                 : 0 );
+               break;
+            }
+            else if ( line.contains( "<" ) )
+            {
+               startLine = currentLineIndex
+                     + computeScriptOffSet( currentLineIndex );
+            }
+         }
+         currentLineIndex++;
+      }
+
+      copyScriptLinesKeepingOriginalLineIndices();
+   }
+
+   private List< String > extractScriptLines()
+   {
+      final List< String > scriptLines = new ArrayList< String >();
+
+      for ( int j = 0; j < startLine; j++ )
+      {
+         scriptLines.add( "" );
+      }
+      if ( startLine < endLine )
+      {
+         actualScriptBlock = getLines().subList( startLine,
+                                                 endLine ).toArray( new String[ endLine
+               - startLine ] );
+         scriptLines.addAll( new ArrayList< String >( getLines().subList( startLine,
+                                                                          endLine ) ) );
+      }
+      for ( int j = endLine; j < getLines().size(); j++ )
+      {
+         scriptLines.add( "" );
+      }
+      return scriptLines;
+   }
+
+   private int getFirstMetaDataLine( final List< String > lines )
+   {
+      for ( int i = 0; i < lines.size(); i++ )
+      {
+         final String line = lines.get( i );
+
+         if ( line.contains( METADATA_TAG )
+               && line.contains( "<" ) )
+         {
+            return i;
+         }
+      }
+      return 0;
+   }
+
+   // private String printMetaData( final List< String > metaDataLines )
+   // {
+   // final StringBuffer buffer = new StringBuffer();
+   // if ( metaDataLines == null
+   // || metaDataLines.isEmpty() )
+   // {
+   // return "";
+   // }
+   // for ( final String line : metaDataLines )
+   // {
+   // buffer.append( line );
+   // }
+   // return buffer + " ";
+   // }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-files/src/main/java/net/sourceforge/pmd/PMDException.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-files/src/main/java/net/sourceforge/pmd/PMDException.java b/FlexPMD/flex-pmd-files/src/main/java/net/sourceforge/pmd/PMDException.java
new file mode 100644
index 0000000..ce150c9
--- /dev/null
+++ b/FlexPMD/flex-pmd-files/src/main/java/net/sourceforge/pmd/PMDException.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sourceforge.pmd;
+
+/**
+ * A convenience exception wrapper. Contains the original exception, if any.
+ * Also, contains a severity number (int). Zero implies no severity. The higher
+ * the number the greater the severity.
+ * 
+ * @author Donald A. Leckie
+ * @version $Revision: 5681 $, $Date: 2007-11-30 14:00:56 -0800 (Fri, 30 Nov
+ *          2007) $
+ * @since August 30, 2002
+ */
+public class PMDException extends Exception
+{
+   private static final long serialVersionUID = 6938647389367956874L;
+
+   private int               severity;
+
+   /**
+    * @param message
+    */
+   public PMDException( final String message )
+   {
+      super( message );
+   }
+
+   /**
+    * @param message
+    * @param reason
+    */
+   public PMDException( final String message,
+                        final Exception reason )
+   {
+      super( message, reason );
+   }
+
+   /**
+    * Returns the cause of this exception or <code>null</code>
+    * 
+    * @return the cause of this exception or <code>null</code>
+    * @deprecated use {@link #getCause()} instead
+    */
+   @Deprecated
+   public Exception getReason()
+   {
+      return ( Exception ) getCause();
+   }
+
+   /**
+    * @return
+    */
+   public int getSeverity()
+   {
+      return severity;
+   }
+
+   /**
+    * @param severityToBeSet
+    */
+   public void setSeverity( final int severityToBeSet )
+   {
+      severity = severityToBeSet;
+   }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-files/src/test/java/com/adobe/ac/pmd/FlexPmdTestBaseTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-files/src/test/java/com/adobe/ac/pmd/FlexPmdTestBaseTest.java b/FlexPMD/flex-pmd-files/src/test/java/com/adobe/ac/pmd/FlexPmdTestBaseTest.java
new file mode 100644
index 0000000..3fede84
--- /dev/null
+++ b/FlexPMD/flex-pmd-files/src/test/java/com/adobe/ac/pmd/FlexPmdTestBaseTest.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+import com.adobe.ac.pmd.files.IFlexFile;
+
+public class FlexPmdTestBaseTest
+{
+   @Test
+   public void testSetTestFiles()
+   {
+      final FlexPmdTestBase testBase = new FlexPmdTestBase();
+      final Map< String, IFlexFile > testFilesToBeSet = new LinkedHashMap< String, IFlexFile >();
+
+      testBase.setTestFiles( testFilesToBeSet );
+      Assert.assertEquals( testFilesToBeSet,
+                           testBase.getTestFiles() );
+   }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-files/src/test/java/com/adobe/ac/pmd/ResourcesManagerTestTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-files/src/test/java/com/adobe/ac/pmd/ResourcesManagerTestTest.java b/FlexPMD/flex-pmd-files/src/test/java/com/adobe/ac/pmd/ResourcesManagerTestTest.java
new file mode 100644
index 0000000..fe4848a
--- /dev/null
+++ b/FlexPMD/flex-pmd-files/src/test/java/com/adobe/ac/pmd/ResourcesManagerTestTest.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+public class ResourcesManagerTestTest
+{
+   @Test
+   public void testGetInstance()
+   {
+      final ResourcesManagerTest manager = ResourcesManagerTest.getInstance();
+
+      Assert.assertNotNull( manager.getTestFiles() );
+   }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-files/src/test/java/com/adobe/ac/pmd/files/MxmlFileTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-files/src/test/java/com/adobe/ac/pmd/files/MxmlFileTest.java b/FlexPMD/flex-pmd-files/src/test/java/com/adobe/ac/pmd/files/MxmlFileTest.java
new file mode 100644
index 0000000..2193e78
--- /dev/null
+++ b/FlexPMD/flex-pmd-files/src/test/java/com/adobe/ac/pmd/files/MxmlFileTest.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.files;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.adobe.ac.pmd.FlexPmdTestBase;
+
+public class MxmlFileTest extends FlexPmdTestBase
+{
+   private IMxmlFile bug141;
+   private IMxmlFile bug233a;
+   private IMxmlFile bug233b;
+   private IMxmlFile deleteRenderer;
+   private IMxmlFile iterationsList;
+   private IMxmlFile nestedComponent;
+
+   @Before
+   public void setUp()
+   {
+      bug141 = ( IMxmlFile ) getTestFiles().get( "bug.FlexPMD141a.mxml" );
+      bug233a = ( IMxmlFile ) getTestFiles().get( "bug.FlexPMD233a.mxml" );
+      bug233b = ( IMxmlFile ) getTestFiles().get( "bug.FlexPMD233b.mxml" );
+      iterationsList = ( IMxmlFile ) getTestFiles().get( "com.adobe.ac.ncss.mxml.IterationsList.mxml" );
+      nestedComponent = ( IMxmlFile ) getTestFiles().get( "com.adobe.ac.ncss.mxml.NestedComponent.mxml" );
+      deleteRenderer = ( IMxmlFile ) getTestFiles().get( "DeleteButtonRenderer.mxml" );
+   }
+
+   @Test
+   public void testCommentTags()
+   {
+      assertEquals( "<!--",
+                    iterationsList.getCommentOpeningTag() );
+      assertEquals( "-->",
+                    iterationsList.getCommentClosingTag() );
+   }
+
+   @Test
+   public void testFlexPMD141()
+   {
+      final String[] lines = bug141.getScriptBlock();
+
+      assertEquals( "package bug{",
+                    lines[ 0 ] );
+      assertEquals( "class FlexPMD141a{",
+                    lines[ 1 ] );
+      assertEquals( Integer.valueOf( 46 ),
+                    Integer.valueOf( lines.length ) );
+      assertEquals( "",
+                    lines[ 36 ] );
+      assertEquals( "",
+                    lines[ 37 ] );
+      assertEquals( "",
+                    lines[ 38 ] );
+      assertEquals( "private var object:List = new List();",
+                    lines[ 39 ].trim() );
+      assertEquals( "}}",
+                    lines[ lines.length - 1 ] );
+   }
+
+   @Test
+   public void testFlexPMD233()
+   {
+      final String[] lines = bug233a.getScriptBlock();
+
+      Assert.assertEquals( "",
+                           lines[ 47 ] );
+
+      Assert.assertEquals( 80,
+                           bug233b.getActualScriptBlock().length );
+   }
+
+   @Test
+   public void testGetActionScriptScriptBlock()
+   {
+      final String[] deleteRendererLines = deleteRenderer.getScriptBlock();
+
+      assertEquals( "package {",
+                    deleteRendererLines[ 0 ] );
+      assertEquals( "       [Event(name=\"ruleRemoved\", type=\"flash.events.Event\")]",
+                    deleteRendererLines[ 43 ] );
+      assertEquals( "class DeleteButtonRenderer{",
+                    deleteRendererLines[ 44 ] );
+      assertEquals( Integer.valueOf( 115 ),
+                    Integer.valueOf( deleteRendererLines.length ) );
+      assertEquals( "            import com.adobe.ac.pmd.model.Rule;",
+                    deleteRendererLines[ 49 ] );
+      assertEquals( "}}",
+                    deleteRendererLines[ deleteRendererLines.length - 1 ] );
+   }
+
+   @Test
+   public void testGetMxmlScriptBlock()
+   {
+      final String[] iterationsListLines = iterationsList.getScriptBlock();
+
+      assertEquals( "package com.adobe.ac.ncss.mxml{",
+                    iterationsListLines[ 0 ] );
+      assertEquals( "class IterationsList{",
+                    iterationsListLines[ 1 ] );
+      assertEquals( "         import com.adobe.ac.anthology.model.object.IterationModelLocator;",
+                    iterationsListLines[ 40 ] );
+      assertEquals( "}}",
+                    iterationsListLines[ iterationsListLines.length - 1 ] );
+      assertEquals( Integer.valueOf( 104 ),
+                    Integer.valueOf( iterationsListLines.length ) );
+   }
+
+   @Test
+   public void testGetMxmlScriptBlock2()
+   {
+      final String[] nestedLines = nestedComponent.getScriptBlock();
+
+      assertEquals( "package com.adobe.ac.ncss.mxml{",
+                    nestedLines[ 0 ] );
+      assertEquals( "class NestedComponent{",
+                    nestedLines[ 1 ] );
+      assertEquals( Integer.valueOf( 57 ),
+                    Integer.valueOf( nestedLines.length ) );
+      assertEquals( "}}",
+                    nestedLines[ nestedLines.length - 1 ] );
+   }
+
+   @Test
+   public void testScriptBlockLines()
+   {
+      assertEquals( Integer.valueOf( 40 ),
+                    Integer.valueOf( iterationsList.getBeginningScriptBlock() ) );
+      assertEquals( Integer.valueOf( 94 ),
+                    Integer.valueOf( iterationsList.getEndingScriptBlock() ) );
+   }
+}