flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cd...@apache.org
Subject [01/24] git commit: [flex-utilities] [refs/heads/feature/pmd-5.2-language-module] - Initial commit of the PMD language module for Apache Flex
Date Sat, 07 Mar 2015 12:06:54 GMT
Repository: flex-utilities
Updated Branches:
  refs/heads/feature/pmd-5.2-language-module [created] ff722d6f5


http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/utils/src/main/java/org/apache/flex/pmd/utils/FlexFilter.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/utils/src/main/java/org/apache/flex/pmd/utils/FlexFilter.java
b/FlexPMD/language-module/utils/src/main/java/org/apache/flex/pmd/utils/FlexFilter.java
new file mode 100644
index 0000000..8209330
--- /dev/null
+++ b/FlexPMD/language-module/utils/src/main/java/org/apache/flex/pmd/utils/FlexFilter.java
@@ -0,0 +1,41 @@
+/*
+ * 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 org.apache.flex.pmd.utils;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.Locale;
+
+/**
+ * @author xagnetti
+ */
+public class FlexFilter implements FilenameFilter {
+    /*
+     * (non-Javadoc)
+     * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
+     */
+    public boolean accept(final File dir,
+                          final String name) {
+        boolean accepted = false;
+
+        if (!new File(dir, name).isDirectory()) {
+            accepted = name.toLowerCase(Locale.US).endsWith(".as")
+                    || name.toLowerCase(Locale.US).endsWith(".mxml");
+        }
+        return accepted;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/utils/src/main/java/org/apache/flex/pmd/utils/RegexUtils.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/utils/src/main/java/org/apache/flex/pmd/utils/RegexUtils.java
b/FlexPMD/language-module/utils/src/main/java/org/apache/flex/pmd/utils/RegexUtils.java
new file mode 100644
index 0000000..c00436f
--- /dev/null
+++ b/FlexPMD/language-module/utils/src/main/java/org/apache/flex/pmd/utils/RegexUtils.java
@@ -0,0 +1,16 @@
+package org.apache.flex.pmd.utils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.regex.Pattern;
+
+/**
+ * Created by christoferdutz on 06.03.15.
+ */
+public final class RegexUtils {
+
+    public static boolean isMatch(Pattern pattern, String input) {
+        return ((pattern != null) && StringUtils.isNotBlank(input)) && pattern.matcher(input).find();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/utils/src/main/java/org/apache/flex/pmd/utils/StackTraceUtils.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/utils/src/main/java/org/apache/flex/pmd/utils/StackTraceUtils.java
b/FlexPMD/language-module/utils/src/main/java/org/apache/flex/pmd/utils/StackTraceUtils.java
new file mode 100644
index 0000000..708b4a9
--- /dev/null
+++ b/FlexPMD/language-module/utils/src/main/java/org/apache/flex/pmd/utils/StackTraceUtils.java
@@ -0,0 +1,51 @@
+/*
+ * 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 org.apache.flex.pmd.utils;
+
+/**
+ * @author xagnetti
+ */
+public final class StackTraceUtils {
+    /**
+     * Pretty print the first two lines of the stacktrace of the given exception
+     *
+     * @param exception Exception to print
+     * @return The first two lines of the stacktrace
+     */
+    public static String print(final Exception exception) {
+        return (exception.getMessage()
+                + " at " + exception.getStackTrace()[0] + "\n") + exception.getStackTrace()[1]
+                + "\n" + exception.getStackTrace()[2];
+    }
+
+    /**
+     * Pretty print the first two lines of the stacktrace of the given exception,
+     * specifying which file the exception was thrown on.
+     *
+     * @param fileName  current fileName
+     * @param exception exception thrown
+     * @return error message
+     */
+    public static String print(final String fileName,
+                               final Exception exception) {
+        return "on "
+                + fileName + " " + print(exception);
+    }
+
+    private StackTraceUtils() {
+    }
+}


Mime
View raw message