You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2014/08/27 00:43:48 UTC
[17/51] [partial] Refactored the PMD Maven build - Adjusted the
directory structure - Fixed a lot of compile problems - Fixed the maven setup
- Made PMD build with Flexmojos 7.1.0 and Apache Flex 4.13.0 - Fixed a few
UnitTests
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/IPackage.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/IPackage.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/IPackage.java
new file mode 100644
index 0000000..5fd2069
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/IPackage.java
@@ -0,0 +1,50 @@
+/*
+ * 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.nodes;
+
+import java.util.List;
+
+import com.adobe.ac.pmd.parser.IParserNode;
+
+/**
+ * Node representing a package. It contains the nested class node, the list of
+ * imports, and the package name.
+ *
+ * @author xagnetti
+ */
+public interface IPackage extends INamable, INode
+{
+ /**
+ * @return
+ */
+ IClass getClassNode();
+
+ /**
+ * @return
+ */
+ String getFullyQualifiedClassName();
+
+ /**
+ * @return
+ */
+ List< IFunction > getFunctions();
+
+ /**
+ * @return
+ */
+ List< IParserNode > getImports();
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/IParameter.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/IParameter.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/IParameter.java
new file mode 100644
index 0000000..9a2057b
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/IParameter.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.nodes;
+
+/**
+ * @author xagnetti
+ */
+public interface IParameter extends IVariable
+{
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/IVariable.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/IVariable.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/IVariable.java
new file mode 100644
index 0000000..e8902b6
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/IVariable.java
@@ -0,0 +1,33 @@
+/*
+ * 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.nodes;
+
+/**
+ * @author xagnetti
+ */
+public interface IVariable extends IMetaDataListHolder, INamableNode
+{
+ /**
+ * @return
+ */
+ IFieldInitialization getInitializationExpression();
+
+ /**
+ * @return
+ */
+ IIdentifierNode getType();
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/IVisible.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/IVisible.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/IVisible.java
new file mode 100644
index 0000000..7afd485
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/IVisible.java
@@ -0,0 +1,28 @@
+/*
+ * 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.nodes;
+
+/**
+ * @author xagnetti
+ */
+public interface IVisible extends IModifiersHolder
+{
+ /**
+ * @return
+ */
+ boolean isPublic();
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/MetaData.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/MetaData.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/MetaData.java
new file mode 100644
index 0000000..48e30bf
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/MetaData.java
@@ -0,0 +1,85 @@
+/*
+ * 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.nodes;
+
+/**
+ * @author xagnetti
+ */
+public enum MetaData
+{
+ ARRAY_ELEMENT_TYPE("ArrayElementType"),
+ BEFORE("Before"),
+ BINDABLE("Bindable"),
+ DEFAULT_PROPERTY("DefaultProperty"),
+ DEPRECATED("Deprecated"),
+ EFFECT("Effect"),
+ EMBED("Embed"),
+ EVENT("Event"),
+ EXCLUDE("Exclude"),
+ EXCLUDE_CLASS("Exclude"),
+ ICON_FILE("IconFile"),
+ INSPECTABLE("Inspectable"),
+ INSTANCE_TYPE("InstanceType"),
+ NON_COMITTING_CHANGE_EVENT("NonCommittingChangeEvent"),
+ OTHER("Other"),
+ REMOTE_CLASS("RemoteClass"),
+ STYLE("Style"),
+ TEST("Test"),
+ TRANSIENT("Transient");
+
+ /**
+ * @param metaDataName
+ * @return
+ */
+ public static MetaData create( final String metaDataName )
+ {
+ MetaData metaData = null;
+
+ for ( final MetaData currentMetadata : values() )
+ {
+ if ( currentMetadata.toString().compareTo( metaDataName ) == 0 )
+ {
+ metaData = currentMetadata;
+ break;
+ }
+ }
+ if ( metaData == null )
+ {
+ metaData = MetaData.OTHER;
+ metaData.name = metaDataName;
+ }
+
+ return metaData;
+ }
+
+ private String name;
+
+ private MetaData( final String nameToBeSet )
+ {
+ name = nameToBeSet;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Enum#toString()
+ */
+ @Override
+ public String toString()
+ {
+ return name;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/Modifier.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/Modifier.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/Modifier.java
new file mode 100644
index 0000000..bd93b42
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/Modifier.java
@@ -0,0 +1,78 @@
+/*
+ * 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.nodes;
+
+import com.adobe.ac.pmd.parser.KeyWords;
+
+/**
+ * @author xagnetti
+ */
+public enum Modifier
+{
+ DYNAMIC, FINAL, INTERNAL, OVERRIDE, PRIVATE, PROTECTED, PUBLIC, STATIC, INTRINSIC;
+
+ /**
+ * @param name
+ * @return
+ */
+ public static Modifier create( final String name )
+ {
+ Modifier modifier = null;
+ if ( KeyWords.PUBLIC.toString().equals( name ) )
+ {
+ modifier = Modifier.PUBLIC;
+ }
+ else if ( KeyWords.PRIVATE.toString().equals( name ) )
+ {
+ modifier = Modifier.PRIVATE;
+ }
+ else if ( KeyWords.PROTECTED.toString().equals( name ) )
+ {
+ modifier = Modifier.PROTECTED;
+ }
+ else if ( KeyWords.INTERNAL.toString().equals( name ) )
+ {
+ modifier = Modifier.INTERNAL;
+ }
+ else if ( KeyWords.DYNAMIC.toString().equals( name ) )
+ {
+ modifier = Modifier.DYNAMIC;
+ }
+ else if ( KeyWords.OVERRIDE.toString().equals( name ) )
+ {
+ modifier = Modifier.OVERRIDE;
+ }
+ else if ( KeyWords.STATIC.toString().equals( name ) )
+ {
+ modifier = Modifier.STATIC;
+ }
+ else if ( KeyWords.FINAL.toString().equals( name ) )
+ {
+ modifier = Modifier.FINAL;
+ }
+ // class modifier AS2
+ else if ( KeyWords.INTRINSIC.toString().equals( name ) )
+ {
+ modifier = Modifier.INTRINSIC;
+ }
+ return modifier;
+ }
+
+ private Modifier()
+ {
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/asdoc/impl/AsDocNodeBase.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/asdoc/impl/AsDocNodeBase.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/asdoc/impl/AsDocNodeBase.java
new file mode 100644
index 0000000..9cdb774
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/asdoc/impl/AsDocNodeBase.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.pmd.nodes.asdoc.impl;
+
+/**
+ * @author xagnetti
+ */
+public class AsDocNodeBase
+{
+ private final String description;
+
+ /**
+ * @param descriptionToBeSet
+ */
+ public AsDocNodeBase( final String descriptionToBeSet )
+ {
+ super();
+ description = descriptionToBeSet;
+ }
+
+ /**
+ * @return
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/asdoc/impl/ClassAsDocNode.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/asdoc/impl/ClassAsDocNode.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/asdoc/impl/ClassAsDocNode.java
new file mode 100644
index 0000000..f165771
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/asdoc/impl/ClassAsDocNode.java
@@ -0,0 +1,31 @@
+/*
+ * 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.nodes.asdoc.impl;
+
+/**
+ * @author xagnetti
+ */
+public class ClassAsDocNode extends AsDocNodeBase
+{
+ /**
+ * @param descriptionToBeSet
+ */
+ public ClassAsDocNode( final String descriptionToBeSet )
+ {
+ super( descriptionToBeSet );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/asdoc/impl/FunctionAsDocNode.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/asdoc/impl/FunctionAsDocNode.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/asdoc/impl/FunctionAsDocNode.java
new file mode 100644
index 0000000..c8edf41
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/asdoc/impl/FunctionAsDocNode.java
@@ -0,0 +1,54 @@
+/*
+ * 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.nodes.asdoc.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author xagnetti
+ */
+public class FunctionAsDocNode extends AsDocNodeBase
+{
+ private final List< ParameterAsDocNode > parameters;
+
+ /**
+ * @param descriptionToBeSet
+ */
+ public FunctionAsDocNode( final String descriptionToBeSet )
+ {
+ super( descriptionToBeSet );
+ parameters = new ArrayList< ParameterAsDocNode >();
+ }
+
+ /**
+ * @param param
+ */
+ public void addParameter( final ParameterAsDocNode param )
+ {
+ parameters.add( param );
+ }
+
+ /**
+ * @param index
+ * @return
+ */
+ public ParameterAsDocNode getParameter( final int index )
+ {
+ return parameters.get( index );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/asdoc/impl/ParameterAsDocNode.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/asdoc/impl/ParameterAsDocNode.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/asdoc/impl/ParameterAsDocNode.java
new file mode 100644
index 0000000..a41286a
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/asdoc/impl/ParameterAsDocNode.java
@@ -0,0 +1,55 @@
+/*
+ * 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.nodes.asdoc.impl;
+
+/**
+ * @author xagnetti
+ */
+public class ParameterAsDocNode
+{
+ private final String description;
+ private final String name;
+
+ /**
+ * @param nameToBeSet
+ * @param descriptionToBeSet
+ */
+ public ParameterAsDocNode( final String nameToBeSet,
+ final String descriptionToBeSet )
+ {
+ super();
+
+ name = nameToBeSet;
+ description = descriptionToBeSet;
+ }
+
+ /**
+ * @return
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+
+ /**
+ * @return
+ */
+ public String getName()
+ {
+ return name;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/AbstractNode.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/AbstractNode.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/AbstractNode.java
new file mode 100644
index 0000000..41c0183
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/AbstractNode.java
@@ -0,0 +1,90 @@
+/*
+ * 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.nodes.impl;
+
+import java.util.logging.Logger;
+
+import com.adobe.ac.pmd.nodes.IMetaDataListHolder;
+import com.adobe.ac.pmd.nodes.IModifiersHolder;
+import com.adobe.ac.pmd.nodes.INode;
+import com.adobe.ac.pmd.nodes.Modifier;
+import com.adobe.ac.pmd.parser.IParserNode;
+
+/**
+ * @author xagnetti
+ */
+abstract class AbstractNode implements INode
+{
+ protected static final Logger LOGGER = Logger.getLogger( "Node" );
+
+ /**
+ * @param metaDataHolder
+ * @param child
+ */
+ protected static void computeMetaDataList( final IMetaDataListHolder metaDataHolder,
+ final IParserNode child )
+ {
+ if ( child.numChildren() != 0 )
+ {
+ for ( final IParserNode metadataNode : child.getChildren() )
+ {
+ metaDataHolder.add( NodeFactory.createMetaData( metadataNode ) );
+ }
+ }
+ }
+
+ /**
+ * @param modifiable
+ * @param child
+ */
+ protected static final void computeModifierList( final IModifiersHolder modifiable,
+ final IParserNode child )
+ {
+ if ( child.numChildren() != 0 )
+ {
+ for ( final IParserNode modifierNode : child.getChildren() )
+ {
+ final Modifier modifier = Modifier.create( modifierNode.getStringValue() );
+
+ modifiable.add( modifier );
+ }
+ }
+ }
+ private final IParserNode internalNode;
+
+ /**
+ * @param node
+ */
+ protected AbstractNode( final IParserNode node )
+ {
+ internalNode = node;
+ }
+
+ /**
+ * @return
+ */
+ public abstract AbstractNode compute();
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.INode#getInternalNode()
+ */
+ public IParserNode getInternalNode()
+ {
+ return internalNode;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/AttributeNode.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/AttributeNode.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/AttributeNode.java
new file mode 100644
index 0000000..accdb1d
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/AttributeNode.java
@@ -0,0 +1,44 @@
+/*
+ * 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.nodes.impl;
+
+import com.adobe.ac.pmd.nodes.IAttribute;
+import com.adobe.ac.pmd.parser.IParserNode;
+
+/**
+ * @author xagnetti
+ */
+class AttributeNode extends FieldNode implements IAttribute
+{
+ /**
+ * @param rootNode
+ */
+ protected AttributeNode( final IParserNode rootNode )
+ {
+ super( rootNode );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.impl.FieldNode#compute()
+ */
+ @Override
+ public AttributeNode compute()
+ {
+ return ( AttributeNode ) super.compute();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/ClassNode.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/ClassNode.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/ClassNode.java
new file mode 100644
index 0000000..8f39c78
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/ClassNode.java
@@ -0,0 +1,411 @@
+/*
+ * 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.nodes.impl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import com.adobe.ac.pmd.nodes.IAttribute;
+import com.adobe.ac.pmd.nodes.IClass;
+import com.adobe.ac.pmd.nodes.IConstant;
+import com.adobe.ac.pmd.nodes.IFunction;
+import com.adobe.ac.pmd.nodes.IMetaData;
+import com.adobe.ac.pmd.nodes.MetaData;
+import com.adobe.ac.pmd.nodes.Modifier;
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.parser.NodeKind;
+
+/**
+ * @author xagnetti
+ */
+class ClassNode extends AbstractNode implements IClass
+{
+ private IParserNode asDoc;
+ private final List< IAttribute > attributes;
+ private IParserNode block;
+ private final List< IConstant > constants;
+ private IFunction constructor;
+ private String extensionName;
+ private final List< IFunction > functions;
+ private List< IParserNode > implementations;
+ private final Map< MetaData, List< IMetaData > > metaDataList;
+ private final Set< Modifier > modifiers;
+ private final List< IParserNode > multiLinesComments;
+ private IdentifierNode name;
+
+ /**
+ * @param node
+ */
+ protected ClassNode( final IParserNode node )
+ {
+ super( node );
+
+ modifiers = new HashSet< Modifier >();
+ metaDataList = new LinkedHashMap< MetaData, List< IMetaData > >();
+ implementations = new ArrayList< IParserNode >();
+ constants = new ArrayList< IConstant >();
+ attributes = new ArrayList< IAttribute >();
+ functions = new ArrayList< IFunction >();
+ multiLinesComments = new ArrayList< IParserNode >();
+ name = null;
+ asDoc = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.nodes.IMetaDataListHolder#add(com.adobe.ac.pmd.nodes.
+ * IMetaData)
+ */
+ public void add( final IMetaData metaData )
+ {
+ final MetaData metaDataImpl = MetaData.create( metaData.getName() );
+
+ if ( !metaDataList.containsKey( metaDataImpl ) )
+ {
+ metaDataList.put( metaDataImpl,
+ new ArrayList< IMetaData >() );
+ }
+ metaDataList.get( metaDataImpl ).add( metaData );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.nodes.IModifiersHolder#add(com.adobe.ac.pmd.nodes.Modifier
+ * )
+ */
+ public void add( final Modifier modifier )
+ {
+ modifiers.add( modifier );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.impl.AbstractNode#compute()
+ */
+ @Override
+ public ClassNode compute()
+ {
+ if ( getInternalNode().numChildren() != 0 )
+ {
+ for ( final IParserNode node : getInternalNode().getChildren() )
+ {
+ if ( node.is( NodeKind.CONTENT ) )
+ {
+ computeClassContent( node );
+ }
+ else if ( node.is( NodeKind.MOD_LIST ) )
+ {
+ computeModifierList( this,
+ node );
+ }
+ else if ( node.is( NodeKind.NAME ) )
+ {
+ name = IdentifierNode.create( node );
+ }
+ else if ( node.is( NodeKind.META_LIST ) )
+ {
+ computeMetaDataList( this,
+ node );
+ }
+ else if ( node.is( NodeKind.AS_DOC ) )
+ {
+ asDoc = node;
+ }
+ else if ( node.is( NodeKind.MULTI_LINE_COMMENT ) )
+ {
+ multiLinesComments.add( node );
+ }
+ detectImplementations( node );
+ detectExtensions( node );
+ }
+ for ( final IFunction function : functions )
+ {
+ if ( name.toString().equals( function.getName() ) )
+ {
+ constructor = function;
+ }
+ }
+ }
+ return this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IMetaDataListHolder#getAllMetaData()
+ */
+ public List< IMetaData > getAllMetaData()
+ {
+ final List< IMetaData > list = new ArrayList< IMetaData >();
+
+ for ( final Entry< MetaData, List< IMetaData > > entry : metaDataList.entrySet() )
+ {
+ list.addAll( entry.getValue() );
+ }
+
+ return list;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IAsDocHolder#getAsDoc()
+ */
+ public IParserNode getAsDoc()
+ {
+ return asDoc;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IClass#getAttributes()
+ */
+ public List< IAttribute > getAttributes()
+ {
+ return attributes;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IClass#getAverageCyclomaticComplexity()
+ */
+ public double getAverageCyclomaticComplexity()
+ {
+ if ( functions.isEmpty() )
+ {
+ return 0;
+ }
+ int totalCcn = 0;
+
+ for ( final IFunction function : functions )
+ {
+ totalCcn += function.getCyclomaticComplexity();
+ }
+
+ return totalCcn
+ / functions.size();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IClass#getBlock()
+ */
+ public final IParserNode getBlock()
+ {
+ return block;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IClass#getConstants()
+ */
+ public List< IConstant > getConstants()
+ {
+ return constants;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IClass#getConstructor()
+ */
+ public IFunction getConstructor()
+ {
+ return constructor;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IClass#getExtensionName()
+ */
+ public String getExtensionName()
+ {
+ return extensionName;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IClass#getFunctions()
+ */
+ public List< IFunction > getFunctions()
+ {
+ return functions;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IClass#getImplementations()
+ */
+ public List< IParserNode > getImplementations()
+ {
+ return implementations;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.nodes.IMetaDataListHolder#getMetaData(com.adobe.ac.pmd
+ * .nodes.MetaData)
+ */
+ public List< IMetaData > getMetaData( final MetaData metaDataName )
+ {
+ if ( metaDataList.containsKey( metaDataName ) )
+ {
+ return metaDataList.get( metaDataName );
+ }
+ else
+ {
+ return new ArrayList< IMetaData >();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IMetaDataListHolder#getMetaDataCount()
+ */
+ public int getMetaDataCount()
+ {
+ return metaDataList.size();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.ICommentHolder#getMultiLinesComment()
+ */
+ public List< IParserNode > getMultiLinesComment()
+ {
+ return multiLinesComments;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.INamable#getName()
+ */
+ public String getName()
+ {
+ return name.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.nodes.IModifiersHolder#is(com.adobe.ac.pmd.nodes.Modifier
+ * )
+ */
+ public boolean is( final Modifier modifier ) // NOPMD
+ {
+ return modifiers.contains( modifier );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IClass#isBindable()
+ */
+ public boolean isBindable()
+ {
+ return metaDataList.get( MetaData.BINDABLE ) != null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IClass#isFinal()
+ */
+ public boolean isFinal()
+ {
+ return is( Modifier.FINAL );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IVisible#isPublic()
+ */
+ public boolean isPublic()
+ {
+ return is( Modifier.PUBLIC );
+ }
+
+ private void computeClassContent( final IParserNode classContentNode )
+ {
+ if ( classContentNode.numChildren() != 0 )
+ {
+ for ( final IParserNode node : classContentNode.getChildren() )
+ {
+ detectBlock( node );
+ detectFunction( node );
+ detectAttribute( node );
+ detectConstant( node );
+ if ( node.is( NodeKind.MULTI_LINE_COMMENT ) )
+ {
+ multiLinesComments.add( node );
+ }
+ }
+ }
+ }
+
+ private void detectAttribute( final IParserNode node )
+ {
+ if ( node.is( NodeKind.VAR_LIST ) )
+ {
+ attributes.add( new AttributeNode( node ).compute() );
+ }
+ }
+
+ private void detectBlock( final IParserNode node )
+ {
+ if ( node.is( NodeKind.BLOCK ) )
+ {
+ block = node;
+ }
+ }
+
+ private void detectConstant( final IParserNode node )
+ {
+ if ( node.is( NodeKind.CONST_LIST ) )
+ {
+ constants.add( new ConstantNode( node ).compute() );
+ }
+ }
+
+ private void detectExtensions( final IParserNode node )
+ {
+ if ( node.is( NodeKind.EXTENDS ) )
+ {
+ extensionName = node.getStringValue();
+ }
+ }
+
+ private void detectFunction( final IParserNode node )
+ {
+ if ( node.is( NodeKind.FUNCTION )
+ || node.is( NodeKind.GET ) || node.is( NodeKind.SET ) )
+ {
+ functions.add( new FunctionNode( node ).compute() );
+ }
+ }
+
+ private void detectImplementations( final IParserNode node )
+ {
+ if ( node.is( NodeKind.IMPLEMENTS_LIST ) )
+ {
+ implementations = node.getChildren();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/ConstantNode.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/ConstantNode.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/ConstantNode.java
new file mode 100644
index 0000000..dd809c5
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/ConstantNode.java
@@ -0,0 +1,44 @@
+/*
+ * 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.nodes.impl;
+
+import com.adobe.ac.pmd.nodes.IConstant;
+import com.adobe.ac.pmd.parser.IParserNode;
+
+/**
+ * @author xagnetti
+ */
+class ConstantNode extends FieldNode implements IConstant
+{
+ /**
+ * @param rootNode
+ */
+ protected ConstantNode( final IParserNode rootNode )
+ {
+ super( rootNode );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.impl.FieldNode#compute()
+ */
+ @Override
+ public ConstantNode compute()
+ {
+ return ( ConstantNode ) super.compute();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/FieldInitializationNode.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/FieldInitializationNode.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/FieldInitializationNode.java
new file mode 100644
index 0000000..bde2b5a
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/FieldInitializationNode.java
@@ -0,0 +1,53 @@
+/*
+ * 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.nodes.impl;
+
+import com.adobe.ac.pmd.nodes.IFieldInitialization;
+import com.adobe.ac.pmd.parser.IParserNode;
+
+/**
+ * @author xagnetti
+ */
+class FieldInitializationNode extends AbstractNode implements IFieldInitialization
+{
+ /**
+ * @param node
+ * @return
+ */
+ static FieldInitializationNode create( final IParserNode node )
+ {
+ return new FieldInitializationNode( node );
+ }
+
+ /**
+ * @param node
+ */
+ protected FieldInitializationNode( final IParserNode node )
+ {
+ super( node );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.impl.AbstractNode#compute()
+ */
+ @Override
+ public FieldInitializationNode compute()
+ {
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/FieldNode.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/FieldNode.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/FieldNode.java
new file mode 100644
index 0000000..a9db9d9
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/FieldNode.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.nodes.impl;
+
+import com.adobe.ac.pmd.nodes.IField;
+import com.adobe.ac.pmd.nodes.Modifier;
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.parser.NodeKind;
+
+/**
+ * Base class for AttributeNode and for ConstantNode
+ *
+ * @author xagnetti
+ */
+class FieldNode extends VariableNode implements IField
+{
+ private IParserNode asDocs;
+
+ /**
+ * @param rootNode
+ */
+ protected FieldNode( final IParserNode rootNode )
+ {
+ super( rootNode );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.impl.VariableNode#compute()
+ */
+ @Override
+ public FieldNode compute()
+ {
+ super.compute();
+
+ if ( getInternalNode().numChildren() != 0 )
+ {
+ for ( final IParserNode child : getInternalNode().getChildren() )
+ {
+ if ( child.is( NodeKind.MOD_LIST ) )
+ {
+ computeModifierList( this,
+ child );
+ }
+ else if ( child.is( NodeKind.AS_DOC ) )
+ {
+ asDocs = child;
+ }
+ }
+ }
+ return this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IAsDocHolder#getAsDoc()
+ */
+ public IParserNode getAsDoc()
+ {
+ return asDocs;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IVisible#isPublic()
+ */
+ public boolean isPublic()
+ {
+ return is( Modifier.PUBLIC );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IField#isStatic()
+ */
+ public boolean isStatic()
+ {
+ return is( Modifier.STATIC );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/FormalNode.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/FormalNode.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/FormalNode.java
new file mode 100644
index 0000000..8aaacdb
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/FormalNode.java
@@ -0,0 +1,53 @@
+/*
+ * 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.nodes.impl;
+
+import com.adobe.ac.pmd.nodes.IParameter;
+import com.adobe.ac.pmd.parser.IParserNode;
+
+/**
+ * @author xagnetti
+ */
+final class FormalNode extends VariableNode implements IParameter
+{
+ /**
+ * @param node
+ * @return
+ */
+ static FormalNode create( final IParserNode node )
+ {
+ return new FormalNode( node ).compute();
+ }
+
+ /**
+ * @param node
+ */
+ private FormalNode( final IParserNode node )
+ {
+ super( node );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.impl.VariableNode#compute()
+ */
+ @Override
+ public FormalNode compute()
+ {
+ return ( FormalNode ) super.compute();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/FunctionNode.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/FunctionNode.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/FunctionNode.java
new file mode 100644
index 0000000..6d61a9e
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/FunctionNode.java
@@ -0,0 +1,444 @@
+/*
+ * 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.nodes.impl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import com.adobe.ac.pmd.nodes.IFunction;
+import com.adobe.ac.pmd.nodes.IIdentifierNode;
+import com.adobe.ac.pmd.nodes.IMetaData;
+import com.adobe.ac.pmd.nodes.IParameter;
+import com.adobe.ac.pmd.nodes.MetaData;
+import com.adobe.ac.pmd.nodes.Modifier;
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.parser.KeyWords;
+import com.adobe.ac.pmd.parser.NodeKind;
+
+/**
+ * @author xagnetti
+ */
+class FunctionNode extends AbstractNode implements IFunction
+{
+ private IParserNode asDoc;
+ private IParserNode body;
+ private int cyclomaticComplexity;
+ private final Map< String, IParserNode > localVariables;
+ private final Map< MetaData, List< IMetaData > > metaDataList;
+ private final Set< Modifier > modifiers;
+ private final List< IParserNode > multiLinesComments;
+ private IdentifierNode name;
+ private final List< IParameter > parameters;
+ private IIdentifierNode returnType;
+
+ /**
+ * @param node
+ */
+ protected FunctionNode( final IParserNode node )
+ {
+ super( node );
+
+ modifiers = new HashSet< Modifier >();
+ metaDataList = new LinkedHashMap< MetaData, List< IMetaData > >();
+ localVariables = new LinkedHashMap< String, IParserNode >();
+ parameters = new ArrayList< IParameter >();
+ name = null;
+ multiLinesComments = new ArrayList< IParserNode >();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.nodes.IMetaDataListHolder#add(com.adobe.ac.pmd.nodes.
+ * IMetaData)
+ */
+ public void add( final IMetaData metaData )
+ {
+ final MetaData metaDataImpl = MetaData.create( metaData.getName() );
+
+ if ( !metaDataList.containsKey( metaDataImpl ) )
+ {
+ metaDataList.put( metaDataImpl,
+ new ArrayList< IMetaData >() );
+ }
+ metaDataList.get( metaDataImpl ).add( metaData );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.nodes.IModifiersHolder#add(com.adobe.ac.pmd.nodes.Modifier
+ * )
+ */
+ public void add( final Modifier modifier )
+ {
+ modifiers.add( modifier );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.impl.AbstractNode#compute()
+ */
+ @Override
+ public FunctionNode compute()
+ {
+ if ( getInternalNode().numChildren() != 0 )
+ {
+ for ( final IParserNode node : getInternalNode().getChildren() )
+ {
+ if ( node.is( NodeKind.BLOCK ) )
+ {
+ computeFunctionContent( node );
+ }
+ else if ( node.is( NodeKind.NAME ) )
+ {
+ name = IdentifierNode.create( node );
+ }
+ else if ( node.is( NodeKind.MOD_LIST ) )
+ {
+ computeModifierList( this,
+ node );
+ }
+ else if ( node.is( NodeKind.PARAMETER_LIST ) )
+ {
+ computeParameterList( node );
+ }
+ else if ( node.is( NodeKind.TYPE ) )
+ {
+ returnType = IdentifierNode.create( node );
+ }
+ else if ( node.is( NodeKind.META_LIST ) )
+ {
+ computeMetaDataList( this,
+ node );
+ }
+ else if ( node.is( NodeKind.AS_DOC ) )
+ {
+ asDoc = node;
+ }
+ }
+ }
+ return this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.nodes.IFunction#findPrimaryStatementInBody(java.lang.
+ * String[])
+ */
+ public List< IParserNode > findPrimaryStatementInBody( final String[] primaryNames )
+ {
+ return body == null ? null
+ : body.findPrimaryStatementsFromNameInChildren( primaryNames );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.nodes.IFunction#findPrimaryStatementsInBody(java.lang
+ * .String)
+ */
+ public List< IParserNode > findPrimaryStatementsInBody( final String primaryName )
+ {
+ return body == null ? new ArrayList< IParserNode >()
+ : body.findPrimaryStatementsFromNameInChildren( new String[]
+ { primaryName } );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IMetaDataListHolder#getAllMetaData()
+ */
+ public List< IMetaData > getAllMetaData()
+ {
+ final List< IMetaData > list = new ArrayList< IMetaData >();
+
+ for ( final Entry< MetaData, List< IMetaData > > entry : metaDataList.entrySet() )
+ {
+ list.addAll( entry.getValue() );
+ }
+
+ return list;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IAsDocHolder#getAsDoc()
+ */
+ public IParserNode getAsDoc()
+ {
+ return asDoc;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IFunction#getBody()
+ */
+ public IParserNode getBody()
+ {
+ return body;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IFunction#getCyclomaticComplexity()
+ */
+ public int getCyclomaticComplexity()
+ {
+ return cyclomaticComplexity;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IFunction#getLocalVariables()
+ */
+ public Map< String, IParserNode > getLocalVariables()
+ {
+ return localVariables;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.nodes.IMetaDataListHolder#getMetaData(com.adobe.ac.pmd
+ * .nodes.MetaData)
+ */
+ public List< IMetaData > getMetaData( final MetaData metaDataName )
+ {
+ if ( metaDataList.containsKey( metaDataName ) )
+ {
+ return metaDataList.get( metaDataName );
+ }
+ else
+ {
+ return new ArrayList< IMetaData >();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IMetaDataListHolder#getMetaDataCount()
+ */
+ public int getMetaDataCount()
+ {
+ return metaDataList.size();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.ICommentHolder#getMultiLinesComment()
+ */
+ public List< IParserNode > getMultiLinesComment()
+ {
+ return multiLinesComments;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.INamable#getName()
+ */
+ public String getName()
+ {
+ return name.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IFunction#getParameters()
+ */
+ public List< IParameter > getParameters()
+ {
+ return parameters;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IFunction#getReturnType()
+ */
+ public IIdentifierNode getReturnType()
+ {
+ return returnType;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IFunction#getStatementNbInBody()
+ */
+ public int getStatementNbInBody()
+ {
+ return 1 + getStatementInNode( body );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IFunction#getSuperCall()
+ */
+ public IParserNode getSuperCall()
+ {
+ if ( body != null
+ && body.numChildren() != 0 )
+ {
+ for ( final IParserNode childContent : body.getChildren() )
+ {
+ if ( NodeKind.CALL.equals( childContent.getId() )
+ || NodeKind.DOT.equals( childContent.getId() ) )
+ {
+ for ( final IParserNode childCall : childContent.getChildren() )
+ {
+ if ( KeyWords.SUPER.toString().equals( childCall.getStringValue() ) )
+ {
+ return childContent;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.nodes.IModifiersHolder#is(com.adobe.ac.pmd.nodes.Modifier
+ * )
+ */
+ public boolean is( final Modifier modifier ) // NOPMD
+ {
+ return modifiers.contains( modifier );
+ }
+
+ //@Override
+ public boolean isEventHandler()
+ {
+ return getParameters().size() == 1
+ && getParameters().get( 0 ).getType().toString().contains( "Event" );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IFunction#isGetter()
+ */
+ public boolean isGetter()
+ {
+ return getInternalNode().is( NodeKind.GET );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IFunction#isOverriden()
+ */
+ public boolean isOverriden()
+ {
+ return is( Modifier.OVERRIDE );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IVisible#isPublic()
+ */
+ public boolean isPublic()
+ {
+ return is( Modifier.PUBLIC );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IFunction#isSetter()
+ */
+ public boolean isSetter()
+ {
+ return getInternalNode().is( NodeKind.SET );
+ }
+
+ private void computeCyclomaticComplexity()
+ {
+ cyclomaticComplexity = 1 + body.computeCyclomaticComplexity();
+ }
+
+ private void computeFunctionContent( final IParserNode functionBodyNode )
+ {
+ body = functionBodyNode;
+
+ computeCyclomaticComplexity();
+ if ( body.numChildren() > 0 )
+ {
+ for ( final IParserNode node : body.getChildren() )
+ {
+ if ( node.is( NodeKind.MULTI_LINE_COMMENT ) )
+ {
+ multiLinesComments.add( node );
+ }
+ }
+ }
+ computeVariableList( body );
+ }
+
+ private void computeParameterList( final IParserNode node )
+ {
+ if ( node.numChildren() != 0 )
+ {
+ for ( final IParserNode parameterNode : node.getChildren() )
+ {
+ parameters.add( FormalNode.create( parameterNode ) );
+ }
+ }
+ }
+
+ private void computeVariableList( final IParserNode node )
+ {
+ if ( node.is( NodeKind.VAR_LIST ) )
+ {
+ localVariables.put( node.getChild( 0 ).getChild( 0 ).getStringValue(),
+ node );
+ }
+ else if ( node.numChildren() > 0 )
+ {
+ for ( final IParserNode child : node.getChildren() )
+ {
+ computeVariableList( child );
+ }
+ }
+ }
+
+ private int getStatementInNode( final IParserNode node )
+ {
+ int statementNb = 0;
+
+ if ( node != null
+ && node.numChildren() != 0 )
+ {
+ int lastLine = node.getChild( 0 ).getLine();
+ for ( final IParserNode childContent : node.getChildren() )
+ {
+ if ( childContent.getLine() != lastLine )
+ {
+ lastLine = childContent.getLine();
+ statementNb++;
+ }
+ statementNb += getStatementInNode( childContent );
+ }
+ }
+
+ return statementNb;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/IdentifierNode.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/IdentifierNode.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/IdentifierNode.java
new file mode 100644
index 0000000..2b7ff10
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/IdentifierNode.java
@@ -0,0 +1,63 @@
+/*
+ * 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.nodes.impl;
+
+import com.adobe.ac.pmd.nodes.IIdentifierNode;
+import com.adobe.ac.pmd.parser.IParserNode;
+
+/**
+ * @author xagnetti
+ */
+class IdentifierNode extends AbstractNode implements IIdentifierNode
+{
+ /**
+ * @param node
+ * @return
+ */
+ static IdentifierNode create( final IParserNode node )
+ {
+ return new IdentifierNode( node ).compute();
+ }
+
+ /**
+ * @param node
+ */
+ protected IdentifierNode( final IParserNode node )
+ {
+ super( node );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.impl.AbstractNode#compute()
+ */
+ @Override
+ public IdentifierNode compute()
+ {
+ return this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString()
+ {
+ return getInternalNode().getStringValue();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/MetaDataNode.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/MetaDataNode.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/MetaDataNode.java
new file mode 100644
index 0000000..edb9777
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/MetaDataNode.java
@@ -0,0 +1,139 @@
+/*
+ * 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.nodes.impl;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.adobe.ac.pmd.nodes.IMetaData;
+import com.adobe.ac.pmd.parser.IParserNode;
+
+/**
+ * @author xagnetti
+ */
+class MetaDataNode extends AbstractNode implements IMetaData
+{
+ private List< String > attributeNames;
+ private String name;
+ private String parameter;
+ private Map< String, String[] > parameters;
+
+ /**
+ * @param node
+ */
+ protected MetaDataNode( final IParserNode node )
+ {
+ super( node );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.impl.AbstractNode#compute()
+ */
+ @Override
+ public MetaDataNode compute()
+ {
+ final String stringValue = getInternalNode().getStringValue();
+
+ name = stringValue.indexOf( " ( " ) > -1 ? stringValue.substring( 0,
+ stringValue.indexOf( " ( " ) )
+ : stringValue;
+ parameter = stringValue.indexOf( "( " ) > -1 ? stringValue.substring( stringValue.indexOf( "( " ) + 2,
+ stringValue.lastIndexOf( " )" ) )
+ : "";
+
+ computeAttributeNames();
+ return this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IMetaData#getAttributeNames()
+ */
+ public List< String > getAttributeNames()
+ {
+ return attributeNames;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IMetaData#getDefaultValue()
+ */
+ public String getDefaultValue()
+ {
+ return parameter;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.INamable#getName()
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IMetaData#getProperty(java.lang.String)
+ */
+ public String[] getProperty( final String property )
+ {
+ return parameters.containsKey( property ) ? parameters.get( property )
+ : new String[]
+ {};
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IMetaData#getPropertyAsList(java.lang.String)
+ */
+ public List< String > getPropertyAsList( final String property )
+ {
+ return Arrays.asList( getProperty( property ) );
+ }
+
+ private void computeAttributeNames()
+ {
+ attributeNames = new ArrayList< String >();
+ parameters = new LinkedHashMap< String, String[] >();
+
+ final String[] pairs = getPairs();
+
+ for ( final String pair : pairs )
+ {
+ final String[] pairSplit = pair.split( "=" );
+
+ if ( pairSplit.length == 2 )
+ {
+ attributeNames.add( pairSplit[ 0 ].trim() );
+ parameters.put( pairSplit[ 0 ].trim(),
+ pairSplit[ 1 ].trim().replaceAll( "\'",
+ "" ).replaceAll( "\"",
+ "" ).split( "," ) );
+ }
+ }
+ }
+
+ private String[] getPairs()
+ {
+ return parameter.split( "," );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/NodeFactory.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/NodeFactory.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/NodeFactory.java
new file mode 100644
index 0000000..1a9aac8
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/NodeFactory.java
@@ -0,0 +1,49 @@
+/*
+ * 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.nodes.impl;
+
+import com.adobe.ac.pmd.nodes.IMetaData;
+import com.adobe.ac.pmd.nodes.IPackage;
+import com.adobe.ac.pmd.parser.IParserNode;
+
+/**
+ * @author xagnetti
+ */
+public final class NodeFactory
+{
+ /**
+ * @param metadataNode
+ * @return
+ */
+ public static IMetaData createMetaData( final IParserNode metadataNode )
+ {
+ return new MetaDataNode( metadataNode ).compute();
+ }
+
+ /**
+ * @param packageNode
+ * @return
+ */
+ public static IPackage createPackage( final IParserNode packageNode )
+ {
+ return new PackageNode( packageNode ).compute();
+ }
+
+ private NodeFactory()
+ {
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/PackageNode.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/PackageNode.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/PackageNode.java
new file mode 100644
index 0000000..f8bd8b5
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/PackageNode.java
@@ -0,0 +1,167 @@
+/*
+ * 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.nodes.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.adobe.ac.pmd.nodes.IClass;
+import com.adobe.ac.pmd.nodes.IFunction;
+import com.adobe.ac.pmd.nodes.IPackage;
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.parser.NodeKind;
+
+/**
+ * @author xagnetti
+ */
+class PackageNode extends AbstractNode implements IPackage
+{
+ private IClass classNode;
+ private final List< IFunction > functions;
+ private final List< IParserNode > imports;
+ private String name;
+
+ /**
+ * @param node
+ */
+ protected PackageNode( final IParserNode node )
+ {
+ super( node );
+
+ imports = new ArrayList< IParserNode >();
+ functions = new ArrayList< IFunction >();
+ classNode = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.impl.AbstractNode#compute()
+ */
+ @Override
+ public PackageNode compute()
+ {
+ final IParserNode classWrapperNode = getClassNodeFromCompilationUnitNode( getInternalNode(),
+ 3 );
+ final IParserNode firstChild = getInternalNode().getChild( 0 );
+
+ if ( firstChild.numChildren() > 0
+ && firstChild.getChild( 0 ).getStringValue() != null )
+ {
+ name = firstChild.getChild( 0 ).getStringValue();
+ }
+ else
+ {
+ name = "";
+ }
+ if ( classWrapperNode != null )
+ {
+ classNode = new ClassNode( classWrapperNode ).compute();
+ }
+
+ if ( firstChild.numChildren() > 1
+ && firstChild.getChild( 1 ).numChildren() != 0 )
+ {
+ final List< IParserNode > children = firstChild.getChild( 1 ).getChildren();
+
+ for ( final IParserNode node : children )
+ {
+ if ( node.is( NodeKind.IMPORT ) )
+ {
+ imports.add( node );
+ }
+ }
+ }
+ return this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IPackage#getClassNode()
+ */
+ public IClass getClassNode()
+ {
+ return classNode;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IPackage#getFullyQualifiedClassName()
+ */
+ public String getFullyQualifiedClassName()
+ {
+ if ( !"".equals( name ) )
+ {
+ return name
+ + "." + classNode.getName();
+ }
+ return classNode == null ? ""
+ : classNode.getName();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IPackage#getFunctions()
+ */
+ public List< IFunction > getFunctions()
+ {
+ return functions;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IPackage#getImports()
+ */
+ public List< IParserNode > getImports()
+ {
+ return imports;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.INamable#getName()
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ private IParserNode getClassNodeFromCompilationUnitNode( final IParserNode node,
+ final int depth )
+ {
+ if ( depth == 0
+ || node.numChildren() == 0 )
+ {
+ return null;
+ }
+ for ( final IParserNode child : node.getChildren() )
+ {
+ if ( child.is( NodeKind.CLASS )
+ || child.is( NodeKind.INTERFACE ) )
+ {
+ return child;
+ }
+ final IParserNode localClassNode = getClassNodeFromCompilationUnitNode( child,
+ depth - 1 );
+
+ if ( localClassNode != null )
+ {
+ return localClassNode;
+ }
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/VariableNode.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/VariableNode.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/VariableNode.java
new file mode 100644
index 0000000..3f64380
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/impl/VariableNode.java
@@ -0,0 +1,224 @@
+/*
+ * 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.nodes.impl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import com.adobe.ac.pmd.nodes.IFieldInitialization;
+import com.adobe.ac.pmd.nodes.IIdentifierNode;
+import com.adobe.ac.pmd.nodes.IMetaData;
+import com.adobe.ac.pmd.nodes.IModifiersHolder;
+import com.adobe.ac.pmd.nodes.IVariable;
+import com.adobe.ac.pmd.nodes.MetaData;
+import com.adobe.ac.pmd.nodes.Modifier;
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.parser.NodeKind;
+
+/**
+ * Node representing a variable (var i : int = 0) It contains the variable name,
+ * its type name, the list of modifiers, the list of metadata, and the
+ * initialization expression (if any).
+ *
+ * @author xagnetti
+ */
+class VariableNode extends AbstractNode implements IVariable, IModifiersHolder
+{
+ private IFieldInitialization initializationExpression;
+ private final Map< MetaData, List< IMetaData > > metaDataList;
+ private final Set< Modifier > modifiers;
+ private IdentifierNode name;
+ private IdentifierNode type;
+
+ /**
+ * @param rootNode
+ */
+ protected VariableNode( final IParserNode rootNode )
+ {
+ super( rootNode );
+
+ metaDataList = new LinkedHashMap< MetaData, List< IMetaData > >();
+ modifiers = new HashSet< Modifier >();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.nodes.IMetaDataListHolder#add(com.adobe.ac.pmd.nodes.
+ * IMetaData)
+ */
+ public void add( final IMetaData metaData )
+ {
+ final MetaData metaDataImpl = MetaData.create( metaData.getName() );
+ if ( !metaDataList.containsKey( metaDataImpl ) )
+ {
+ metaDataList.put( metaDataImpl,
+ new ArrayList< IMetaData >() );
+ }
+ metaDataList.get( metaDataImpl ).add( metaData );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.nodes.IModifiersHolder#add(com.adobe.ac.pmd.nodes.Modifier
+ * )
+ */
+ public void add( final Modifier modifier )
+ {
+ modifiers.add( modifier );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.impl.AbstractNode#compute()
+ */
+ @Override
+ public VariableNode compute()
+ {
+ if ( getInternalNode().is( NodeKind.NAME_TYPE_INIT ) )
+ {
+ computeNameTypeInit( getInternalNode() );
+ }
+ else
+ {
+ if ( getInternalNode().numChildren() != 0 )
+ {
+ for ( final IParserNode child : getInternalNode().getChildren() )
+ {
+ if ( child.is( NodeKind.NAME_TYPE_INIT ) )
+ {
+ computeNameTypeInit( child );
+ }
+ else if ( child.is( NodeKind.META_LIST ) )
+ {
+ computeMetaDataList( this,
+ child );
+ }
+ }
+ }
+ }
+ return this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IMetaDataListHolder#getAllMetaData()
+ */
+ public List< IMetaData > getAllMetaData()
+ {
+ final List< IMetaData > list = new ArrayList< IMetaData >();
+
+ for ( final Entry< MetaData, List< IMetaData > > entry : metaDataList.entrySet() )
+ {
+ list.addAll( entry.getValue() );
+ }
+
+ return list;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IVariable#getInitializationExpression()
+ */
+ public IFieldInitialization getInitializationExpression()
+ {
+ return initializationExpression;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.nodes.IMetaDataListHolder#getMetaData(com.adobe.ac.pmd
+ * .nodes.MetaData)
+ */
+ public List< IMetaData > getMetaData( final MetaData metaDataName )
+ {
+ return metaDataList.get( metaDataName );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IMetaDataListHolder#getMetaDataCount()
+ */
+ public int getMetaDataCount()
+ {
+ return metaDataList.size();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.INamable#getName()
+ */
+ public String getName()
+ {
+ return name == null ? ""
+ : name.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.nodes.IVariable#getType()
+ */
+ public IIdentifierNode getType()
+ {
+ return type;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.nodes.IModifiersHolder#is(com.adobe.ac.pmd.nodes.Modifier
+ * )
+ */
+ public boolean is( final Modifier modifier ) // NOPMD
+ {
+ return modifiers.contains( modifier );
+ }
+
+ private void computeNameTypeInit( final IParserNode nameTypeInit )
+ {
+ if ( nameTypeInit.numChildren() != 0 )
+ {
+ for ( final IParserNode child : nameTypeInit.getChildren() )
+ {
+ if ( child.is( NodeKind.NAME ) )
+ {
+ name = IdentifierNode.create( child );
+ }
+ else if ( child.is( NodeKind.TYPE ) )
+ {
+ type = IdentifierNode.create( child );
+ }
+ else if ( child.is( NodeKind.INIT ) )
+ {
+ initializationExpression = FieldInitializationNode.create( child );
+ }
+ else
+ {
+ LOGGER.warning( "unknown node type "
+ + child.toString() );
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/utils/AsDocUtils.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/utils/AsDocUtils.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/utils/AsDocUtils.java
new file mode 100644
index 0000000..c363ca5
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/utils/AsDocUtils.java
@@ -0,0 +1,60 @@
+/*
+ * 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.nodes.utils;
+
+import com.adobe.ac.pmd.nodes.asdoc.impl.ClassAsDocNode;
+import com.adobe.ac.pmd.nodes.asdoc.impl.FunctionAsDocNode;
+import com.adobe.ac.pmd.nodes.asdoc.impl.ParameterAsDocNode;
+
+/**
+ * @author xagnetti
+ */
+public final class AsDocUtils
+{
+ /**
+ * @param doc
+ * @return
+ */
+ public static ClassAsDocNode computeClassDoc( final String doc )
+ {
+ return new ClassAsDocNode( doc );
+ }
+
+ /**
+ * @param doc
+ * @return
+ */
+ public static FunctionAsDocNode computeFunctionDoc( final String doc )
+ {
+ return new FunctionAsDocNode( doc );
+ }
+
+ /**
+ * @param nameToBeSet
+ * @param descriptionToBeSet
+ * @return
+ */
+ public static ParameterAsDocNode computeParameterDoc( final String nameToBeSet,
+ final String descriptionToBeSet )
+ {
+ return new ParameterAsDocNode( nameToBeSet, descriptionToBeSet );
+ }
+
+ private AsDocUtils()
+ {
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/utils/FunctionUtils.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/utils/FunctionUtils.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/utils/FunctionUtils.java
new file mode 100644
index 0000000..cc8d041
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/nodes/utils/FunctionUtils.java
@@ -0,0 +1,53 @@
+/*
+ * 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.nodes.utils;
+
+import com.adobe.ac.ncss.utils.FileUtils;
+import com.adobe.ac.pmd.files.IFlexFile;
+import com.adobe.ac.pmd.parser.IParserNode;
+
+/**
+ * @author xagnetti
+ */
+public final class FunctionUtils
+{
+ /**
+ * @param currentFile
+ * @param block
+ * @return
+ */
+ public static int computeFunctionLength( final IFlexFile currentFile,
+ final IParserNode block )
+ {
+ int lineNb = 1;
+ final int firstLine = block.getChild( 0 ).getLine();
+ final int lastLine = block.getLastChild().getLine();
+
+ for ( int lineIndex = firstLine; lineIndex < lastLine; lineIndex++ )
+ {
+ if ( FileUtils.isLineACorrectStatement( currentFile.getLineAt( lineIndex ) ) )
+ {
+ lineNb++;
+ }
+ }
+ return lineNb;
+ }
+
+ private FunctionUtils()
+ {
+ }
+}