You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2025/05/27 14:48:42 UTC
(sling-org-apache-sling-scripting-sightly-compiler-java) 01/02: SLING-12803 - Update the Scripting HTL Java Compile to the latest pom version
This is an automated email from the ASF dual-hosted git repository.
radu pushed a commit to branch issue/SLING-12803
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-compiler-java.git
commit 18cc076457f760391495144a08d79b40eb085de5
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Tue May 27 15:02:30 2025 +0200
SLING-12803 - Update the Scripting HTL Java Compile to the latest pom version
* applied spotless formatting
---
pom.xml | 87 ++++++------
.../scripting/sightly/java/compiler/ClassInfo.java | 31 ++--
.../sightly/java/compiler/CompilationOutput.java | 30 ++--
.../compiler/GlobalShadowCheckBackendCompiler.java | 31 ++--
.../java/compiler/JavaClassBackendCompiler.java | 40 +++---
.../sightly/java/compiler/JavaEscapeUtils.java | 31 ++--
.../sightly/java/compiler/JavaImportsAnalyzer.java | 5 +-
.../compiler/SightlyJavaCompilerException.java | 33 +++--
.../sightly/java/compiler/impl/CodeGenVisitor.java | 101 +++++++------
.../java/compiler/impl/CommandVisitorHandler.java | 31 ++--
.../java/compiler/impl/CompilationOutputImpl.java | 32 ++---
.../java/compiler/impl/ExpressionTranslator.java | 51 +++----
.../sightly/java/compiler/impl/GenHelper.java | 50 ++++---
.../java/compiler/impl/GlobalShadowChecker.java | 31 ++--
.../java/compiler/impl/JavaClassTemplate.java | 31 ++--
.../sightly/java/compiler/impl/JavaSource.java | 45 +++---
.../java/compiler/impl/SourceGenConstants.java | 30 ++--
.../scripting/sightly/java/compiler/impl/Type.java | 31 ++--
.../sightly/java/compiler/impl/TypeInference.java | 45 +++---
.../sightly/java/compiler/impl/TypeInfo.java | 33 ++---
.../sightly/java/compiler/impl/UnitBuilder.java | 31 ++--
.../java/compiler/impl/VariableAnalyzer.java | 36 ++---
.../java/compiler/impl/VariableDescriptor.java | 31 ++--
.../sightly/java/compiler/impl/VariableScope.java | 35 ++---
.../java/compiler/impl/operator/BinaryOpGen.java | 32 ++---
.../compiler/impl/operator/ComparisonOpGen.java | 70 +++++----
.../compiler/impl/operator/ConcatenateOpGen.java | 34 ++---
.../compiler/impl/operator/EquivalenceOpGen.java | 43 +++---
.../java/compiler/impl/operator/InOpGen.java | 36 ++---
.../compiler/impl/operator/IsWhiteSpaceGen.java | 34 ++---
.../java/compiler/impl/operator/LengthOpGen.java | 34 ++---
.../java/compiler/impl/operator/LogicalOpGen.java | 41 +++---
.../java/compiler/impl/operator/LongOpGen.java | 31 ++--
.../java/compiler/impl/operator/NotOpGen.java | 34 ++---
.../java/compiler/impl/operator/NumericOpGen.java | 42 +++---
.../java/compiler/impl/operator/OpHelper.java | 31 ++--
.../java/compiler/impl/operator/Operators.java | 32 ++---
.../java/compiler/impl/operator/StrictEqGenOp.java | 33 ++---
.../java/compiler/impl/operator/TypedNode.java | 33 ++---
.../java/compiler/impl/operator/UnaryOpGen.java | 32 ++---
.../java/JavaClassBackendCompilerTest.java | 79 ++++++-----
.../java/utils/CharSequenceJavaCompiler.java | 158 +++++++++------------
.../utils/CharSequenceJavaCompilerException.java | 48 +++----
.../sightly/compiler/java/utils/TestUtils.java | 31 ++--
.../compiler/java/utils/fixture/a/TestPojo.java | 39 +++--
.../compiler/java/utils/fixture/b/TestPojo.java | 39 +++--
.../sightly/java/compiler/JavaEscapeUtilsTest.java | 8 +-
47 files changed, 1001 insertions(+), 925 deletions(-)
diff --git a/pom.xml b/pom.xml
index 7dcc51a..ba47b99 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling-bundle-parent</artifactId>
- <version>38</version>
+ <version>62</version>
<relativePath />
</parent>
@@ -39,58 +39,21 @@
<name>Apache Sling Scripting HTL Java Compiler</name>
- <description>
- The Apache Sling Scripting HTL Java Compiler provides support for transpiling the Abstract Syntax Tree produced by the
- org.apache.sling.scripting.sightly.compiler module into Java source code.
- </description>
+ <description>The Apache Sling Scripting HTL Java Compiler provides support for transpiling the Abstract Syntax Tree produced by the
+ org.apache.sling.scripting.sightly.compiler module into Java source code.</description>
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-compiler-java.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-compiler-java.git</developerConnection>
+ <tag>HEAD</tag>
<url>https://github.com/apache/sling-org-apache-sling-scripting-sightly-compiler-java.git</url>
- <tag>HEAD</tag>
- </scm>
+ </scm>
<properties>
- <sling.java.version>8</sling.java.version>
+ <!-- compile version -->
+ <sling.java.version>11</sling.java.version>
</properties>
- <!-- ======================================================================= -->
- <!-- B U I L D -->
- <!-- ======================================================================= -->
- <build>
- <plugins>
- <plugin>
- <groupId>com.github.spotbugs</groupId>
- <artifactId>spotbugs-maven-plugin</artifactId>
- <version>3.1.12.2</version>
- <configuration>
- <effort>Max</effort>
- <xmlOutput>true</xmlOutput>
- </configuration>
- <executions>
- <execution>
- <id>find-bugs</id>
- <phase>process-classes</phase>
- <goals>
- <goal>check</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <!-- No javadocs -->
- <excludePackageNames>
- org.apache.sling.scripting.sightly.java.compiler.impl
- </excludePackageNames>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
<!-- ======================================================================= -->
<!-- D E P E N D E N C I E S -->
<!-- ======================================================================= -->
@@ -162,4 +125,38 @@
</dependency>
</dependencies>
+ <!-- ======================================================================= -->
+ <!-- B U I L D -->
+ <!-- ======================================================================= -->
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.github.spotbugs</groupId>
+ <artifactId>spotbugs-maven-plugin</artifactId>
+ <version>3.1.12.2</version>
+ <configuration>
+ <effort>Max</effort>
+ <xmlOutput>true</xmlOutput>
+ </configuration>
+ <executions>
+ <execution>
+ <id>find-bugs</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-classes</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <!-- No javadocs -->
+ <excludePackageNames>org.apache.sling.scripting.sightly.java.compiler.impl</excludePackageNames>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/ClassInfo.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/ClassInfo.java
index 3bd16b7..d95b646 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/ClassInfo.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/ClassInfo.java
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler;
import org.osgi.annotation.versioning.ProviderType;
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/CompilationOutput.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/CompilationOutput.java
index f177eb2..facaac9 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/CompilationOutput.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/CompilationOutput.java
@@ -1,19 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
+ * 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.sling.scripting.sightly.java.compiler;
import java.util.Map;
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/GlobalShadowCheckBackendCompiler.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/GlobalShadowCheckBackendCompiler.java
index 5806229..54a407f 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/GlobalShadowCheckBackendCompiler.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/GlobalShadowCheckBackendCompiler.java
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler;
import java.util.Set;
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/JavaClassBackendCompiler.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/JavaClassBackendCompiler.java
index 01a8c62..c9761f0 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/JavaClassBackendCompiler.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/JavaClassBackendCompiler.java
@@ -1,19 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
+ * 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.sling.scripting.sightly.java.compiler;
import java.io.IOException;
@@ -43,9 +45,10 @@ public final class JavaClassBackendCompiler implements BackendCompiler {
static {
try {
- mainTemplate = IOUtils
- .toString(JavaClassTemplate.class.getClassLoader().getResourceAsStream(COMPILED_UNIT_TEMPLATE), "UTF-8");
- childTemplate = IOUtils.toString(JavaClassTemplate.class.getClassLoader().getResourceAsStream(SUBTEMPLATE), "UTF-8");
+ mainTemplate = IOUtils.toString(
+ JavaClassTemplate.class.getClassLoader().getResourceAsStream(COMPILED_UNIT_TEMPLATE), "UTF-8");
+ childTemplate = IOUtils.toString(
+ JavaClassTemplate.class.getClassLoader().getResourceAsStream(SUBTEMPLATE), "UTF-8");
} catch (IOException e) {
throw new IllegalStateException(e);
}
@@ -91,7 +94,8 @@ public final class JavaClassBackendCompiler implements BackendCompiler {
private void processCompilationResult(CompilationOutput result, JavaClassTemplate mainTemplate) {
mainTemplate.writeMainBody(result.getMainBody());
- for (Map.Entry<String, CompilationOutput> entry : result.getSubTemplates().entrySet()) {
+ for (Map.Entry<String, CompilationOutput> entry :
+ result.getSubTemplates().entrySet()) {
JavaClassTemplate childTemplate = newChildTemplate();
processCompilationResult(entry.getValue(), childTemplate);
mainTemplate.writeSubTemplate(entry.getKey(), childTemplate.toString());
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/JavaEscapeUtils.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/JavaEscapeUtils.java
index ae5dcfb..9fe7ae1 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/JavaEscapeUtils.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/JavaEscapeUtils.java
@@ -1,19 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
+ * 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.sling.scripting.sightly.java.compiler;
import org.apache.sling.commons.compiler.source.JavaEscapeHelper;
@@ -76,5 +78,4 @@ public class JavaEscapeUtils {
public static boolean isJavaKeyword(String key) {
return JavaEscapeHelper.isJavaKeyword(key);
}
-
}
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/JavaImportsAnalyzer.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/JavaImportsAnalyzer.java
index 23a94e4..1424a79 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/JavaImportsAnalyzer.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/JavaImportsAnalyzer.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
+ */
package org.apache.sling.scripting.sightly.java.compiler;
/**
@@ -33,5 +33,4 @@ public interface JavaImportsAnalyzer {
default boolean allowImport(String importedClass) {
return true;
}
-
}
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/SightlyJavaCompilerException.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/SightlyJavaCompilerException.java
index 7c55278..1b8228d 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/SightlyJavaCompilerException.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/SightlyJavaCompilerException.java
@@ -1,19 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
+ * 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.sling.scripting.sightly.java.compiler;
public class SightlyJavaCompilerException extends RuntimeException {
@@ -34,7 +36,8 @@ public class SightlyJavaCompilerException extends RuntimeException {
super(cause);
}
- protected SightlyJavaCompilerException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ protected SightlyJavaCompilerException(
+ String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/CodeGenVisitor.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/CodeGenVisitor.java
index 50a94c3..f487d1b 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/CodeGenVisitor.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/CodeGenVisitor.java
@@ -1,19 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
+ * 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.sling.scripting.sightly.java.compiler.impl;
import java.util.HashSet;
@@ -77,19 +79,20 @@ public class CodeGenVisitor implements CommandVisitor {
} else {
initSource.startMethodCall(SourceGenConstants.BINDINGS_FIELD, SourceGenConstants.BINDINGS_GET_METHOD);
}
- initSource.stringLiteral(descriptor.getOriginalName())
- .endCall()
- .endStatement();
+ initSource.stringLiteral(descriptor.getOriginalName()).endCall().endStatement();
} else if (scope == VariableScope.GLOBAL) {
- initSource.beginAssignment(descriptor.getAssignedName())
+ initSource
+ .beginAssignment(descriptor.getAssignedName())
.nullLiteral()
.endStatement();
}
String listCoercionVar = descriptor.getListCoercion();
if (listCoercionVar != null) {
- //need to initialize the list coercion to null
- initSource.beginAssignment(listCoercionVar, SourceGenConstants.COLLECTION_TYPE)
- .nullLiteral().endStatement();
+ // need to initialize the list coercion to null
+ initSource
+ .beginAssignment(listCoercionVar, SourceGenConstants.COLLECTION_TYPE)
+ .nullLiteral()
+ .endStatement();
}
}
@@ -104,7 +107,10 @@ public class CodeGenVisitor implements CommandVisitor {
if (descriptor.getType() == Type.BOOLEAN) {
source.append(descriptor.getAssignedName());
} else {
- source.objectModel().startCall(SourceGenConstants.ROM_TO_BOOLEAN, true).append(descriptor.getAssignedName()).endCall();
+ source.objectModel()
+ .startCall(SourceGenConstants.ROM_TO_BOOLEAN, true)
+ .append(descriptor.getAssignedName())
+ .endCall();
}
source.completeIf();
}
@@ -117,17 +123,16 @@ public class CodeGenVisitor implements CommandVisitor {
@Override
public void visit(VariableBinding.Start variableBinding) {
source.startBlock();
- TypeInfo typeInfo = TypeInference
- .inferTypes(variableBinding.getExpression(), analyzer, unitBuilder.getImports(), unitBuilder.getJavaImportsAnalyzer());
+ TypeInfo typeInfo = TypeInference.inferTypes(
+ variableBinding.getExpression(),
+ analyzer,
+ unitBuilder.getImports(),
+ unitBuilder.getJavaImportsAnalyzer());
Type type = typeInfo.typeOf(variableBinding.getExpression());
String properName = declare(variableBinding.getVariableName(), type);
source.beginAssignment(properName, type.getNativeClass());
ExpressionTranslator.buildExpression(
- variableBinding.getExpression(),
- source,
- analyzer,
- typeInfo,
- unitBuilder.getImports());
+ variableBinding.getExpression(), source, analyzer, typeInfo, unitBuilder.getImports());
source.endStatement();
}
@@ -136,7 +141,7 @@ public class CodeGenVisitor implements CommandVisitor {
VariableDescriptor descriptor = analyzer.endVariable();
String listCoercionVar = descriptor.getListCoercion();
if (listCoercionVar != null) {
- //this variable was coerced to list at some point
+ // this variable was coerced to list at some point
generateCoercionClearing(listCoercionVar);
}
source.endBlock();
@@ -144,21 +149,20 @@ public class CodeGenVisitor implements CommandVisitor {
@Override
public void visit(VariableBinding.Global globalAssignment) {
- TypeInfo typeInfo = TypeInference
- .inferTypes(globalAssignment.getExpression(), analyzer, unitBuilder.getImports(), unitBuilder.getJavaImportsAnalyzer());
+ TypeInfo typeInfo = TypeInference.inferTypes(
+ globalAssignment.getExpression(),
+ analyzer,
+ unitBuilder.getImports(),
+ unitBuilder.getJavaImportsAnalyzer());
VariableDescriptor descriptor = analyzer.declareGlobal(globalAssignment.getVariableName());
String name = descriptor.getAssignedName();
source.append(name).assign();
ExpressionTranslator.buildExpression(
- globalAssignment.getExpression(),
- source,
- analyzer,
- typeInfo,
- unitBuilder.getImports());
+ globalAssignment.getExpression(), source, analyzer, typeInfo, unitBuilder.getImports());
source.endStatement();
String listCoercionVar = descriptor.getListCoercion();
if (listCoercionVar != null) {
- //variable was used for list coercion. Generating a coercion clearing
+ // variable was used for list coercion. Generating a coercion clearing
generateCoercionClearing(listCoercionVar);
}
}
@@ -168,7 +172,8 @@ public class CodeGenVisitor implements CommandVisitor {
String variable = analyzer.assignedName(outputVariable.getVariableName());
source.startStatement()
.startMethodCall(SourceGenConstants.OUT_BUFFER, SourceGenConstants.WRITE_METHOD)
- .objectModel().startCall(SourceGenConstants.ROM_TO_STRING, true)
+ .objectModel()
+ .startCall(SourceGenConstants.ROM_TO_STRING, true)
.append(variable)
.endCall()
.endCall()
@@ -189,11 +194,16 @@ public class CodeGenVisitor implements CommandVisitor {
VariableDescriptor descriptor = analyzer.descriptor(loop.getListVariable());
String listVariable = descriptor.getAssignedName();
String collectionVar = descriptor.requireListCoercion();
- source.beginIf().append(collectionVar).equality().nullLiteral().completeIf()
+ source.beginIf()
+ .append(collectionVar)
+ .equality()
+ .nullLiteral()
+ .completeIf()
.startStatement()
.append(collectionVar)
.assign()
- .objectModel().startCall(SourceGenConstants.ROM_TO_COLLECTION, true)
+ .objectModel()
+ .startCall(SourceGenConstants.ROM_TO_COLLECTION, true)
.append(listVariable)
.endCall()
.endStatement()
@@ -216,7 +226,8 @@ public class CodeGenVisitor implements CommandVisitor {
@Override
public void visit(Procedure.Start startProcedure) {
- UnitBuilder subTemplateUnit = unitBuilder.newSubBuilder(startProcedure.getName(), startProcedure.getParameters());
+ UnitBuilder subTemplateUnit =
+ unitBuilder.newSubBuilder(startProcedure.getName(), startProcedure.getParameters());
analyzer.declareTemplate(startProcedure.getName());
control.push(new CodeGenVisitor(subTemplateUnit, control));
}
@@ -249,6 +260,10 @@ public class CodeGenVisitor implements CommandVisitor {
}
private void generateCoercionClearing(String coercionVariableName) {
- source.startStatement().append(coercionVariableName).assign().nullLiteral().endStatement();
+ source.startStatement()
+ .append(coercionVariableName)
+ .assign()
+ .nullLiteral()
+ .endStatement();
}
}
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/CommandVisitorHandler.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/CommandVisitorHandler.java
index 8683512..f29c404 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/CommandVisitorHandler.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/CommandVisitorHandler.java
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl;
import org.apache.sling.scripting.sightly.compiler.commands.Command;
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/CompilationOutputImpl.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/CompilationOutputImpl.java
index 8aedeaa..2b08f85 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/CompilationOutputImpl.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/CompilationOutputImpl.java
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl;
import java.util.Map;
@@ -26,7 +27,6 @@ public final class CompilationOutputImpl implements CompilationOutput {
private final String mainBody;
private final Map<String, CompilationOutput> subTemplates;
-
public CompilationOutputImpl(String mainBody, Map<String, CompilationOutput> subTemplates) {
this.mainBody = mainBody;
this.subTemplates = subTemplates;
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/ExpressionTranslator.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/ExpressionTranslator.java
index 6d36a55..9fde90c 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/ExpressionTranslator.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/ExpressionTranslator.java
@@ -1,19 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
+ * 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.sling.scripting.sightly.java.compiler.impl;
import java.util.Map;
@@ -51,15 +53,12 @@ public final class ExpressionTranslator extends SideEffectVisitor {
private ExpressionTranslator(JavaSource source, VariableAnalyzer analyzer, TypeInfo typeInfo, Set<String> imports) {
this.source = source;
this.analyzer = analyzer;
- this.typeInfo= typeInfo;
+ this.typeInfo = typeInfo;
this.imports = imports;
}
- public static void buildExpression(ExpressionNode node,
- JavaSource source,
- VariableAnalyzer analyzer,
- TypeInfo typeInfo,
- Set<String> imports) {
+ public static void buildExpression(
+ ExpressionNode node, JavaSource source, VariableAnalyzer analyzer, TypeInfo typeInfo, Set<String> imports) {
ExpressionTranslator builder = new ExpressionTranslator(source, analyzer, typeInfo, imports);
builder.traverse(node);
}
@@ -75,7 +74,7 @@ public final class ExpressionTranslator extends SideEffectVisitor {
@Override
public void visit(PropertyAccess propertyAccess) {
if (typeInfo.typeOf(propertyAccess.getTarget()) == Type.MAP) {
- //Special optimization for maps
+ // Special optimization for maps
visit(propertyAccess.getTarget());
source.startCall(SourceGenConstants.MAP_GET, true);
visit(propertyAccess.getProperty());
@@ -104,7 +103,9 @@ public final class ExpressionTranslator extends SideEffectVisitor {
public void visit(BinaryOperation binaryOperation) {
BinaryOpGen opGen = Operators.generatorFor(binaryOperation.getOperator());
source.startExpression();
- opGen.generate(source, this,
+ opGen.generate(
+ source,
+ this,
typeInfo.getTyped(binaryOperation.getLeftOperand()),
typeInfo.getTyped(binaryOperation.getRightOperand()));
source.endExpression();
@@ -117,7 +118,7 @@ public final class ExpressionTranslator extends SideEffectVisitor {
@Override
public void visit(NumericConstant numericConstant) {
- source.append(numericConstant.getValue().toString()); //todo: check correctness
+ source.append(numericConstant.getValue().toString()); // todo: check correctness
}
@Override
@@ -132,7 +133,9 @@ public final class ExpressionTranslator extends SideEffectVisitor {
@Override
public void visit(TernaryOperator ternaryOperator) {
- GenHelper.generateTernary(source, this,
+ GenHelper.generateTernary(
+ source,
+ this,
typeInfo.getTyped(ternaryOperator.getCondition()),
typeInfo.getTyped(ternaryOperator.getThenBranch()),
typeInfo.getTyped(ternaryOperator.getElseBranch()));
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/GenHelper.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/GenHelper.java
index 6f00eee..fea0294 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/GenHelper.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/GenHelper.java
@@ -1,19 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
+ * 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.sling.scripting.sightly.java.compiler.impl;
import java.util.HashMap;
@@ -29,8 +31,12 @@ import org.apache.sling.scripting.sightly.java.compiler.impl.operator.TypedNode;
*/
public class GenHelper {
- public static void generateTernary(JavaSource source, SideEffectVisitor visitor,
- TypedNode condition, TypedNode thenBranch, TypedNode elseBranch) {
+ public static void generateTernary(
+ JavaSource source,
+ SideEffectVisitor visitor,
+ TypedNode condition,
+ TypedNode thenBranch,
+ TypedNode elseBranch) {
source.startExpression();
typeCoercion(source, visitor, condition, Type.BOOLEAN);
source.conditional();
@@ -57,7 +63,7 @@ public class GenHelper {
public static void listCoercion(JavaSource source, ExpressionTranslator visitor, TypedNode typedNode) {
ExpressionNode node = typedNode.getNode();
if (node instanceof Identifier) {
- //using list coercion caching optimization
+ // using list coercion caching optimization
VariableDescriptor descriptor = visitor.getAnalyzer().descriptor(((Identifier) node).getName());
String listCoercionVar = descriptor.requireListCoercion();
source.startExpression()
@@ -68,10 +74,10 @@ public class GenHelper {
.startExpression()
.append(listCoercionVar)
.assign()
- .objectModel().startCall(SourceGenConstants.ROM_TO_COLLECTION, true);
+ .objectModel()
+ .startCall(SourceGenConstants.ROM_TO_COLLECTION, true);
node.accept(visitor);
- source
- .endCall()
+ source.endCall()
.endExpression()
.conditionalBranchSep()
.append(listCoercionVar)
@@ -90,7 +96,8 @@ public class GenHelper {
source.endExpression();
}
- private static void callDynamicCoercion(JavaSource source, SideEffectVisitor visitor, ExpressionNode node, String methodName) {
+ private static void callDynamicCoercion(
+ JavaSource source, SideEffectVisitor visitor, ExpressionNode node, String methodName) {
source.objectModel().startCall(methodName, true);
node.accept(visitor);
source.endCall();
@@ -104,5 +111,4 @@ public class GenHelper {
dynamicCoercions.put(Type.LONG, SourceGenConstants.ROM_TO_NUMBER);
dynamicCoercions.put(Type.DOUBLE, SourceGenConstants.ROM_TO_NUMBER);
}
-
}
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/GlobalShadowChecker.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/GlobalShadowChecker.java
index 8e4b286..ed10246 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/GlobalShadowChecker.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/GlobalShadowChecker.java
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl;
import java.util.HashMap;
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/JavaClassTemplate.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/JavaClassTemplate.java
index 66b43d5..1a5c617 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/JavaClassTemplate.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/JavaClassTemplate.java
@@ -1,19 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
+ * 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.sling.scripting.sightly.java.compiler.impl;
/**
@@ -21,7 +23,6 @@ package org.apache.sling.scripting.sightly.java.compiler.impl;
*/
public class JavaClassTemplate {
-
private String classTemplate;
private static final String PACKAGE_NAME = "PackageName";
private static final String CLASS_NAME = "ClassName";
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/JavaSource.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/JavaSource.java
index cebb2ae..5459fee 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/JavaSource.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/JavaSource.java
@@ -1,19 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
+ * 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.sling.scripting.sightly.java.compiler.impl;
import org.apache.commons.lang3.StringEscapeUtils;
@@ -126,9 +128,7 @@ public class JavaSource {
}
public JavaSource stringLiteral(String text) {
- builder.append('"')
- .append(StringEscapeUtils.escapeJava(text))
- .append('"');
+ builder.append('"').append(StringEscapeUtils.escapeJava(text)).append('"');
return this;
}
@@ -207,7 +207,12 @@ public class JavaSource {
}
public JavaSource beginMethod(String name, String returnType) {
- return startStatement().append("public ").append(returnType).append(" ").append(name).append("(");
+ return startStatement()
+ .append("public ")
+ .append(returnType)
+ .append(" ")
+ .append(name)
+ .append("(");
}
public JavaSource methodParameter(String name, String type) {
@@ -241,7 +246,9 @@ public class JavaSource {
}
public JavaSource objectModel() {
- return startMethodCall(SourceGenConstants.RENDER_CONTEXT_INSTANCE, SourceGenConstants.RENDER_CONTEXT_GET_OBJECT_MODEL).endCall();
+ return startMethodCall(
+ SourceGenConstants.RENDER_CONTEXT_INSTANCE, SourceGenConstants.RENDER_CONTEXT_GET_OBJECT_MODEL)
+ .endCall();
}
public JavaSource property(String target, String property) {
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/SourceGenConstants.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/SourceGenConstants.java
index 758dfd8..17740f2 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/SourceGenConstants.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/SourceGenConstants.java
@@ -1,19 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
+ * 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.sling.scripting.sightly.java.compiler.impl;
/**
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/Type.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/Type.java
index 187c650..21a6b38 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/Type.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/Type.java
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl;
/**
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/TypeInference.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/TypeInference.java
index 4951746..1bf63f0 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/TypeInference.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/TypeInference.java
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl;
import java.util.IdentityHashMap;
@@ -50,11 +51,11 @@ public final class TypeInference implements NodeVisitor<Type> {
private final Map<ExpressionNode, Type> inferMap = new IdentityHashMap<>();
private final Set<String> imports;
private final JavaImportsAnalyzer importsAnalyzer;
- private static final Pattern FQCN_PATTERN = Pattern.compile("([[\\p{L}&&[^\\p{Lu}]]_$][\\p{L}\\p{N}_$]*\\.)+[\\p{Lu}_$][\\p{L}\\p{N}_$]*");
-
+ private static final Pattern FQCN_PATTERN =
+ Pattern.compile("([[\\p{L}&&[^\\p{Lu}]]_$][\\p{L}\\p{N}_$]*\\.)+[\\p{Lu}_$][\\p{L}\\p{N}_$]*");
- public static TypeInfo inferTypes(ExpressionNode node, VariableAnalyzer analyzer, Set<String> imports,
- JavaImportsAnalyzer importsAnalyzer) {
+ public static TypeInfo inferTypes(
+ ExpressionNode node, VariableAnalyzer analyzer, Set<String> imports, JavaImportsAnalyzer importsAnalyzer) {
TypeInference typeInference = new TypeInference(analyzer, imports, importsAnalyzer);
typeInference.infer(node);
return new TypeInfo(typeInference.inferMap);
@@ -66,8 +67,6 @@ public final class TypeInference implements NodeVisitor<Type> {
this.importsAnalyzer = importsAnalyzer;
}
-
-
private Type infer(ExpressionNode node) {
Type type = node.accept(this);
inferMap.put(node, type);
@@ -141,7 +140,9 @@ public final class TypeInference implements NodeVisitor<Type> {
ExpressionNode identifier = runtimeCall.getArguments().get(0);
if (identifier instanceof StringConstant) {
String objectType = ((StringConstant) identifier).getText();
- if (FQCN_PATTERN.matcher(objectType).matches() && importsAnalyzer != null && importsAnalyzer.allowImport(objectType)) {
+ if (FQCN_PATTERN.matcher(objectType).matches()
+ && importsAnalyzer != null
+ && importsAnalyzer.allowImport(objectType)) {
imports.add(objectType);
return Type.dynamic(objectType);
}
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/TypeInfo.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/TypeInfo.java
index 3d0ee13..b33a4cc 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/TypeInfo.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/TypeInfo.java
@@ -1,26 +1,27 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl;
import java.util.Map;
-import org.apache.sling.scripting.sightly.java.compiler.impl.operator.TypedNode;
import org.apache.sling.scripting.sightly.compiler.expression.ExpressionNode;
+import org.apache.sling.scripting.sightly.java.compiler.impl.operator.TypedNode;
/**
* Provide type information for expressions
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/UnitBuilder.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/UnitBuilder.java
index 3a7678c..f834f75 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/UnitBuilder.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/UnitBuilder.java
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl;
import java.util.Collections;
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/VariableAnalyzer.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/VariableAnalyzer.java
index 42497bc..45195a6 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/VariableAnalyzer.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/VariableAnalyzer.java
@@ -1,19 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
+ * 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.sling.scripting.sightly.java.compiler.impl;
import java.util.ArrayList;
@@ -48,8 +50,8 @@ public class VariableAnalyzer {
public VariableDescriptor declareVariable(String originalName, Type type) {
originalName = originalName.toLowerCase();
String safeName = findSafeName(originalName);
- VariableDescriptor descriptor =
- new VariableDescriptor(originalName, JavaEscapeHelper.getJavaIdentifier(safeName), type, VariableScope.SCOPED);
+ VariableDescriptor descriptor = new VariableDescriptor(
+ originalName, JavaEscapeHelper.getJavaIdentifier(safeName), type, VariableScope.SCOPED);
tracker.pushVariable(originalName, descriptor);
variables.add(descriptor);
return descriptor;
@@ -159,7 +161,7 @@ public class VariableAnalyzer {
int occurrenceCount = tracker.getOccurrenceCount(original);
String syntaxSafe = JavaEscapeHelper.getJavaIdentifier(original);
if (occurrenceCount == 0) {
- return syntaxSafe; //no other declarations in scope. Use this very name
+ return syntaxSafe; // no other declarations in scope. Use this very name
} else {
return original + "_" + occurrenceCount;
}
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/VariableDescriptor.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/VariableDescriptor.java
index 800a5bd..4d316fa 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/VariableDescriptor.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/VariableDescriptor.java
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl;
/**
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/VariableScope.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/VariableScope.java
index 7e2fb75..f3c180c 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/VariableScope.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/VariableScope.java
@@ -1,25 +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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl;
/**
* The scope of a variable in a HTL script
*/
public enum VariableScope {
- DYNAMIC, SCOPED, GLOBAL
+ DYNAMIC,
+ SCOPED,
+ GLOBAL
}
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/BinaryOpGen.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/BinaryOpGen.java
index 3fc0d90..499dfdb 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/BinaryOpGen.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/BinaryOpGen.java
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl.operator;
import org.apache.sling.scripting.sightly.java.compiler.impl.ExpressionTranslator;
@@ -29,5 +30,4 @@ public interface BinaryOpGen {
Type returnType(Type leftType, Type rightType);
void generate(JavaSource source, ExpressionTranslator visitor, TypedNode left, TypedNode right);
-
}
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/ComparisonOpGen.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/ComparisonOpGen.java
index 96b626f..1a8f868 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/ComparisonOpGen.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/ComparisonOpGen.java
@@ -1,28 +1,29 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl.operator;
+import org.apache.sling.scripting.sightly.compiler.expression.ExpressionNode;
import org.apache.sling.scripting.sightly.compiler.expression.SideEffectVisitor;
+import org.apache.sling.scripting.sightly.compiler.expression.nodes.BinaryOperator;
import org.apache.sling.scripting.sightly.java.compiler.impl.ExpressionTranslator;
import org.apache.sling.scripting.sightly.java.compiler.impl.JavaSource;
import org.apache.sling.scripting.sightly.java.compiler.impl.Type;
-import org.apache.sling.scripting.sightly.compiler.expression.ExpressionNode;
-import org.apache.sling.scripting.sightly.compiler.expression.nodes.BinaryOperator;
/**
* Generator for logical operators
@@ -40,11 +41,28 @@ public class ComparisonOpGen implements BinaryOpGen {
public ComparisonOpGen(BinaryOperator operator) {
switch (operator) {
- case LT: runtimeMethod = METHOD_LT; inverted = false; javaOperator = "<"; break;
- case GT: runtimeMethod = METHOD_LEQ; inverted = true; javaOperator = ">"; break;
- case LEQ: runtimeMethod = METHOD_LEQ; inverted = false; javaOperator = "<="; break;
- case GEQ: runtimeMethod = METHOD_LT; inverted = true; javaOperator = ">="; break;
- default: throw new IllegalArgumentException("Operator is not a comparison operator: " + operator);
+ case LT:
+ runtimeMethod = METHOD_LT;
+ inverted = false;
+ javaOperator = "<";
+ break;
+ case GT:
+ runtimeMethod = METHOD_LEQ;
+ inverted = true;
+ javaOperator = ">";
+ break;
+ case LEQ:
+ runtimeMethod = METHOD_LEQ;
+ inverted = false;
+ javaOperator = "<=";
+ break;
+ case GEQ:
+ runtimeMethod = METHOD_LT;
+ inverted = true;
+ javaOperator = ">=";
+ break;
+ default:
+ throw new IllegalArgumentException("Operator is not a comparison operator: " + operator);
}
}
@@ -63,7 +81,8 @@ public class ComparisonOpGen implements BinaryOpGen {
}
}
- private void generateGeneric(JavaSource source, SideEffectVisitor visitor, ExpressionNode leftNode, ExpressionNode rightNode) {
+ private void generateGeneric(
+ JavaSource source, SideEffectVisitor visitor, ExpressionNode leftNode, ExpressionNode rightNode) {
if (inverted) {
source.negation().startExpression();
}
@@ -77,11 +96,10 @@ public class ComparisonOpGen implements BinaryOpGen {
}
}
- private void generateWithOperator(JavaSource source, SideEffectVisitor visitor,
- ExpressionNode leftNode, ExpressionNode rightNode) {
+ private void generateWithOperator(
+ JavaSource source, SideEffectVisitor visitor, ExpressionNode leftNode, ExpressionNode rightNode) {
leftNode.accept(visitor);
source.append(" ").append(javaOperator).append(" ");
rightNode.accept(visitor);
}
-
}
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/ConcatenateOpGen.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/ConcatenateOpGen.java
index 1a20a50..3eab00a 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/ConcatenateOpGen.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/ConcatenateOpGen.java
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl.operator;
import org.apache.sling.scripting.sightly.java.compiler.impl.ExpressionTranslator;
@@ -29,8 +30,7 @@ public final class ConcatenateOpGen implements BinaryOpGen {
public static final ConcatenateOpGen INSTANCE = new ConcatenateOpGen();
- private ConcatenateOpGen() {
- }
+ private ConcatenateOpGen() {}
@Override
public Type returnType(Type leftType, Type rightType) {
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/EquivalenceOpGen.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/EquivalenceOpGen.java
index eeb6676..67be928 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/EquivalenceOpGen.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/EquivalenceOpGen.java
@@ -1,27 +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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl.operator;
+import org.apache.sling.scripting.sightly.compiler.expression.ExpressionNode;
import org.apache.sling.scripting.sightly.compiler.expression.SideEffectVisitor;
import org.apache.sling.scripting.sightly.java.compiler.impl.ExpressionTranslator;
import org.apache.sling.scripting.sightly.java.compiler.impl.JavaSource;
import org.apache.sling.scripting.sightly.java.compiler.impl.Type;
-import org.apache.sling.scripting.sightly.compiler.expression.ExpressionNode;
/**
* Generator for logical operators
@@ -49,7 +50,8 @@ public class EquivalenceOpGen implements BinaryOpGen {
}
}
- private void generateCheckedEquals(JavaSource source, SideEffectVisitor visitor, TypedNode leftNode, TypedNode rightNode) {
+ private void generateCheckedEquals(
+ JavaSource source, SideEffectVisitor visitor, TypedNode leftNode, TypedNode rightNode) {
source.startExpression();
leftNode.getNode().accept(visitor);
source.equality().nullLiteral().conditional();
@@ -60,7 +62,8 @@ public class EquivalenceOpGen implements BinaryOpGen {
source.endExpression();
}
- private void generateEqualsMethod(JavaSource source, SideEffectVisitor visitor, TypedNode leftNode, TypedNode rightNode) {
+ private void generateEqualsMethod(
+ JavaSource source, SideEffectVisitor visitor, TypedNode leftNode, TypedNode rightNode) {
boolean performCast = leftNode.getType().isPrimitive();
if (negated) {
source.negation();
@@ -78,7 +81,8 @@ public class EquivalenceOpGen implements BinaryOpGen {
source.endCall();
}
- private void generateEqualsOperator(JavaSource source, SideEffectVisitor visitor, ExpressionNode leftNode, ExpressionNode rightNode) {
+ private void generateEqualsOperator(
+ JavaSource source, SideEffectVisitor visitor, ExpressionNode leftNode, ExpressionNode rightNode) {
leftNode.accept(visitor);
source.append(" ").append(operator()).append(" ");
rightNode.accept(visitor);
@@ -87,5 +91,4 @@ public class EquivalenceOpGen implements BinaryOpGen {
private String operator() {
return (negated) ? "!=" : "==";
}
-
}
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/InOpGen.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/InOpGen.java
index c73c839..718af06 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/InOpGen.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/InOpGen.java
@@ -1,21 +1,21 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ 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.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+/*
+ * 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.sling.scripting.sightly.java.compiler.impl.operator;
import org.apache.sling.scripting.sightly.compiler.expression.nodes.BinaryOperator;
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/IsWhiteSpaceGen.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/IsWhiteSpaceGen.java
index 0be2035..c9272d4 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/IsWhiteSpaceGen.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/IsWhiteSpaceGen.java
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl.operator;
import org.apache.sling.scripting.sightly.java.compiler.impl.ExpressionTranslator;
@@ -30,8 +31,7 @@ public final class IsWhiteSpaceGen implements UnaryOpGen {
public static final IsWhiteSpaceGen INSTANCE = new IsWhiteSpaceGen();
- private IsWhiteSpaceGen() {
- }
+ private IsWhiteSpaceGen() {}
@Override
public Type returnType(Type operandType) {
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/LengthOpGen.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/LengthOpGen.java
index 35f2cf6..e1bd28f 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/LengthOpGen.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/LengthOpGen.java
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl.operator;
import org.apache.sling.scripting.sightly.java.compiler.impl.ExpressionTranslator;
@@ -30,8 +31,7 @@ public final class LengthOpGen implements UnaryOpGen {
public static final LengthOpGen INSTANCE = new LengthOpGen();
- private LengthOpGen() {
- }
+ private LengthOpGen() {}
@Override
public Type returnType(Type operandType) {
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/LogicalOpGen.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/LogicalOpGen.java
index 6613b6b..d0c2519 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/LogicalOpGen.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/LogicalOpGen.java
@@ -1,28 +1,29 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl.operator;
+import org.apache.sling.scripting.sightly.compiler.expression.ExpressionNode;
import org.apache.sling.scripting.sightly.compiler.expression.SideEffectVisitor;
import org.apache.sling.scripting.sightly.java.compiler.impl.ExpressionTranslator;
import org.apache.sling.scripting.sightly.java.compiler.impl.GenHelper;
import org.apache.sling.scripting.sightly.java.compiler.impl.JavaSource;
import org.apache.sling.scripting.sightly.java.compiler.impl.Type;
-import org.apache.sling.scripting.sightly.compiler.expression.ExpressionNode;
/**
* Generator for logical operators
@@ -66,11 +67,11 @@ public abstract class LogicalOpGen implements BinaryOpGen {
}
}
- protected abstract void generateGeneric(JavaSource source, SideEffectVisitor visitor,
- TypedNode left, TypedNode right);
+ protected abstract void generateGeneric(
+ JavaSource source, SideEffectVisitor visitor, TypedNode left, TypedNode right);
- private void generateWithOperator(JavaSource source, SideEffectVisitor visitor,
- ExpressionNode leftNode, ExpressionNode rightNode) {
+ private void generateWithOperator(
+ JavaSource source, SideEffectVisitor visitor, ExpressionNode leftNode, ExpressionNode rightNode) {
leftNode.accept(visitor);
source.append(" ").append(javaOperator).append(" ");
rightNode.accept(visitor);
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/LongOpGen.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/LongOpGen.java
index 7876b96..bab6c15 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/LongOpGen.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/LongOpGen.java
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl.operator;
import org.apache.sling.scripting.sightly.compiler.expression.nodes.BinaryOperator;
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/NotOpGen.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/NotOpGen.java
index a9ec52a..b26966d 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/NotOpGen.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/NotOpGen.java
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl.operator;
import org.apache.sling.scripting.sightly.java.compiler.impl.ExpressionTranslator;
@@ -29,8 +30,7 @@ public final class NotOpGen implements UnaryOpGen {
public static final NotOpGen INSTANCE = new NotOpGen();
- private NotOpGen() {
- }
+ private NotOpGen() {}
@Override
public Type returnType(Type operandType) {
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/NumericOpGen.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/NumericOpGen.java
index 2d57d56..142a90f 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/NumericOpGen.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/NumericOpGen.java
@@ -1,25 +1,25 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl.operator;
import org.apache.sling.scripting.sightly.compiler.expression.nodes.BinaryOperator;
import org.apache.sling.scripting.sightly.java.compiler.impl.ExpressionTranslator;
-import org.apache.sling.scripting.sightly.java.compiler.impl.GenHelper;
import org.apache.sling.scripting.sightly.java.compiler.impl.JavaSource;
import org.apache.sling.scripting.sightly.java.compiler.impl.SourceGenConstants;
import org.apache.sling.scripting.sightly.java.compiler.impl.Type;
@@ -48,12 +48,16 @@ public class NumericOpGen implements BinaryOpGen {
@Override
public void generate(JavaSource source, ExpressionTranslator visitor, TypedNode left, TypedNode right) {
Type commonType = commonType(left.getType(), right.getType());
- source.objectModel().startCall(SourceGenConstants.ROM_TO_NUMBER, true).startMethodCall(OBJECT_NAME + "." + binaryOperator.name(),
- METHOD_NAME);
+ source.objectModel()
+ .startCall(SourceGenConstants.ROM_TO_NUMBER, true)
+ .startMethodCall(OBJECT_NAME + "." + binaryOperator.name(), METHOD_NAME);
left.getNode().accept(visitor);
source.separateArgument();
right.getNode().accept(visitor);
- source.endCall().endCall().startCall(commonType.getNativeClass() + "Value", true).endCall();
+ source.endCall()
+ .endCall()
+ .startCall(commonType.getNativeClass() + "Value", true)
+ .endCall();
}
protected Type commonType(Type leftType, Type rightType) {
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/OpHelper.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/OpHelper.java
index ba90dce..e61c0c5 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/OpHelper.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/OpHelper.java
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl.operator;
import org.apache.sling.scripting.sightly.java.compiler.impl.Type;
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/Operators.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/Operators.java
index a895e4d..05db9f8 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/Operators.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/Operators.java
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl.operator;
import java.util.EnumMap;
@@ -58,7 +59,6 @@ public class Operators {
unaryMapping.put(UnaryOperator.NOT, NotOpGen.INSTANCE);
}
-
/**
* Provide the signature of the given operator
* @param operator - the operator
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/StrictEqGenOp.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/StrictEqGenOp.java
index f024f7b..42b3aa8 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/StrictEqGenOp.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/StrictEqGenOp.java
@@ -1,26 +1,27 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl.operator;
+import org.apache.sling.scripting.sightly.compiler.expression.nodes.BinaryOperator;
import org.apache.sling.scripting.sightly.java.compiler.impl.ExpressionTranslator;
import org.apache.sling.scripting.sightly.java.compiler.impl.JavaSource;
import org.apache.sling.scripting.sightly.java.compiler.impl.Type;
-import org.apache.sling.scripting.sightly.compiler.expression.nodes.BinaryOperator;
/**
* Generator for strict equality
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/TypedNode.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/TypedNode.java
index 0b27fa7..e312bc2 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/TypedNode.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/TypedNode.java
@@ -1,24 +1,25 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl.operator;
-import org.apache.sling.scripting.sightly.java.compiler.impl.Type;
import org.apache.sling.scripting.sightly.compiler.expression.ExpressionNode;
+import org.apache.sling.scripting.sightly.java.compiler.impl.Type;
/**
* Expression nodes with type information
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/UnaryOpGen.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/UnaryOpGen.java
index 0cfa9ee..e7abde4 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/UnaryOpGen.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/UnaryOpGen.java
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.java.compiler.impl.operator;
import org.apache.sling.scripting.sightly.java.compiler.impl.ExpressionTranslator;
@@ -29,5 +30,4 @@ public interface UnaryOpGen {
Type returnType(Type operandType);
void generate(JavaSource source, ExpressionTranslator visitor, TypedNode typedNode);
-
}
diff --git a/src/test/java/org/apache/sling/scripting/sightly/compiler/java/JavaClassBackendCompilerTest.java b/src/test/java/org/apache/sling/scripting/sightly/compiler/java/JavaClassBackendCompilerTest.java
index da22be4..fce4d35 100644
--- a/src/test/java/org/apache/sling/scripting/sightly/compiler/java/JavaClassBackendCompilerTest.java
+++ b/src/test/java/org/apache/sling/scripting/sightly/compiler/java/JavaClassBackendCompilerTest.java
@@ -1,31 +1,32 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+/*
+ * 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
+ * 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.
- ******************************************************************************/
+ * 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.sling.scripting.sightly.compiler.java;
+import javax.script.Bindings;
+import javax.script.SimpleBindings;
+
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
-import javax.script.Bindings;
-import javax.script.SimpleBindings;
-
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
-import org.apache.sling.scripting.sightly.compiler.CompilationResult;
import org.apache.sling.scripting.sightly.compiler.CompilationUnit;
import org.apache.sling.scripting.sightly.compiler.SightlyCompiler;
import org.apache.sling.scripting.sightly.compiler.java.utils.CharSequenceJavaCompiler;
@@ -68,14 +69,19 @@ public class JavaClassBackendCompilerTest {
String source = backendCompiler.build(classInfo);
StringWriter writer = new StringWriter();
Bindings bindings = new SimpleBindings();
- bindings.put("img", new HashMap<String, Object>(){{
- put("attributes", new HashMap<String, String>() {{
- put("v-bind:src", "replaced");
- }});
- }});
+ bindings.put("img", new HashMap<String, Object>() {
+ {
+ put("attributes", new HashMap<String, String>() {
+ {
+ put("v-bind:src", "replaced");
+ }
+ });
+ }
+ });
RenderContext renderContext = buildRenderContext(bindings);
render(writer, classInfo, source, renderContext, new SimpleBindings());
- String expectedOutput = IOUtils.toString(this.getClass().getResourceAsStream("/SLING-6094.1.output.html"), "UTF-8");
+ String expectedOutput =
+ IOUtils.toString(this.getClass().getResourceAsStream("/SLING-6094.1.output.html"), "UTF-8");
assertEquals(expectedOutput, writer.toString());
}
@@ -91,7 +97,8 @@ public class JavaClassBackendCompilerTest {
Bindings bindings = new SimpleBindings();
RenderContext renderContext = buildRenderContext(bindings);
render(writer, classInfo, source, renderContext, new SimpleBindings());
- String expectedOutput = IOUtils.toString(this.getClass().getResourceAsStream("/SLING-6094.2.output.html"), "UTF-8");
+ String expectedOutput =
+ IOUtils.toString(this.getClass().getResourceAsStream("/SLING-6094.2.output.html"), "UTF-8");
assertEquals(expectedOutput, writer.toString());
}
@@ -103,7 +110,8 @@ public class JavaClassBackendCompilerTest {
sightlyCompiler.compile(compilationUnit, backendCompiler);
ClassInfo classInfo = buildClassInfo("imports");
String source = backendCompiler.build(classInfo);
- String expectedJavaOutput = IOUtils.toString(this.getClass().getResourceAsStream("/imports.html.java"), "UTF-8");
+ String expectedJavaOutput =
+ IOUtils.toString(this.getClass().getResourceAsStream("/imports.html.java"), "UTF-8");
assertEquals(normalizeLineEndings(expectedJavaOutput), normalizeLineEndings(source));
ClassLoader classLoader = JavaClassBackendCompilerTest.class.getClassLoader();
CharSequenceJavaCompiler<RenderUnit> compiler = new CharSequenceJavaCompiler<>(classLoader, null);
@@ -120,13 +128,16 @@ public class JavaClassBackendCompilerTest {
String source = backendCompiler.build(classInfo);
StringWriter writer = new StringWriter();
Bindings bindings = new SimpleBindings();
- HashMap<String, Integer> properties = new HashMap<String, Integer>(){{
- put("begin", 1);
- }};
+ HashMap<String, Integer> properties = new HashMap<String, Integer>() {
+ {
+ put("begin", 1);
+ }
+ };
bindings.put("properties", properties);
RenderContext renderContext = buildRenderContext(bindings);
render(writer, classInfo, source, renderContext, new SimpleBindings());
- String expectedOutput = IOUtils.toString(this.getClass().getResourceAsStream("/SLING-8217.output.html"), "UTF-8");
+ String expectedOutput =
+ IOUtils.toString(this.getClass().getResourceAsStream("/SLING-8217.output.html"), "UTF-8");
assertEquals(expectedOutput, writer.toString());
}
@@ -141,7 +152,8 @@ public class JavaClassBackendCompilerTest {
StringWriter writer = new StringWriter();
RenderContext renderContext = buildRenderContext(new SimpleBindings());
render(writer, classInfo, source, renderContext, new SimpleBindings());
- String expectedOutput = IOUtils.toString(this.getClass().getResourceAsStream("/nested-lists.output.html"), "UTF-8");
+ String expectedOutput =
+ IOUtils.toString(this.getClass().getResourceAsStream("/nested-lists.output.html"), "UTF-8");
assertEquals(expectedOutput, writer.toString());
}
@@ -187,8 +199,9 @@ public class JavaClassBackendCompilerTest {
};
}
- private void render(StringWriter writer, ClassInfo classInfo, String source, RenderContext renderContext, Bindings arguments) throws
- Exception {
+ private void render(
+ StringWriter writer, ClassInfo classInfo, String source, RenderContext renderContext, Bindings arguments)
+ throws Exception {
ClassLoader classLoader = JavaClassBackendCompilerTest.class.getClassLoader();
CharSequenceJavaCompiler<RenderUnit> compiler = new CharSequenceJavaCompiler<>(classLoader, null);
Class<RenderUnit> newClass = compiler.compile(classInfo.getFullyQualifiedClassName(), source);
diff --git a/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/CharSequenceJavaCompiler.java b/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/CharSequenceJavaCompiler.java
index b4c752d..e09c39f 100644
--- a/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/CharSequenceJavaCompiler.java
+++ b/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/CharSequenceJavaCompiler.java
@@ -1,21 +1,36 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
+ * 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.sling.scripting.sightly.compiler.java.utils;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticCollector;
+import javax.tools.FileObject;
+import javax.tools.ForwardingJavaFileManager;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaCompiler.CompilationTask;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.JavaFileObject.Kind;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -32,19 +47,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import javax.tools.Diagnostic;
-import javax.tools.DiagnosticCollector;
-import javax.tools.FileObject;
-import javax.tools.ForwardingJavaFileManager;
-import javax.tools.JavaCompiler;
-import javax.tools.JavaCompiler.CompilationTask;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.tools.JavaFileObject.Kind;
-import javax.tools.SimpleJavaFileObject;
-import javax.tools.StandardLocation;
-import javax.tools.ToolProvider;
-
/**
* This compiler is a slightly simplified version of the CharSequenceCompiler described at
* http://www.ibm.com/developerworks/java/library/j-jcomp/index.html.
@@ -82,13 +84,12 @@ public class CharSequenceJavaCompiler<T> {
public CharSequenceJavaCompiler(ClassLoader loader, Iterable<String> options) {
compiler = ToolProvider.getSystemJavaCompiler();
if (compiler == null) {
- throw new IllegalStateException("Cannot find the system Java compiler. "
- + "Check that your class path includes tools.jar");
+ throw new IllegalStateException(
+ "Cannot find the system Java compiler. " + "Check that your class path includes tools.jar");
}
classLoader = new ClassLoaderImpl(loader);
diagnostics = new DiagnosticCollector<>();
- final JavaFileManager fileManager = compiler.getStandardFileManager(diagnostics,
- null, null);
+ final JavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null);
// create our FileManager which chains to the default file manager
// and our ClassLoader
javaFileManager = new FileManagerImpl(fileManager, classLoader);
@@ -124,9 +125,9 @@ public class CharSequenceJavaCompiler<T> {
* if the generated class is not assignable to all the optional
* <var>types</var>.
*/
- public synchronized Class<T> compile(final String qualifiedClassName,
- final CharSequence javaSource,
- final Class<?>... types) throws ClassCastException {
+ public synchronized Class<T> compile(
+ final String qualifiedClassName, final CharSequence javaSource, final Class<?>... types)
+ throws ClassCastException {
Map<String, CharSequence> classes = new HashMap<>(1);
classes.put(qualifiedClassName, javaSource);
try {
@@ -161,34 +162,30 @@ public class CharSequenceJavaCompiler<T> {
* @throws CharSequenceJavaCompilerException
* if the source cannot be compiled
*/
- public synchronized Map<String, Class<T>> compile(final Map<String, CharSequence> classes) throws CharSequenceJavaCompilerException {
+ public synchronized Map<String, Class<T>> compile(final Map<String, CharSequence> classes)
+ throws CharSequenceJavaCompilerException {
List<JavaFileObject> sources = new ArrayList<>();
for (Entry<String, CharSequence> entry : classes.entrySet()) {
String qualifiedClassName = entry.getKey();
CharSequence javaSource = entry.getValue();
if (javaSource != null) {
final int dotPos = qualifiedClassName.lastIndexOf('.');
- final String className = dotPos == -1 ? qualifiedClassName
- : qualifiedClassName.substring(dotPos + 1);
- final String packageName = dotPos == -1 ? "" : qualifiedClassName
- .substring(0, dotPos);
- final JavaFileObjectImpl source = new JavaFileObjectImpl(className,
- javaSource);
+ final String className = dotPos == -1 ? qualifiedClassName : qualifiedClassName.substring(dotPos + 1);
+ final String packageName = dotPos == -1 ? "" : qualifiedClassName.substring(0, dotPos);
+ final JavaFileObjectImpl source = new JavaFileObjectImpl(className, javaSource);
sources.add(source);
// Store the source file in the FileManager via package/class
// name.
// For source files, we add a .java extension
- javaFileManager.putFileForInput(StandardLocation.SOURCE_PATH, packageName,
- className + JAVA_EXTENSION, source);
+ javaFileManager.putFileForInput(
+ StandardLocation.SOURCE_PATH, packageName, className + JAVA_EXTENSION, source);
}
}
// Get a CompliationTask from the compiler and compile the sources
- final CompilationTask task = compiler.getTask(null, javaFileManager, diagnostics,
- options, null, sources);
+ final CompilationTask task = compiler.getTask(null, javaFileManager, diagnostics, options, null, sources);
final Boolean result = task.call();
if (result == null || !result) {
- throw new CharSequenceJavaCompilerException("Compilation failed.", classes
- .keySet(), diagnostics);
+ throw new CharSequenceJavaCompilerException("Compilation failed.", classes.keySet(), diagnostics);
}
try {
// For each class name in the input map, get its compiled
@@ -219,8 +216,7 @@ public class CharSequenceJavaCompiler<T> {
* if no such class is found.
*/
@SuppressWarnings("unchecked")
- public Class<T> loadClass(final String qualifiedClassName)
- throws ClassNotFoundException {
+ public Class<T> loadClass(final String qualifiedClassName) throws ClassNotFoundException {
return (Class<T>) classLoader.loadClass(qualifiedClassName);
}
@@ -235,8 +231,7 @@ public class CharSequenceJavaCompiler<T> {
* @throws ClassCastException
* if <var>newClass</var> is not castable to all the types.
*/
- private Class<T> castable(Class<T> newClass, Class<?>... types)
- throws ClassCastException {
+ private Class<T> castable(Class<T> newClass, Class<?>... types) throws ClassCastException {
for (Class<?> type : types)
if (!type.isAssignableFrom(newClass)) {
throw new ClassCastException(type.getName());
@@ -304,11 +299,9 @@ final class FileManagerImpl extends ForwardingJavaFileManager<JavaFileManager> {
* java.lang.String, java.lang.String)
*/
@Override
- public FileObject getFileForInput(Location location, String packageName,
- String relativeName) throws IOException {
+ public FileObject getFileForInput(Location location, String packageName, String relativeName) throws IOException {
FileObject o = fileObjects.get(uri(location, packageName, relativeName));
- if (o != null)
- return o;
+ if (o != null) return o;
return super.getFileForInput(location, packageName, relativeName);
}
@@ -325,8 +318,8 @@ final class FileManagerImpl extends ForwardingJavaFileManager<JavaFileManager> {
* @param file
* the file object to store for later retrieval
*/
- public void putFileForInput(StandardLocation location, String packageName,
- String relativeName, JavaFileObject file) {
+ public void putFileForInput(
+ StandardLocation location, String packageName, String relativeName, JavaFileObject file) {
fileObjects.put(uri(location, packageName, relativeName), file);
}
@@ -334,8 +327,7 @@ final class FileManagerImpl extends ForwardingJavaFileManager<JavaFileManager> {
* Convert a location and class name to a URI
*/
private URI uri(Location location, String packageName, String relativeName) {
- return CharSequenceJavaCompiler.toURI(location.getName() + '/' + packageName + '/'
- + relativeName);
+ return CharSequenceJavaCompiler.toURI(location.getName() + '/' + packageName + '/' + relativeName);
}
/**
@@ -347,8 +339,8 @@ final class FileManagerImpl extends ForwardingJavaFileManager<JavaFileManager> {
* javax.tools.FileObject)
*/
@Override
- public JavaFileObject getJavaFileForOutput(Location location, String qualifiedName,
- Kind kind, FileObject outputFile) throws IOException {
+ public JavaFileObject getJavaFileForOutput(
+ Location location, String qualifiedName, Kind kind, FileObject outputFile) throws IOException {
JavaFileObject file = new JavaFileObjectImpl(qualifiedName, kind);
classLoader.add(qualifiedName, file);
return file;
@@ -364,31 +356,24 @@ final class FileManagerImpl extends ForwardingJavaFileManager<JavaFileManager> {
String result;
// For our JavaFileImpl instances, return the file's name, else
// simply run the default implementation
- if (file instanceof JavaFileObjectImpl)
- result = file.getName();
- else
- result = super.inferBinaryName(loc, file);
+ if (file instanceof JavaFileObjectImpl) result = file.getName();
+ else result = super.inferBinaryName(loc, file);
return result;
}
@Override
- public Iterable<JavaFileObject> list(Location location, String packageName,
- Set<Kind> kinds, boolean recurse) throws IOException {
- Iterable<JavaFileObject> result = super.list(location, packageName, kinds,
- recurse);
+ public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse)
+ throws IOException {
+ Iterable<JavaFileObject> result = super.list(location, packageName, kinds, recurse);
ArrayList<JavaFileObject> files = new ArrayList<>();
- if (location == StandardLocation.CLASS_PATH
- && kinds.contains(JavaFileObject.Kind.CLASS)) {
+ if (location == StandardLocation.CLASS_PATH && kinds.contains(JavaFileObject.Kind.CLASS)) {
for (JavaFileObject file : fileObjects.values()) {
- if (file.getKind() == Kind.CLASS && file.getName().startsWith(packageName))
- files.add(file);
+ if (file.getKind() == Kind.CLASS && file.getName().startsWith(packageName)) files.add(file);
}
files.addAll(classLoader.files());
- } else if (location == StandardLocation.SOURCE_PATH
- && kinds.contains(JavaFileObject.Kind.SOURCE)) {
+ } else if (location == StandardLocation.SOURCE_PATH && kinds.contains(JavaFileObject.Kind.SOURCE)) {
for (JavaFileObject file : fileObjects.values()) {
- if (file.getKind() == Kind.SOURCE && file.getName().startsWith(packageName))
- files.add(file);
+ if (file.getKind() == Kind.SOURCE && file.getName().startsWith(packageName)) files.add(file);
}
}
for (JavaFileObject file : result) {
@@ -432,8 +417,7 @@ final class JavaFileObjectImpl extends SimpleJavaFileObject {
* the source code
*/
JavaFileObjectImpl(final String baseName, final CharSequence source) {
- super(CharSequenceJavaCompiler.toURI(baseName + CharSequenceJavaCompiler.JAVA_EXTENSION),
- Kind.SOURCE);
+ super(CharSequenceJavaCompiler.toURI(baseName + CharSequenceJavaCompiler.JAVA_EXTENSION), Kind.SOURCE);
this.source = source;
}
@@ -456,10 +440,8 @@ final class JavaFileObjectImpl extends SimpleJavaFileObject {
* @see javax.tools.SimpleJavaFileObject#getCharContent(boolean)
*/
@Override
- public CharSequence getCharContent(final boolean ignoreEncodingErrors)
- throws UnsupportedOperationException {
- if (source == null)
- throw new UnsupportedOperationException("getCharContent()");
+ public CharSequence getCharContent(final boolean ignoreEncodingErrors) throws UnsupportedOperationException {
+ if (source == null) throw new UnsupportedOperationException("getCharContent()");
return source;
}
@@ -511,8 +493,7 @@ final class ClassLoaderImpl extends ClassLoader {
}
@Override
- protected Class<?> findClass(final String qualifiedClassName)
- throws ClassNotFoundException {
+ protected Class<?> findClass(final String qualifiedClassName) throws ClassNotFoundException {
JavaFileObject file = classes.get(qualifiedClassName);
if (file != null) {
byte[] bytes = ((JavaFileObjectImpl) file).getByteCode();
@@ -539,16 +520,15 @@ final class ClassLoaderImpl extends ClassLoader {
}
@Override
- protected synchronized Class<?> loadClass(final String name, final boolean resolve)
- throws ClassNotFoundException {
+ protected synchronized Class<?> loadClass(final String name, final boolean resolve) throws ClassNotFoundException {
return super.loadClass(name, resolve);
}
@Override
public InputStream getResourceAsStream(final String name) {
if (name.endsWith(".class")) {
- String qualifiedClassName = name.substring(0,
- name.length() - ".class".length()).replace('/', '.');
+ String qualifiedClassName =
+ name.substring(0, name.length() - ".class".length()).replace('/', '.');
JavaFileObjectImpl file = (JavaFileObjectImpl) classes.get(qualifiedClassName);
if (file != null) {
return new ByteArrayInputStream(file.getByteCode());
diff --git a/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/CharSequenceJavaCompilerException.java b/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/CharSequenceJavaCompilerException.java
index a5d421a..9b2248b 100644
--- a/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/CharSequenceJavaCompilerException.java
+++ b/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/CharSequenceJavaCompilerException.java
@@ -1,44 +1,45 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
+ * 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.sling.scripting.sightly.compiler.java.utils;
+import javax.tools.DiagnosticCollector;
+import javax.tools.JavaFileObject;
+
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
-import javax.tools.DiagnosticCollector;
-import javax.tools.JavaFileObject;
-
public class CharSequenceJavaCompilerException extends Exception {
private Set<String> classNames;
- transient private DiagnosticCollector<JavaFileObject> diagnostics;
+ private transient DiagnosticCollector<JavaFileObject> diagnostics;
- public CharSequenceJavaCompilerException(String message,
- Set<String> qualifiedClassNames,
- DiagnosticCollector<JavaFileObject> diagnostics) {
+ public CharSequenceJavaCompilerException(
+ String message, Set<String> qualifiedClassNames, DiagnosticCollector<JavaFileObject> diagnostics) {
super(message);
setClassNames(qualifiedClassNames);
setDiagnostics(diagnostics);
}
- public CharSequenceJavaCompilerException(Set<String> qualifiedClassNames,
- Throwable cause, DiagnosticCollector<JavaFileObject> diagnostics) {
+ public CharSequenceJavaCompilerException(
+ Set<String> qualifiedClassNames, Throwable cause, DiagnosticCollector<JavaFileObject> diagnostics) {
super(cause);
setClassNames(qualifiedClassNames);
setDiagnostics(diagnostics);
@@ -69,4 +70,3 @@ public class CharSequenceJavaCompilerException extends Exception {
return Collections.unmodifiableSet(classNames);
}
}
-
diff --git a/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/TestUtils.java b/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/TestUtils.java
index f735e9e..954f65c 100644
--- a/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/TestUtils.java
+++ b/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/TestUtils.java
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
+ * 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.
- ******************************************************************************/
-
+ * 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.sling.scripting.sightly.compiler.java.utils;
import java.io.InputStream;
diff --git a/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/fixture/a/TestPojo.java b/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/fixture/a/TestPojo.java
index 830bf03..3f72232 100644
--- a/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/fixture/a/TestPojo.java
+++ b/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/fixture/a/TestPojo.java
@@ -1,22 +1,21 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ 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.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+/*
+ * 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.sling.scripting.sightly.compiler.java.utils.fixture.a;
-public class TestPojo {
-}
+public class TestPojo {}
diff --git a/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/fixture/b/TestPojo.java b/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/fixture/b/TestPojo.java
index db79e5c..464727e 100644
--- a/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/fixture/b/TestPojo.java
+++ b/src/test/java/org/apache/sling/scripting/sightly/compiler/java/utils/fixture/b/TestPojo.java
@@ -1,22 +1,21 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ 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.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+/*
+ * 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.sling.scripting.sightly.compiler.java.utils.fixture.b;
-public class TestPojo {
-}
+public class TestPojo {}
diff --git a/src/test/java/org/apache/sling/scripting/sightly/java/compiler/JavaEscapeUtilsTest.java b/src/test/java/org/apache/sling/scripting/sightly/java/compiler/JavaEscapeUtilsTest.java
index 06b29ed..9d29b3a 100644
--- a/src/test/java/org/apache/sling/scripting/sightly/java/compiler/JavaEscapeUtilsTest.java
+++ b/src/test/java/org/apache/sling/scripting/sightly/java/compiler/JavaEscapeUtilsTest.java
@@ -18,17 +18,17 @@
*/
package org.apache.sling.scripting.sightly.java.compiler;
-import static org.junit.Assert.assertEquals;
-
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
public class JavaEscapeUtilsTest {
@Test
public void testMakeJavaPackage() {
assertEquals("apps.projects.script__002e__html", JavaEscapeUtils.makeJavaPackage("/apps/projects/script.html"));
// test also with windows path names
- assertEquals("apps.projects.script__002e__html", JavaEscapeUtils.makeJavaPackage("\\apps\\projects\\script.html"));
+ assertEquals(
+ "apps.projects.script__002e__html", JavaEscapeUtils.makeJavaPackage("\\apps\\projects\\script.html"));
}
-
}