From d185ee79a3d6850352f57481e3efac5d779ad5b9 Mon Sep 17 00:00:00 2001 From: alexey-andreev Date: Sun, 18 Jan 2015 13:15:11 +0400 Subject: [PATCH] Check html4j with checkstyle --- teavm-html4j/pom.xml | 10 ++- .../html4j/JavaScriptBodyDependency.java | 2 +- .../java/org/teavm/html4j/JsCallback.java | 21 ++---- .../java/org/teavm/html4j/test/Callback.java | 15 ++++ .../org/teavm/html4j/test/KnockoutFXTest.java | 68 ++++++------------- 5 files changed, 49 insertions(+), 67 deletions(-) diff --git a/teavm-html4j/pom.xml b/teavm-html4j/pom.xml index 78f588056..571ca3af6 100644 --- a/teavm-html4j/pom.xml +++ b/teavm-html4j/pom.xml @@ -101,9 +101,6 @@ true true true - - - @@ -116,6 +113,13 @@ org.apache.maven.plugins maven-javadoc-plugin + + org.apache.maven.plugins + maven-checkstyle-plugin + + ../checkstyle.xml + + diff --git a/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptBodyDependency.java b/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptBodyDependency.java index f77ef54b0..e160e9eb1 100644 --- a/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptBodyDependency.java +++ b/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptBodyDependency.java @@ -53,7 +53,7 @@ public class JavaScriptBodyDependency implements DependencyListener { private static class OneDirectionalConnection implements DependencyConsumer { private DependencyNode target; - public OneDirectionalConnection( DependencyNode target) { + public OneDirectionalConnection(DependencyNode target) { this.target = target; } @Override public void consume(DependencyAgentType type) { diff --git a/teavm-html4j/src/main/java/org/teavm/html4j/JsCallback.java b/teavm-html4j/src/main/java/org/teavm/html4j/JsCallback.java index 45ff283bc..6266a132a 100644 --- a/teavm-html4j/src/main/java/org/teavm/html4j/JsCallback.java +++ b/teavm-html4j/src/main/java/org/teavm/html4j/JsCallback.java @@ -87,11 +87,8 @@ abstract class JsCallback { int sigEnd = body.indexOf(')', sigBeg); int colon4 = body.indexOf("::", next); if (sigBeg == -1 || sigEnd == -1 || colon4 == -1) { - throw new IllegalStateException( - "Wrong format of instance callback. " - + "Should be: 'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" - + body - ); + throw new IllegalStateException("Wrong format of instance callback. Should be: " + + "'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body); } String fqn = body.substring(next + 2, colon4); String method = body.substring(colon4 + 2, sigBeg); @@ -99,11 +96,8 @@ abstract class JsCallback { int paramBeg = body.indexOf('(', sigEnd + 1); if (paramBeg == -1) { - throw new IllegalStateException( - "Wrong format of instance callback. " - + "Should be: 'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" - + body - ); + throw new IllegalStateException("Wrong format of instance callback. " + + "Should be: 'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body); } sb.append(callMethod(refId, fqn, method, params)); @@ -133,11 +127,8 @@ abstract class JsCallback { int sigEnd = body.indexOf(')', sigBeg); int colon4 = body.indexOf("::", next); if (sigBeg == -1 || sigEnd == -1 || colon4 == -1) { - throw new IllegalStateException( - "Wrong format of static callback. " - + "Should be: '@pkg.Class::staticMethod(Ljava/lang/Object;)(param)':\n" - + body - ); + throw new IllegalStateException("Wrong format of static callback. Should be: " + + "'@pkg.Class::staticMethod(Ljava/lang/Object;)(param)':\n" + body); } String fqn = body.substring(next + 1, colon4); String method = body.substring(colon4 + 2, sigBeg); diff --git a/teavm-html4j/src/test/java/org/teavm/html4j/test/Callback.java b/teavm-html4j/src/test/java/org/teavm/html4j/test/Callback.java index 0b58916e2..2bbc9e6d4 100644 --- a/teavm-html4j/src/test/java/org/teavm/html4j/test/Callback.java +++ b/teavm-html4j/src/test/java/org/teavm/html4j/test/Callback.java @@ -1,3 +1,18 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * Licensed 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.teavm.html4j.test; import java.util.Calendar; diff --git a/teavm-html4j/src/test/java/org/teavm/html4j/test/KnockoutFXTest.java b/teavm-html4j/src/test/java/org/teavm/html4j/test/KnockoutFXTest.java index f2d2d1547..50fc1bb75 100644 --- a/teavm-html4j/src/test/java/org/teavm/html4j/test/KnockoutFXTest.java +++ b/teavm-html4j/src/test/java/org/teavm/html4j/test/KnockoutFXTest.java @@ -1,44 +1,17 @@ -/** - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +/* + * Copyright 2014 Alexey Andreev. * - * Copyright 2013-2014 Oracle and/or its affiliates. All rights reserved. + * Licensed 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 * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. + * http://www.apache.org/licenses/LICENSE-2.0 * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Oracle. Portions Copyright 2013-2014 Oracle. All Rights Reserved. - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. + * 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.teavm.html4j.test; @@ -120,20 +93,19 @@ public final class KnockoutFXTest extends KnockoutTCK implements Transfer { private static native void setProperty(Object json, String key, Object value); @Override - @JavaScriptBody(args = { "s", "args" }, body = "" - + "var f = new Function(s); " - + "return f.apply(null, args);" + @JavaScriptBody(args = { "s", "args" }, body = + "var f = new Function(s); " + + "return f.apply(null, args);" ) public native Object executeScript(String script, Object[] arguments); @JavaScriptBody(args = { }, body = - "var h;" - + "if (!!window && !!window.location && !!window.location.href)\n" - + " h = window.location.href;\n" - + "else " - + " h = null;" - + "return h;\n" - ) + "var h;" + + "if (!!window && !!window.location && !!window.location.href)\n" + + " h = window.location.href;\n" + + "else " + + " h = null;" + + "return h;\n") private static native String findBaseURL(); @Override