You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by jl...@apache.org on 2018/08/24 17:59:24 UTC
[incubator-netbeans-jackpot30] branch master updated: Cleaning up
command line Jackpot,
trying to fix build and support for JDK 10 and other cleanup.
This is an automated email from the ASF dual-hosted git repository.
jlahoda pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans-jackpot30.git
The following commit(s) were added to refs/heads/master by this push:
new 052839d Cleaning up command line Jackpot, trying to fix build and support for JDK 10 and other cleanup.
052839d is described below
commit 052839d8323fb95e7d97372d25fbacd66adf4519
Author: Jan Lahoda <la...@gmail.com>
AuthorDate: Fri Aug 24 19:59:22 2018 +0200
Cleaning up command line Jackpot, trying to fix build and support for JDK 10 and other cleanup.
---
.travis.yml | 27 ++
DISCLAIMER | 8 +
cmdline/README.md | 61 ++++
cmdline/ant/nbproject/project.properties | 4 +-
cmdline/ap/build.xml | 50 ----
cmdline/ap/manifest.mf | 6 -
cmdline/ap/nbproject/build-impl.xml | 62 ----
cmdline/ap/nbproject/genfiles.properties | 23 --
cmdline/ap/nbproject/project.properties | 18 --
cmdline/ap/nbproject/project.xml | 47 ---
cmdline/ap/nbproject/suite.properties | 16 -
.../services/javax.annotation.processing.Processor | 17 --
.../modules/jackpot30/ap/Bundle.properties | 16 -
cmdline/build.xml | 46 ++-
.../jackpot30/compiler/ant/JackpotCompiler.java | 92 ------
cmdline/compiler/build.xml | 89 ------
cmdline/compiler/manifest.mf | 5 -
cmdline/compiler/nbproject/build-impl.xml | 62 ----
cmdline/compiler/nbproject/genfiles.properties | 23 --
cmdline/compiler/nbproject/project.properties | 23 --
cmdline/compiler/nbproject/project.xml | 315 --------------------
cmdline/compiler/nbproject/suite.properties | 16 -
cmdline/compiler/scripts/README | 32 --
cmdline/compiler/scripts/jackpotc | 19 --
.../api/java/source/CompilationInfoHack.java | 258 ----------------
.../AbstractHintsAnnotationProcessing.java | 43 ---
.../modules/jackpot30/compiler/Bundle.properties | 18 --
.../jackpot30/compiler/CompilerResourcesImpl.java | 55 ----
.../compiler/HintsAnnotationProcessing.java | 329 ---------------------
.../compiler/HintsAnnotationProcessingImpl.java | 263 ----------------
.../compiler/IndexingAnnotationProcessor.java | 157 ----------
.../modules/java/source/parsing/HackAccessor.java | 34 ---
.../netbeans/modules/parsing/api/SnapshotHack.java | 34 ---
cmdline/compiler/test/scripted/config | 23 --
cmdline/compiler/test/scripted/test-ant-1 | 59 ----
.../compiler/test/scripted/test-ant-with-params | 59 ----
cmdline/compiler/test/scripted/test-cmdline-1 | 50 ----
.../compiler/CreateStandaloneCompilerJar.java | 44 ---
.../compiler/CreateStandaloneCompilerJarTest.java | 65 ----
.../compiler/HintsAnnotationProcessingTest.java | 236 ---------------
.../HintsAnnotationProcessingTestBase.java | 204 -------------
.../compiler/IndexingAnnotationProcessorTest.java | 102 -------
cmdline/lib/build.xml | 2 +-
cmdline/lib/nbproject/project.properties | 1 -
cmdline/lib/nbproject/project.xml | 19 +-
.../modules/jackpot30/cmdline/lib/DumpHints.java | 33 ++-
.../jackpot30/cmdline/lib/StandaloneTools.java | 50 ++--
.../modules/jackpot30/cmdline/lib/Utils.java | 89 ++++++
.../jackpot30/cmdline/lib/CreateStandaloneJar.java | 63 ++--
cmdline/maven/pom.xml | 4 +-
cmdline/nbproject/platform.properties | 18 +-
cmdline/nbproject/project.properties | 6 +-
cmdline/tool/build.xml | 35 ++-
cmdline/tool/nbproject/project.properties | 5 +-
cmdline/tool/nbproject/project.xml | 18 +-
cmdline/tool/scripts/jackpot | 2 +-
.../netbeans/modules/jackpot30/cmdline/Main.java | 214 ++++++++------
.../modules/jackpot30/cmdline}/ProcessorImpl.java | 246 ++++++++-------
.../modules/jackpot30/cmdline/cfg_hints.xml | 241 +++++++++++++++
.../modules/jackpot30/cmdline/CreateTool.java | 12 +-
...eToolTest.java => CreateToolProcessorTest.java} | 77 +----
.../modules/jackpot30/cmdline/CreateToolTest.java | 7 +-
.../modules/jackpot30/cmdline/MainTest.java | 188 +++++++++---
.../jackpot30/cmdline}/ProcessorImplTest.java | 39 ++-
.../netbeans/modules/jackpot30/cmdline/Utils.java | 99 +++++++
65 files changed, 1163 insertions(+), 3415 deletions(-)
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..baf9ed4
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,27 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+language: java
+jdk:
+ - openjdk10
+before_script:
+ - wget 'http://www.apache.org/dyn/closer.lua?action=download&filename=incubator/netbeans/incubating-netbeans-java/incubating-9.0/incubating-netbeans-java-9.0-bin.zip' -O /tmp/incubating-netbeans-java-9.0-bin.zip
+ - (cd $HOME; unzip /tmp/incubating-netbeans-java-9.0-bin.zip)
+ - unset _JAVA_OPTIONS
+script:
+ - export JDK10=$JAVA_HOME
+ - jdk_switcher use oraclejdk8
+ - (cd cmdline; ant -Dnbplatform.default.harness.dir=$HOME/netbeans/harness -DNETBEANS_PLATFORM=$HOME/netbeans -DJDK10=$JDK10 build-and-test)
diff --git a/DISCLAIMER b/DISCLAIMER
new file mode 100644
index 0000000..d6f7fea
--- /dev/null
+++ b/DISCLAIMER
@@ -0,0 +1,8 @@
+Apache NetBeans is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of
+all newly accepted projects until a further review indicates that the
+infrastructure, communications, and decision making process have stabilized in
+a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the
+ASF.
diff --git a/cmdline/README.md b/cmdline/README.md
new file mode 100644
index 0000000..d73ccd9
--- /dev/null
+++ b/cmdline/README.md
@@ -0,0 +1,61 @@
+<!--
+
+ 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.
+
+-->
+
+# Apache NetBeans Jackpot
+
+This tool allows to run NetBeans Java code checker without the NetBeans IDE. This includes running the custom Java hints specified in META-INF/upgrade/*.hint.
+
+### Requirements
+
+#### To Build
+
+* NetBeans 9.0
+* JDK 8 and JDK 10
+* bash
+* ant 1.9.9 or above
+
+#### To Run
+
+* JDK 10
+
+### Building
+
+Build using:
+
+```
+$ ant -DNETBEANS_PLATFORM=<path-to-NetBeans-9.0> -DJDK10=<path-to-JDK-10> build-and-test
+```
+
+The built product is in tool/build/jackpot.
+
+### Running
+
+Run using:
+
+```
+$ jackpot <options> <files-to-inspect>
+```
+
+To get help on the options, run:
+
+```
+$ jackpot --help
+```
diff --git a/cmdline/ant/nbproject/project.properties b/cmdline/ant/nbproject/project.properties
index 3bac6fe..af74793 100644
--- a/cmdline/ant/nbproject/project.properties
+++ b/cmdline/ant/nbproject/project.properties
@@ -53,8 +53,8 @@ javac.compilerargs=
javac.deprecation=false
javac.processorpath=\
${javac.classpath}
-javac.source=1.6
-javac.target=1.6
+javac.source=1.8
+javac.target=1.8
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}:\
diff --git a/cmdline/ap/build.xml b/cmdline/ap/build.xml
deleted file mode 100644
index ff578b4..0000000
--- a/cmdline/ap/build.xml
+++ /dev/null
@@ -1,50 +0,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
- 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.
--->
-<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
-<!-- for some information on what you could do (e.g. targets to override). -->
-<!-- If you delete this file and reopen the project it will be recreated. -->
-<project name="org.netbeans.modules.jackpot30.ap" default="netbeans" basedir=".">
- <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.ap.</description>
- <import file="nbproject/build-impl.xml"/>
- <property name="bootclasspath.prepend" value="" />
- <import file="${suite.dir}/../findbugs-import.xml"/>
-
- <target name="-check-lib-exists" depends="files-init">
- <condition property="jackpot.lib.exists" value="true">
- <available file="${build.dir}/jackpot-ap-lib.jar" />
- </condition>
- </target>
- <target name="build-init" depends="harness.build-init,-check-lib-exists" unless="jackpot.lib.exists">
- <mkdir dir="${build.dir}/" />
- <ant dir="../lib" target="test" inheritall="false" inheritrefs="false">
- <property name="test.config.standalone.includes" value="org/netbeans/modules/jackpot30/cmdline/lib/CreateAPLibJar.class"/>
- <property name="test.config" value="standalone"/>
- <property name="test-unit-sys-prop.outputDir" location="${build.dir}/" />
- </ant>
- </target>
- <target name="build-ap-jar" depends="compile">
- <delete dir="${build.dir}/temp-unpack" failonerror="false"/>
- <mkdir dir="${build.dir}/temp-unpack" />
- <unjar src="${build.dir}/jackpot-ap-lib.jar" dest="${build.dir}/temp-unpack" />
- <copy todir="${build.dir}/temp-unpack">
- <fileset dir="${build.classes.dir}"/>
- </copy>
- <jar destfile="${build.dir}/jackpot-ap.jar" basedir="${build.dir}/temp-unpack" />
- </target>
-</project>
diff --git a/cmdline/ap/manifest.mf b/cmdline/ap/manifest.mf
deleted file mode 100644
index b85e04a..0000000
--- a/cmdline/ap/manifest.mf
+++ /dev/null
@@ -1,6 +0,0 @@
-Manifest-Version: 1.0
-AutoUpdate-Show-In-Client: true
-OpenIDE-Module: org.netbeans.modules.jackpot30.ap
-OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/ap/Bundle.properties
-OpenIDE-Module-Specification-Version: 1.0
-
diff --git a/cmdline/ap/nbproject/build-impl.xml b/cmdline/ap/nbproject/build-impl.xml
deleted file mode 100644
index ec47f9a..0000000
--- a/cmdline/ap/nbproject/build-impl.xml
+++ /dev/null
@@ -1,62 +0,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
- 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.
--->
-<!--
-*** GENERATED FROM project.xml - DO NOT EDIT ***
-*** EDIT ../build.xml INSTEAD ***
--->
-<project name="org.netbeans.modules.jackpot30.ap-impl" basedir="..">
- <fail message="Please build using Ant 1.7.1 or higher.">
- <condition>
- <not>
- <antversion atleast="1.7.1"/>
- </not>
- </condition>
- </fail>
- <property file="nbproject/private/suite-private.properties"/>
- <property file="nbproject/suite.properties"/>
- <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
- <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
- <property file="${suite.dir}/nbproject/platform.properties"/>
- <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
- <attribute name="name"/>
- <attribute name="value"/>
- <sequential>
- <property name="@{name}" value="${@{value}}"/>
- </sequential>
- </macrodef>
- <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
- <attribute name="property"/>
- <attribute name="value"/>
- <sequential>
- <property name="@{property}" value="@{value}"/>
- </sequential>
- </macrodef>
- <property file="${user.properties.file}"/>
- <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
- <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
- <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
- <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
- <condition>
- <not>
- <contains string="${cluster.path.evaluated}" substring="platform"/>
- </not>
- </condition>
- </fail>
- <import file="${harness.dir}/build.xml"/>
-</project>
diff --git a/cmdline/ap/nbproject/genfiles.properties b/cmdline/ap/nbproject/genfiles.properties
deleted file mode 100644
index d5ce80d..0000000
--- a/cmdline/ap/nbproject/genfiles.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-# 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.
-
-build.xml.data.CRC32=abf35b3d
-build.xml.script.CRC32=434ef419
-build.xml.stylesheet.CRC32=a56c6a5b@2.70
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=abf35b3d
-nbproject/build-impl.xml.script.CRC32=dd901283
-nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.70
diff --git a/cmdline/ap/nbproject/project.properties b/cmdline/ap/nbproject/project.properties
deleted file mode 100644
index 5df14d8..0000000
--- a/cmdline/ap/nbproject/project.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# 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.
-
-javac.source=1.7
-javac.compilerargs=-Xlint -Xlint:-serial
-cp.extra=build/jackpot-ap-lib.jar:${tools.jar}
diff --git a/cmdline/ap/nbproject/project.xml b/cmdline/ap/nbproject/project.xml
deleted file mode 100644
index 7d1cf58..0000000
--- a/cmdline/ap/nbproject/project.xml
+++ /dev/null
@@ -1,47 +0,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
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<project xmlns="http://www.netbeans.org/ns/project/1">
- <type>org.netbeans.modules.apisupport.project</type>
- <configuration>
- <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
- <code-name-base>org.netbeans.modules.jackpot30.ap</code-name-base>
- <suite-component/>
- <module-dependencies/>
- <test-dependencies>
- <test-type>
- <name>unit</name>
- <test-dependency>
- <code-name-base>org.netbeans.libs.junit4</code-name-base>
- <compile-dependency/>
- </test-dependency>
- <test-dependency>
- <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
- <compile-dependency/>
- </test-dependency>
- <test-dependency>
- <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
- <recursive/>
- <compile-dependency/>
- </test-dependency>
- </test-type>
- </test-dependencies>
- <public-packages/>
- </data>
- </configuration>
-</project>
diff --git a/cmdline/ap/nbproject/suite.properties b/cmdline/ap/nbproject/suite.properties
deleted file mode 100644
index 5f42472..0000000
--- a/cmdline/ap/nbproject/suite.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-# 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.
-
-suite.dir=${basedir}/..
diff --git a/cmdline/ap/src/META-INF/services/javax.annotation.processing.Processor b/cmdline/ap/src/META-INF/services/javax.annotation.processing.Processor
deleted file mode 100644
index cc27238..0000000
--- a/cmdline/ap/src/META-INF/services/javax.annotation.processing.Processor
+++ /dev/null
@@ -1,17 +0,0 @@
-# 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.
-
-
-org.netbeans.modules.jackpot30.ap.ProcessorImpl
diff --git a/cmdline/ap/src/org/netbeans/modules/jackpot30/ap/Bundle.properties b/cmdline/ap/src/org/netbeans/modules/jackpot30/ap/Bundle.properties
deleted file mode 100644
index dad9c0c..0000000
--- a/cmdline/ap/src/org/netbeans/modules/jackpot30/ap/Bundle.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-# 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.
-
-OpenIDE-Module-Name=Jackpot 3.0 Annotation Processing
diff --git a/cmdline/build.xml b/cmdline/build.xml
index c8b5032..033893e 100644
--- a/cmdline/build.xml
+++ b/cmdline/build.xml
@@ -22,5 +22,49 @@
<project name="cmdline" basedir=".">
<description>Builds the module suite cmdline.</description>
<import file="nbproject/build-impl.xml"/>
- <import file="../suite-common.xml"/>
+<!-- <import file="../suite-common.xml"/>-->
+
+ <!-- copied (and adjusted) from suite.xml: -->
+ <target name="test" depends="build" description="Runs tests for all modules in the suite.">
+ <sortsuitemodules unsortedmodules="${modules}" sortedmodulesproperty="modules.test.sorted" sorttests="true"/>
+ <subant target="test" buildpath="${modules.test.sorted}" inheritrefs="false" inheritall="false">
+ <property name="cluster.path.evaluated" value="${cluster.path.evaluated}"/> <!-- Just for speed of pre-7.0 projects -->
+ <property name="harness.taskdefs.done" value="${harness.taskdefs.done}"/> <!-- optimization -->
+ </subant>
+ </target>
+
+ <target name="build-source-dist">
+ <mkdir dir="build" />
+ <zip file="build/incubating-apache-netbeans-jackpot-${version}.zip">
+ <zipfileset dir="." />
+ <zipfileset dir=".." includes="DISCLAIMER" fullpath="DISCLAIMER"/>
+ <zipfileset dir=".." includes="LICENSE" fullpath="LICENSE"/>
+ <zipfileset dir=".." includes="NOTICE" fullpath="NOTICE"/>
+ </zip>
+ </target>
+
+ <target name="build-and-test">
+ <ant dir="${basedir}" inheritAll="false" inheritRefs="false">
+ <property name="nbplatform.default.harness.dir" value="${NETBEANS_PLATFORM}/harness" />
+ <property name="nbplatform.default.netbeans.dest.dir" value="${NETBEANS_PLATFORM}" />
+ <property name="test.run.args" value="--add-exports=jdk.javadoc/com.sun.tools.javadoc.main=ALL-UNNAMED" />
+ <property name="test.nbjdk.home" value="${JDK10}" />
+ <target name="clean" />
+ <target name="build" />
+ <target name="test" />
+ </ant>
+ <ant dir="${basedir}/tool" target="create-standalone-tool" inheritAll="false" inheritRefs="false">
+ <property name="nbplatform.default.harness.dir" value="${NETBEANS_PLATFORM}/harness" />
+ <property name="nbplatform.default.netbeans.dest.dir" value="${NETBEANS_PLATFORM}" />
+ <property name="continue.after.failing.tests" value="false" />
+ <property name="test.run.args" value="--add-exports=jdk.javadoc/com.sun.tools.javadoc.main=ALL-UNNAMED" />
+ <property name="test.nbjdk.home" value="${JDK10}" />
+ </ant>
+ <property environment="env"/>
+ <exec executable="build/test/scripted/run" dir="tool" failonerror="true">
+ <env key="JAVA_HOME" path="${JDK10}" />
+ <env key="PATH" path="${JDK10}/bin:${env.PATH}" />
+ </exec>
+ </target>
+
</project>
diff --git a/cmdline/compiler/antsrc/org/netbeans/modules/jackpot30/compiler/ant/JackpotCompiler.java b/cmdline/compiler/antsrc/org/netbeans/modules/jackpot30/compiler/ant/JackpotCompiler.java
deleted file mode 100644
index 11e2302..0000000
--- a/cmdline/compiler/antsrc/org/netbeans/modules/jackpot30/compiler/ant/JackpotCompiler.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * 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.netbeans.modules.jackpot30.compiler.ant;
-
-import java.lang.reflect.Field;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Javac;
-import org.apache.tools.ant.taskdefs.compilers.JavacExternal;
-import org.apache.tools.ant.types.Commandline;
-import org.apache.tools.ant.types.Commandline.Argument;
-import org.netbeans.modules.jackpot30.compiler.HintsAnnotationProcessing;
-import org.netbeans.modules.jackpot30.compiler.IndexingAnnotationProcessor;
-import org.openide.util.Exceptions;
-
-/**
- *
- * @author lahvac
- */
-public class JackpotCompiler extends JavacExternal {
-
- @Override
- public boolean execute() throws BuildException {
- try {
- Field forkField = Javac.class.getDeclaredField("fork");
-
- forkField.setAccessible(true);
- forkField.set(getJavac(), true);
- } catch (IllegalArgumentException ex) {
- Exceptions.printStackTrace(ex);
- } catch (IllegalAccessException ex) {
- Exceptions.printStackTrace(ex);
- } catch (NoSuchFieldException ex) {
- Exceptions.printStackTrace(ex);
- } catch (SecurityException ex) {
- Exceptions.printStackTrace(ex);
- }
-
- return super.execute();
- }
-
- @Override
- protected Commandline setupJavacCommandlineSwitches(Commandline cmd, boolean useDebugLevel) {
- super.setupJavacCommandlineSwitches(cmd, useDebugLevel);
-
- URL jackpotCompiler = HintsAnnotationProcessing.class.getProtectionDomain().getCodeSource().getLocation();
- String jackpotCompilerPath = jackpotCompiler.getPath();
- Argument arg = cmd.createArgument(true);
- List<String> options = new LinkedList<String>();
- StringBuilder enabledHintsProp = new StringBuilder();
-
- options.addAll(HintsAnnotationProcessing.OPTIONS);
- options.addAll(IndexingAnnotationProcessor.OPTIONS);
-
- for (String prop : options) {
- String val = getProject().getProperty(prop);
-
- if (val != null) {
- enabledHintsProp.append(" -A").append(prop).append("=").append(val);
- }
- }
-
- arg.setLine("-J-Xbootclasspath/p:" + jackpotCompilerPath + " -Xjcov -J-Xmx256m" + enabledHintsProp); //XXX: Xmx!
-
- return cmd;
- }
-
-
-}
diff --git a/cmdline/compiler/build.xml b/cmdline/compiler/build.xml
deleted file mode 100644
index b097688..0000000
--- a/cmdline/compiler/build.xml
+++ /dev/null
@@ -1,89 +0,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
- 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.
--->
-<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
-<!-- for some information on what you could do (e.g. targets to override). -->
-<!-- If you delete this file and reopen the project it will be recreated. -->
-<project name="org.netbeans.modules.jackpot30.compiler" default="netbeans" basedir=".">
- <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.compiler.</description>
- <import file="nbproject/build-impl.xml"/>
- <import file="${suite.dir}/../findbugs-import.xml"/>
-
- <target name="ant" depends="init,jar">
- <mkdir dir="build/antclasses"/>
- <javac srcdir="antsrc" destdir="build/antclasses" source="1.5" target="1.5" debug="true" deprecation="true">
- <classpath>
- <path refid="cp"/>
- <pathelement location="${ant.jar}"/>
- <pathelement location="${tools.jar}"/>
- <pathelement location="${cluster}/modules/${code.name.base.dashes}.jar"/>
- </classpath>
- <compilerarg line="-proc:none" />
- </javac>
- <copy todir="build/antclasses">
- <fileset dir="antsrc" excludes="${jar-excludes}"/>
- </copy>
- <property name="ant.library.target.dir" value="${cluster}/antextra" />
- <mkdir dir="${ant.library.target.dir}"/>
- <jar jarfile="${ant.library.target.dir}/${code.name.base.dashes}.jar" compress="false">
- <fileset dir="build/antclasses"/>
- </jar>
- </target>
-
- <target name="copy-to-hudson" depends="create-standalone-compiler">
- <mkdir dir="${hudson.compiler.dir}" /> <!--only to be sure, should exist-->
- <copy file="${build.classes.dir}/../jackpotc/ant-jackpotc.jar" todir="${hudson.compiler.dir}"/>
- <copy file="${build.classes.dir}/../jackpotc/jackpotc.jar" todir="${hudson.compiler.dir}"/>
- </target>
-
- <target name="create-standalone-compiler" depends="init,ant">
- <mkdir dir="${build.classes.dir}/../jackpotc" />
- <copy file="${ant.library.target.dir}/${code.name.base.dashes}.jar" tofile="${build.classes.dir}/../jackpotc/ant-jackpotc.jar"/>
- <copy todir="${build.classes.dir}/../jackpotc">
- <fileset dir="scripts"/>
- </copy>
- <chmod dir="${build.classes.dir}/../jackpotc" perm="ugo+x" includes="jackpotc"/>
- <ant target="test" inheritall="false" inheritrefs="false">
- <property name="test.config.standalone.includes" value="org/netbeans/modules/jackpot30/compiler/CreateStandaloneCompilerJar.class"/>
- <property name="test.config" value="standalone"/>
- <property name="test-unit-sys-prop.outputDir" location="${build.classes.dir}/../jackpotc" />
- </ant>
- <zip destfile="${build.classes.dir}/../jackpotc.zip">
- <zipfileset file="${build.classes.dir}/../jackpotc/jackpotc" filemode="755" fullpath="jackpotc/jackpotc"/>
- <zipfileset dir="${build.classes.dir}/../jackpotc" prefix="jackpotc">
- <exclude name="hints" />
- <exclude name="jackpotc" />
- </zipfileset>
- </zip>
- </target>
-
- <target name="clean" depends="init,projectized-common.clean">
- <delete file="${hudson.compiler.dir}/ant-jackpotc.jar"/>
- <delete file="${hudson.compiler.dir}/jackpotc.jar"/>
- </target>
-
- <target name="netbeans-extra" depends="ant"/>
-
- <target name="test-build" depends="projectized-common.test-build,-prepare-scripted-tests" />
- <target name="build-init" depends="harness.build-init">
- <condition property="run.bootclasspath.prepend" value="${bootclasspath.prepend}">
- <istrue value="${requires.nb.javac}"/>
- </condition>
- </target>
-
-</project>
diff --git a/cmdline/compiler/manifest.mf b/cmdline/compiler/manifest.mf
deleted file mode 100644
index fa5d74e..0000000
--- a/cmdline/compiler/manifest.mf
+++ /dev/null
@@ -1,5 +0,0 @@
-Manifest-Version: 1.0
-OpenIDE-Module: org.netbeans.modules.jackpot30.compiler
-OpenIDE-Module-Implementation-Version: 1
-OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/compiler/Bundle.properties
-
diff --git a/cmdline/compiler/nbproject/build-impl.xml b/cmdline/compiler/nbproject/build-impl.xml
deleted file mode 100644
index e091de5..0000000
--- a/cmdline/compiler/nbproject/build-impl.xml
+++ /dev/null
@@ -1,62 +0,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
- 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.
--->
-<!--
-*** GENERATED FROM project.xml - DO NOT EDIT ***
-*** EDIT ../build.xml INSTEAD ***
--->
-<project name="org.netbeans.modules.jackpot30.compiler-impl" basedir="..">
- <fail message="Please build using Ant 1.7.1 or higher.">
- <condition>
- <not>
- <antversion atleast="1.7.1"/>
- </not>
- </condition>
- </fail>
- <property file="nbproject/private/suite-private.properties"/>
- <property file="nbproject/suite.properties"/>
- <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
- <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
- <property file="${suite.dir}/nbproject/platform.properties"/>
- <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
- <attribute name="name"/>
- <attribute name="value"/>
- <sequential>
- <property name="@{name}" value="${@{value}}"/>
- </sequential>
- </macrodef>
- <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
- <attribute name="property"/>
- <attribute name="value"/>
- <sequential>
- <property name="@{property}" value="@{value}"/>
- </sequential>
- </macrodef>
- <property file="${user.properties.file}"/>
- <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
- <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
- <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
- <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
- <condition>
- <not>
- <contains string="${cluster.path.evaluated}" substring="platform"/>
- </not>
- </condition>
- </fail>
- <import file="${harness.dir}/build.xml"/>
-</project>
diff --git a/cmdline/compiler/nbproject/genfiles.properties b/cmdline/compiler/nbproject/genfiles.properties
deleted file mode 100644
index a7015e0..0000000
--- a/cmdline/compiler/nbproject/genfiles.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-# 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.
-
-build.xml.data.CRC32=bbccd04c
-build.xml.script.CRC32=3d84c86a
-build.xml.stylesheet.CRC32=79c3b980@1.33
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=bd5c4e9e
-nbproject/build-impl.xml.script.CRC32=64f6fe95
-nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.70
diff --git a/cmdline/compiler/nbproject/project.properties b/cmdline/compiler/nbproject/project.properties
deleted file mode 100644
index e0f6a71..0000000
--- a/cmdline/compiler/nbproject/project.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-# 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.
-
-ant.jar=${ant.core.lib}
-is.autoload=true
-javac.source=1.6
-javac.compilerargs=-Xlint -Xlint:-serial
-spec.version.base=1.16.0
-requires.nb.javac=true
-spec.version.base=1.16.0
-hudson.compiler.dir=../../server/hudson/data/compiler
diff --git a/cmdline/compiler/nbproject/project.xml b/cmdline/compiler/nbproject/project.xml
deleted file mode 100644
index 9078a42..0000000
--- a/cmdline/compiler/nbproject/project.xml
+++ /dev/null
@@ -1,315 +0,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
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<project xmlns="http://www.netbeans.org/ns/project/1">
- <type>org.netbeans.modules.apisupport.project</type>
- <configuration>
- <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
- <code-name-base>org.netbeans.modules.jackpot30.compiler</code-name-base>
- <suite-component/>
- <module-dependencies>
- <dependency>
- <code-name-base>org.netbeans.api.annotations.common</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <release-version>1</release-version>
- <specification-version>1.4</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.api.java.classpath</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <release-version>1</release-version>
- <specification-version>1.20</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.lib.nbjavac</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <implementation-version/>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.libs.javacapi</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <specification-version>0.9.0.1</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.libs.javacimpl</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <release-version>1</release-version>
- <implementation-version/>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.modules.diff</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <release-version>1</release-version>
- <implementation-version/>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <release-version>1</release-version>
- <specification-version>1.12</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.modules.jackpot30.indexing</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <implementation-version/>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.modules.jackpot30.remoting.api</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <specification-version>1.0</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.modules.java.hints</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <release-version>1</release-version>
- <implementation-version/>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.modules.java.hints.declarative</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <release-version>1</release-version>
- <implementation-version/>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.modules.java.lexer</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <release-version>1</release-version>
- <specification-version>1.6</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.modules.java.preprocessorbridge</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <implementation-version/>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.modules.java.source</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <implementation-version/>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.modules.java.source.base</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <implementation-version/>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.modules.lexer</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <release-version>2</release-version>
- <specification-version>1.31.0.1</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <release-version>1</release-version>
- <implementation-version/>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.modules.parsing.indexing</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <implementation-version/>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.modules.refactoring.api</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <specification-version>1.22</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <release-version>0-1</release-version>
- <specification-version>1.8.1.7.2</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.spi.java.hints</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <implementation-version/>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.openide.filesystems</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <specification-version>7.25.0.1.1</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.openide.text</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <specification-version>6.24</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.openide.util</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <specification-version>8.1</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.openide.util.lookup</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <specification-version>8.1</specification-version>
- </run-dependency>
- </dependency>
- </module-dependencies>
- <test-dependencies>
- <test-type>
- <name>unit</name>
- <test-dependency>
- <code-name-base>org.netbeans.bootstrap</code-name-base>
- <compile-dependency/>
- </test-dependency>
- <test-dependency>
- <code-name-base>org.netbeans.core.startup</code-name-base>
- <compile-dependency/>
- </test-dependency>
- <test-dependency>
- <code-name-base>org.netbeans.insane</code-name-base>
- <compile-dependency/>
- </test-dependency>
- <test-dependency>
- <code-name-base>org.netbeans.libs.junit4</code-name-base>
- <compile-dependency/>
- </test-dependency>
- <test-dependency>
- <code-name-base>org.netbeans.modules.classfile</code-name-base>
- <compile-dependency/>
- </test-dependency>
- <test-dependency>
- <code-name-base>org.netbeans.modules.editor.document</code-name-base>
- <compile-dependency/>
- </test-dependency>
- <test-dependency>
- <code-name-base>org.netbeans.modules.editor.mimelookup.impl</code-name-base>
- <compile-dependency/>
- </test-dependency>
- <test-dependency>
- <code-name-base>org.netbeans.modules.jackpot30.cmdline.lib</code-name-base>
- <recursive/>
- <compile-dependency/>
- <test/>
- </test-dependency>
- <test-dependency>
- <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
- <recursive/>
- <compile-dependency/>
- </test-dependency>
- <test-dependency>
- <code-name-base>org.netbeans.modules.java.hints</code-name-base>
- <compile-dependency/>
- </test-dependency>
- <test-dependency>
- <code-name-base>org.netbeans.modules.masterfs</code-name-base>
- <compile-dependency/>
- </test-dependency>
- <test-dependency>
- <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
- <compile-dependency/>
- </test-dependency>
- <test-dependency>
- <code-name-base>org.netbeans.modules.parsing.nb</code-name-base>
- <compile-dependency/>
- </test-dependency>
- <test-dependency>
- <code-name-base>org.netbeans.modules.projectapi.nb</code-name-base>
- <compile-dependency/>
- </test-dependency>
- <test-dependency>
- <code-name-base>org.netbeans.modules.projectui</code-name-base>
- <compile-dependency/>
- </test-dependency>
- </test-type>
- </test-dependencies>
- <public-packages/>
- <extra-compilation-unit>
- <package-root>antsrc</package-root>
- <classpath>${module.classpath}:${ant.jar}:${tools.jar}:${cluster}/modules/${code.name.base.dashes}.jar</classpath>
- <built-to>build/antclasses</built-to>
- <built-to>${cluster}/ant/extra/${code.name.base.dashes}.jar</built-to>
- </extra-compilation-unit>
- </data>
- </configuration>
-</project>
diff --git a/cmdline/compiler/nbproject/suite.properties b/cmdline/compiler/nbproject/suite.properties
deleted file mode 100644
index 5f42472..0000000
--- a/cmdline/compiler/nbproject/suite.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-# 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.
-
-suite.dir=${basedir}/..
diff --git a/cmdline/compiler/scripts/README b/cmdline/compiler/scripts/README
deleted file mode 100644
index 71930f7..0000000
--- a/cmdline/compiler/scripts/README
+++ /dev/null
@@ -1,32 +0,0 @@
-Standalone Jackpot 3.0
-----------------------
-
-The standalone Jackpot 3.0 compiler is a javac replacement that not only compiles
-the given source files, but also runs any specified Jackpot rules. When the Jackpot
-rule has a fix, the fix is applied and a patch file is created in the source output
-directory in META-INF/upgrade/upgrade.diff.
-
-There are three sources of Jackpot rules to run:
-1) .hint files found on classpath and source path. By default, any .hint file found on
-class and source path in META-INF/upgrade is interpreted as a Jackpot rule and performed.
-Use "-Ajackpot30_enable_cp_hints=true/false" to enable/disable running the rules and
-"-Ajackpot30_apply_cp_hints=true/false" to enable/disable application of the primary
-fixes of the rules.
-2) custom rule files passed from command line using "-Ajackpot30_extra_hints=<files".
-3) NetBeans hints (disabled by default)
-
-Running jackpotc from command line
-----------------------------------
-
-jackpotc script can be used as a replacement of javac. Pass the above arguments to
-control which rules should or should not be run.
-
-Limitations:
--"-sourcepath" argument must be provided
--"-J" arguments are not supported
-
-Running jackpotc from ant
--------------------------
-
-Start ant using "ant -lib <directory-containing-jackpotc> -Dbuild.compiler=org.netbeans.modules.jackpot30.compiler.ant.JackpotCompiler".
-The "-A" parameters need to be passed using -D instead of -A.
diff --git a/cmdline/compiler/scripts/jackpotc b/cmdline/compiler/scripts/jackpotc
deleted file mode 100755
index 88ab1d2..0000000
--- a/cmdline/compiler/scripts/jackpotc
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/bash
-
-# 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.
-
-
-java -Xbootclasspath/p:`dirname $0`/jackpotc.jar com.sun.tools.javac.Main -Xjcov "$@"
diff --git a/cmdline/compiler/src/org/netbeans/api/java/source/CompilationInfoHack.java b/cmdline/compiler/src/org/netbeans/api/java/source/CompilationInfoHack.java
deleted file mode 100644
index 1eba1ca..0000000
--- a/cmdline/compiler/src/org/netbeans/api/java/source/CompilationInfoHack.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/**
- * 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.netbeans.api.java.source;
-
-import com.sun.source.tree.CompilationUnitTree;
-import com.sun.source.tree.Tree;
-import com.sun.source.util.JavacTask;
-import com.sun.source.util.TreePath;
-import com.sun.source.util.Trees;
-import com.sun.tools.javac.api.JavacTaskImpl;
-import com.sun.tools.javac.api.JavacTrees;
-import com.sun.tools.javac.code.Source;
-import com.sun.tools.javac.model.JavacElements;
-import com.sun.tools.javac.model.JavacTypes;
-import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
-import com.sun.tools.javac.util.Context;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.util.Elements;
-import javax.lang.model.util.Types;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.Document;
-import javax.tools.Diagnostic;
-import org.netbeans.api.java.lexer.JavaTokenId;
-import org.netbeans.api.java.source.JavaSource.Phase;
-import org.netbeans.api.lexer.TokenHierarchy;
-import org.netbeans.modules.java.source.parsing.CompilationInfoImpl;
-import org.netbeans.modules.java.source.parsing.HackAccessor;
-import org.netbeans.modules.java.source.save.ElementOverlay;
-import org.netbeans.modules.parsing.api.Snapshot;
-import org.netbeans.modules.parsing.api.SnapshotHack;
-import org.openide.filesystems.FileObject;
-import org.openide.filesystems.URLMapper;
-import org.openide.util.Exceptions;
-
-/**
- *
- * @author lahvac
- */
-public class CompilationInfoHack extends WorkingCopy {
-
- private final Context context;
- private final ClasspathInfo cpInfo;
- private FileObject file;
- private String text;
- private TokenHierarchy<?> th;
- private final CompilationUnitTree cut;
- private PositionConverter conv;
-
- public CompilationInfoHack(Context context, ClasspathInfo cpInfo, JCCompilationUnit cut) {
- super(HackAccessor.createCII(cpInfo), ElementOverlay.getOrCreateOverlay());
- this.context = context;
- this.cpInfo = cpInfo;
- try {
- this.file = URLMapper.findFileObject(cut.sourcefile.toUri().toURL());
- this.text = cut.sourcefile.getCharContent(false).toString();
- this.th = TokenHierarchy.create(text, JavaTokenId.language());
-
- conv = new PositionConverter(SnapshotHack.create(text));
- } catch (IllegalArgumentException ex) {
- Exceptions.printStackTrace(ex);
- } catch (IOException ex) {
- Exceptions.printStackTrace(ex);
- }
- this.cut = cut;
-
- try {
- Field javacTask = CompilationInfoImpl.class.getDeclaredField("javacTask");
-
- javacTask.setAccessible(true);
-
- JavacTask prevTask = context.get(JavacTask.class);
-
- try {
- context.put(JavacTask.class, (JavacTask) null);
- javacTask.set(this.impl, new JavacTaskImpl(context) {});
- } finally {
- context.put(JavacTask.class, (JavacTask) null);
- context.put(JavacTask.class, prevTask);
- }
-
- Method init = WorkingCopy.class.getDeclaredMethod("init");
-
- init.setAccessible(true);
- init.invoke(this);
- } catch (InvocationTargetException ex) {
- Exceptions.printStackTrace(ex);
- } catch (NoSuchMethodException ex) {
- Exceptions.printStackTrace(ex);
- } catch (IllegalArgumentException ex) {
- Exceptions.printStackTrace(ex);
- } catch (IllegalAccessException ex) {
- Exceptions.printStackTrace(ex);
- } catch (NoSuchFieldException ex) {
- Exceptions.printStackTrace(ex);
- } catch (SecurityException ex) {
- Exceptions.printStackTrace(ex);
- }
- }
-
- @Override
- public TreePath getChangedTree() {
- return null;
- }
-
- @Override
- public ClasspathInfo getClasspathInfo() {
- return cpInfo;
- }
-
- @Override
- public CompilationUnitTree getCompilationUnit() {
- return cut;
- }
-
- @Override
- public List<Diagnostic> getDiagnostics() {
- //could be enabled if necessary:
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Document getDocument() throws IOException {
- return null;
- }
-
- @Override
- public synchronized ElementUtilities getElementUtilities() {
- return super.getElementUtilities();
- }
-
- @Override
- public Elements getElements() {
- return JavacElements.instance(context);
- }
-
- @Override
- public FileObject getFileObject() {
- return file;
- }
-
- public CompilationInfoImpl getImpl() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public JavaSource getJavaSource() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Phase getPhase() {
- return Phase.RESOLVED;
- }
-
- @Override
- public PositionConverter getPositionConverter() {
- return conv;
- }
-
- @Override
- public Snapshot getSnapshot() {
- return org.netbeans.modules.parsing.api.Source.create(file).createSnapshot();
- }
-
- @Override
- public SourceVersion getSourceVersion() {
- return Source.toSourceVersion(Source.instance(context));
- }
-
- @Override
- public String getText() {
- return text;
- }
-
- @Override
- public TokenHierarchy<?> getTokenHierarchy() {
- return th;
- }
-
- @Override
- public List<? extends TypeElement> getTopLevelElements() throws IllegalStateException {
- final List<TypeElement> result = new ArrayList<TypeElement>();
- CompilationUnitTree cu = getCompilationUnit();
- if (cu == null) {
- return null;
- }
- final Trees trees = getTrees();
- assert trees != null;
- List<? extends Tree> typeDecls = cu.getTypeDecls();
- TreePath cuPath = new TreePath(cu);
- for( Tree t : typeDecls ) {
- TreePath p = new TreePath(cuPath,t);
- Element e = trees.getElement(p);
- if ( e != null && ( e.getKind().isClass() || e.getKind().isInterface() ) ) {
- result.add((TypeElement)e);
- }
- }
- return Collections.unmodifiableList(result);
- }
-
- @Override
- public synchronized TreeUtilities getTreeUtilities() {
- return super.getTreeUtilities();
- }
-
- @Override
- public Trees getTrees() {
- return JavacTrees.instance(context);
- }
-
- @Override
- public synchronized TypeUtilities getTypeUtilities() {
- return super.getTypeUtilities();
- }
-
- @Override
- public Types getTypes() {
- return JavacTypes.instance(context);
- }
-
- public Context getContext() {
- return context;
- }
-
- public ModificationResult computeResult() throws IOException, BadLocationException {
- ModificationResult mr = new ModificationResult();
-
- mr.diffs.put(getFileObject(), getChanges(new HashMap<Object, int[]>()));
-
- return mr;
- }
-}
diff --git a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/AbstractHintsAnnotationProcessing.java b/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/AbstractHintsAnnotationProcessing.java
deleted file mode 100644
index 8ac2a98..0000000
--- a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/AbstractHintsAnnotationProcessing.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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.netbeans.modules.jackpot30.compiler;
-
-import java.util.Set;
-import javax.annotation.processing.ProcessingEnvironment;
-import org.netbeans.api.java.source.CompilationInfoHack;
-
-/**
- *
- * @author lahvac
- */
-public abstract class AbstractHintsAnnotationProcessing {
-
- protected abstract boolean initialize(ProcessingEnvironment processingEnv);
-
- protected abstract void doProcess(CompilationInfoHack info, ProcessingEnvironment processingEnv, Reporter reporter);
-
- protected abstract void finish();
-
- protected abstract Set<String> getSupportedOptions();
-
- protected static interface Reporter {
- public void warning(int offset, String message);
- }
-
-}
diff --git a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/Bundle.properties b/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/Bundle.properties
deleted file mode 100644
index cae8c29..0000000
--- a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/Bundle.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# 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.
-
-#
-OpenIDE-Module-Name=Jackpot 3.0 Standalone Compiler
diff --git a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/CompilerResourcesImpl.java b/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/CompilerResourcesImpl.java
deleted file mode 100644
index 7974915..0000000
--- a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/CompilerResourcesImpl.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * 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.netbeans.modules.jackpot30.compiler;
-
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- *
- * @author lahvac
- */
-public class CompilerResourcesImpl extends ResourceBundle {
-
- private final ResourceBundle delegate;
-
- public CompilerResourcesImpl() {
- String baseName = getClass().getName();
-
- delegate = CompilerResourcesImpl.getBundle(baseName, Control.getControl(Arrays.asList("java.properties")));
- }
-
- @Override
- protected Object handleGetObject(String key) {
- try {
- return delegate.getObject(key);
- } catch (MissingResourceException ex) {
- return null;
- }
- }
-
- @Override
- public Enumeration<String> getKeys() {
- return delegate.getKeys();
- }
-
-}
diff --git a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessing.java b/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessing.java
deleted file mode 100644
index a867c71..0000000
--- a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessing.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/**
- * 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.netbeans.modules.jackpot30.compiler;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.regex.Pattern;
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.swing.text.BadLocationException;
-import javax.tools.Diagnostic.Kind;
-import javax.tools.FileObject;
-import javax.tools.StandardLocation;
-import org.netbeans.api.java.source.ClasspathInfo.PathKind;
-import org.netbeans.api.java.source.CompilationInfoHack;
-import org.netbeans.api.java.source.ModificationResult;
-import org.netbeans.modules.jackpot30.indexing.batch.BatchUtilities;
-import org.netbeans.modules.java.hints.declarative.DeclarativeHintRegistry;
-import org.netbeans.modules.java.hints.jackpot.spi.HintsRunner;
-import org.netbeans.modules.java.hints.providers.spi.HintDescription;
-import org.netbeans.modules.java.hints.providers.spi.HintMetadata;
-import org.netbeans.modules.java.hints.spiimpl.JavaFixImpl;
-import org.netbeans.modules.java.hints.spiimpl.RulesManager;
-import org.netbeans.modules.java.hints.spiimpl.Utilities;
-import org.netbeans.modules.java.hints.spiimpl.options.HintsSettings;
-import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
-import org.netbeans.modules.refactoring.spi.RefactoringElementImplementation;
-import org.netbeans.spi.editor.hints.ErrorDescription;
-import org.netbeans.spi.editor.hints.Fix;
-import org.netbeans.spi.editor.hints.Severity;
-import org.netbeans.spi.java.hints.Hint;
-import org.netbeans.spi.java.hints.HintSeverity;
-import org.openide.filesystems.FileUtil;
-import org.openide.util.Exceptions;
-import org.openide.util.lookup.ServiceProvider;
-
-/**
- *
- * @author lahvac
- */
-@ServiceProvider(service=AbstractHintsAnnotationProcessing.class)
-public class HintsAnnotationProcessing extends AbstractHintsAnnotationProcessing {
-
- static final String CLASSPATH_HINTS_ENABLE = "jackpot30_enable_cp_hints";
- static final String CLASSPATH_HINTS_FIXES_ENABLE = "jackpot30_apply_cp_hints";
- static final String HARDCODED_HINTS_ENABLE = "jackpot30_enabled_hc_hints";
- static final String HARDCODED_HINTS_FIXES_ENABLE = "jackpot30_apply_hc_hints";
- static final String EXTRA_HINTS = "jackpot30_extra_hints";
-
- public static final Set<String> OPTIONS = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
- CLASSPATH_HINTS_ENABLE, CLASSPATH_HINTS_FIXES_ENABLE,
- HARDCODED_HINTS_ENABLE,
- HARDCODED_HINTS_FIXES_ENABLE,
- EXTRA_HINTS
- )));
-
- private Writer diff;
-
- @Override
- protected boolean initialize(ProcessingEnvironment processingEnv) {
- try {
- File tmp = File.createTempFile("jackpot30", null);
-
- tmp.delete();
- tmp.mkdirs();
- tmp.deleteOnExit();
-
- tmp = FileUtil.normalizeFile(tmp);
- FileUtil.refreshFor(tmp.getParentFile());
-
- org.openide.filesystems.FileObject tmpFO = FileUtil.toFileObject(tmp);
-
- if (tmpFO == null) {
- return false;
- }
-
- CacheFolder.setCacheFolder(tmpFO);
- } catch (IOException ex) {
- ex.printStackTrace();
- }
-
- return true;
- }
-
- @Override
- protected void doProcess(CompilationInfoHack info, ProcessingEnvironment processingEnv, Reporter reporter) {
- Set<HintDescription> hardCodedHints = new LinkedHashSet<HintDescription>();
-
- for (Collection<? extends HintDescription> v : RulesManager.getInstance().readHints(null, null, null).values()) {
- hardCodedHints.addAll(v);
- }
-
- ContainsChecker<String> enabledHints = getEnabledHardcodedHints(processingEnv);
-
- for (Iterator<HintDescription> it = hardCodedHints.iterator(); it.hasNext(); ) {
- HintMetadata current = it.next().getMetadata();
-
- if ( (current.kind == Hint.Kind.INSPECTION)
- && enabledHints.contains(current.id)) {
- continue;
- }
-
- it.remove();
- }
-
- ContainsChecker<String> enabledApplyHints = getApplyHardcodedFixes(processingEnv);
-
- List<HintDescription> hintDescriptions = new LinkedList<HintDescription>(hardCodedHints);
-
- if (isEnabled(processingEnv, CLASSPATH_HINTS_ENABLE)) {
- hintDescriptions.addAll(new LinkedList<HintDescription>(Utilities.listClassPathHints(Collections.singleton(info.getClasspathInfo().getClassPath(PathKind.SOURCE)), Collections.singleton(info.getClasspathInfo().getClassPath(PathKind.COMPILE)))));
- }
-
- boolean applyCPHints = isEnabled(processingEnv, CLASSPATH_HINTS_FIXES_ENABLE);
-
- Collection<? extends HintDescription> extraHints = getExtraHints(processingEnv);
-
- hintDescriptions.addAll(extraHints);
-
- Map<HintDescription, List<ErrorDescription>> hints = HintsRunner.computeErrors(info, hintDescriptions, new AtomicBoolean());
-
- try {
- boolean fixPerformed = false;
-
- for (Entry<HintDescription, List<ErrorDescription>> e : hints.entrySet()) {
- boolean applyFix = hardCodedHints.contains(e.getKey()) ? enabledApplyHints.contains(e.getKey().getMetadata().id) : extraHints.contains(e.getKey()) ? true : applyCPHints;
-
- for (ErrorDescription ed : e.getValue()) {
- reporter.warning(ed.getRange().getBegin().getOffset(), ed.getDescription());
-
- if (!applyFix) continue;
-
- Fix f = ed.getFixes().getFixes().get(0);
-
- if (!(f instanceof JavaFixImpl)) {
- reporter.warning(ed.getRange().getBegin().getOffset(), "Cannot apply primary fix (not a JavaFix)");
- continue;
- }
-
- JavaFixImpl jfi = (JavaFixImpl) f;
-
- try {
- JavaFixImpl.Accessor.INSTANCE.process(jfi.jf, info, false, null, new ArrayList<RefactoringElementImplementation>());
- } catch (Exception ex) {
- Exceptions.printStackTrace(ex);
- }
-
- fixPerformed = true;
- }
- }
-
- if (fixPerformed) {
- ModificationResult mr = info.computeResult();
-
- if (diff == null) {
- FileObject upgradeDiffFO = processingEnv.getFiler().createResource(StandardLocation.SOURCE_OUTPUT, "", "META-INF/upgrade/upgrade.diff");
-
- diff = new OutputStreamWriter(upgradeDiffFO.openOutputStream());
- }
-
- BatchUtilities.exportDiff(mr, null, diff);
- }
- } catch (IOException ex) {
- Exceptions.printStackTrace(ex);
- } catch (BadLocationException ex) {
- Exceptions.printStackTrace(ex);
- }
- }
-
- @Override
- protected void finish() {
- if (diff != null) {
- try {
- diff.close();
- } catch (IOException ex) {
- Exceptions.printStackTrace(ex);
- }
- }
-
- diff = null;
- }
-
- @Override
- public Set<String> getSupportedOptions() {
- return OPTIONS;
- }
-
- private boolean isEnabled(ProcessingEnvironment processingEnv, String key) {
- if (processingEnv.getOptions().containsKey(key)) {
- return Boolean.valueOf(processingEnv.getOptions().get(key));
- }
-
- return true;
- }
-
- private ContainsChecker<String> getApplyHardcodedFixes(ProcessingEnvironment processingEnv) {
- if (processingEnv.getOptions().containsKey(HARDCODED_HINTS_FIXES_ENABLE)) {
- String toSplit = processingEnv.getOptions().get(HARDCODED_HINTS_FIXES_ENABLE);
-
- if (toSplit == null) {
- return new HardcodedContainsChecker<String>(false);
- }
-
- return new SetBasedContainsChecker<String>(new HashSet<String>(Arrays.asList(toSplit.split(":"))));
- }
-
- return new HardcodedContainsChecker<String>(true);
- }
-
- private ContainsChecker<String> getEnabledHardcodedHints(ProcessingEnvironment processingEnv) {
- if (processingEnv.getOptions().containsKey(HARDCODED_HINTS_ENABLE)) {
- String toSplit = processingEnv.getOptions().get(HARDCODED_HINTS_ENABLE);
-
- if (toSplit == null) {
- return new HardcodedContainsChecker<String>(false);
- }
- if ("all".equals(toSplit)) {
- return new HardcodedContainsChecker<String>(true);
- }
- if ("defaults".equals(toSplit)) {
- return new SettingsBasedChecker();
- }
-
- return new SetBasedContainsChecker<String>(new HashSet<String>(Arrays.asList(toSplit.split(":"))));
- }
-
- return new HardcodedContainsChecker<String>(false);
- }
-
- private interface ContainsChecker<T> {
- public boolean contains(T t);
- }
-
- private static final class SetBasedContainsChecker<T> implements ContainsChecker<T> {
- private final Set<T> set;
- public SetBasedContainsChecker(Set<T> set) {
- this.set = set;
- }
- public boolean contains(T t) {
- return set.contains(t);
- }
- }
-
- private static final class HardcodedContainsChecker<T> implements ContainsChecker<T> {
- private final boolean result;
- public HardcodedContainsChecker(boolean result) {
- this.result = result;
- }
- public boolean contains(T t) {
- return result;
- }
- }
-
- private static final class SettingsBasedChecker implements ContainsChecker<String> {
- private static final Set<String> enabled = new HashSet<String>();
- public SettingsBasedChecker() {
- HintsSettings hintsSettings = HintsSettings.getGlobalSettings();
- for (HintMetadata hm : RulesManager.getInstance().readHints(null, null, null).keySet()) {
- if ( hintsSettings.isEnabled(hm)
- && hintsSettings.getSeverity(hm) != Severity.HINT) {
- enabled.add(hm.id);
- }
- }
- }
- public boolean contains(String t) {
- return enabled.contains(t);
- }
- }
-
- private Collection<? extends HintDescription> getExtraHints(ProcessingEnvironment processingEnv) {
- if (processingEnv.getOptions().containsKey(EXTRA_HINTS)) {
- String toSplit = processingEnv.getOptions().get(EXTRA_HINTS);
-
- if (toSplit == null || toSplit.length() == 0) {
- return Collections.emptyList();
- }
-
- List<HintDescription> result = new LinkedList<HintDescription>();
-
- for (String part : toSplit.split(Pattern.quote(System.getProperty("path.separator")))) {
- File resolved = FileUtil.normalizeFile(new File(part).getAbsoluteFile());
-
- if (!resolved.isFile()) {
- processingEnv.getMessager().printMessage(Kind.WARNING, "Cannot resolve hint file: " + part);
- continue;
- }
-
- for (Collection<? extends HintDescription> v : DeclarativeHintRegistry.parseHintFile(FileUtil.toFileObject(resolved)).values()) {
- result.addAll(v);
- }
- }
-
- return result;
- }
-
- return Collections.emptyList();
- }
-
-}
diff --git a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessingImpl.java b/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessingImpl.java
deleted file mode 100644
index ef33258..0000000
--- a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessingImpl.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/**
- * 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.netbeans.modules.jackpot30.compiler;
-
-import com.sun.source.util.JavacTask;
-import com.sun.source.util.TaskEvent;
-import com.sun.source.util.TaskListener;
-import com.sun.source.util.TreePath;
-import com.sun.source.util.Trees;
-import com.sun.tools.javac.api.JavacTrees;
-import com.sun.tools.javac.api.MultiTaskListener;
-import com.sun.tools.javac.comp.Resolve;
-import com.sun.tools.javac.jvm.Gen;
-import com.sun.tools.javac.parser.ParserFactory;
-import com.sun.tools.javac.processing.JavacProcessingEnvironment;
-import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.Context.Key;
-import com.sun.tools.javac.util.Log;
-import com.sun.tools.javac.util.Options;
-import java.io.File;
-import java.lang.reflect.Field;
-import java.net.URL;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.annotation.processing.Processor;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.util.ElementFilter;
-import javax.tools.Diagnostic.Kind;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.StandardLocation;
-import org.netbeans.api.java.classpath.ClassPath;
-import org.netbeans.api.java.source.ClasspathInfo;
-import org.netbeans.api.java.source.CompilationInfoHack;
-import org.netbeans.lib.nbjavac.services.NBParserFactory;
-import org.netbeans.lib.nbjavac.services.NBResolve;
-import org.netbeans.modules.jackpot30.compiler.AbstractHintsAnnotationProcessing.Reporter;
-import org.netbeans.spi.java.classpath.support.ClassPathSupport;
-import org.openide.filesystems.FileUtil;
-import org.openide.util.Lookup;
-import org.openide.util.lookup.ServiceProvider;
-
-/**
- *
- * @author lahvac
- */
-@SupportedAnnotationTypes("*")
-@ServiceProvider(service=Processor.class)
-public final class HintsAnnotationProcessingImpl extends AbstractProcessor {
-
- private final Collection<String> seenTypes = new LinkedList<String>();
- private final Collection<AbstractHintsAnnotationProcessing> processors = new LinkedList<AbstractHintsAnnotationProcessing>();
-
- @Override
- public synchronized void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
-
- for (AbstractHintsAnnotationProcessing p : Lookup.getDefault().lookupAll(AbstractHintsAnnotationProcessing.class)) {
- if (p.initialize(processingEnv)) {
- processors.add(p);
- }
- }
-
- if (processors.isEmpty()) {
- return;
- }
-
- if (!(processingEnv instanceof JavacProcessingEnvironment)) {
- throw new UnsupportedOperationException("Not a JavacProcessingEnvironment");
- }
-
- Context c = ((JavacProcessingEnvironment) processingEnv).getContext();
-
- MultiTaskListener.instance(c).add(new TaskListenerImpl());
- }
-
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- for (TypeElement type : ElementFilter.typesIn(roundEnv.getRootElements())) {
- seenTypes.add(type.getQualifiedName().toString());
- }
-
- if (roundEnv.processingOver()) {
- try {
- //XXX: workarounding a bug in CRTable (see HintsAnnotationProcessingTest.testCRTable):
- Context c = ((JavacProcessingEnvironment) processingEnv).getContext();
- Options.instance(c).remove("-Xjcov");
- Field f = Gen.class.getDeclaredField("genCrt");
- f.setAccessible(true);
- f.set(Gen.instance(c), false);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- return false;
- }
-
- private void doProcessing(TypeElement type) {
- if (!seenTypes.remove(type.getQualifiedName().toString())) return;
-
- Context c = ((JavacProcessingEnvironment) processingEnv).getContext();
- StandardJavaFileManager s = (StandardJavaFileManager) c.get(JavaFileManager.class);
- ClassPath boot = computeClassPath(s, StandardLocation.PLATFORM_CLASS_PATH);
- ClassPath compile = computeClassPath(s, StandardLocation.CLASS_PATH);
- ClassPath source = computeClassPath(s, StandardLocation.SOURCE_PATH);
- Trees trees = JavacTrees.instance(c);
- final Log log = Log.instance(c);
- final Key<ParserFactory> key = ParserFactoryKeyAccessor.getContextKey();
- ParserFactory origParserFactory = c.get(key);
- c.put(key, (ParserFactory) null);
- NBParserFactory.preRegister(c);
- final Key<Resolve> resolveKey = ResolveKeyAccessor.getContextKey();
- Resolve origResolve = c.get(resolveKey);
- c.put(resolveKey, (Resolve) null);
- NBResolve.preRegister(c);
-
- try {
- TreePath elTree = trees.getPath(type);
- JCCompilationUnit cut = (JCCompilationUnit) elTree.getCompilationUnit();
-
- if (!cut.sourcefile.toUri().isAbsolute()) {
- processingEnv.getMessager().printMessage(Kind.NOTE, "Not an absolute URI: " + cut.sourcefile.toUri().toASCIIString(), type);
- return ; //XXX
- }
-
- CompilationInfoHack info = new CompilationInfoHack(c, ClasspathInfo.create(boot, compile, source), cut);
- JavaFileObject origSourceFile = log.currentSourceFile();
-
- try {
- log.useSource(cut.sourcefile);
-
- for (AbstractHintsAnnotationProcessing p : processors) {
- p.doProcess(info, processingEnv, new Reporter() {
- @Override public void warning(int offset, String message) {
- log.warning(offset, "proc.messager", message);
- }
- });
- }
- } finally {
- log.useSource(origSourceFile);
- }
- } finally {
- if (seenTypes.isEmpty()) {
- for (AbstractHintsAnnotationProcessing p : processors) {
- p.finish();
- }
- }
-
- c.put(key, (ParserFactory) null);
- c.put(key, origParserFactory);
- c.put(resolveKey, (Resolve) null);
- c.put(resolveKey, origResolve);
- }
- }
-
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
- @Override
- public Set<String> getSupportedOptions() {
- Set<String> options = new HashSet<String>();
-
- for (AbstractHintsAnnotationProcessing p : Lookup.getDefault().lookupAll(AbstractHintsAnnotationProcessing.class)) {
- options.addAll(p.getSupportedOptions());
- }
-
- return options;
- }
-
- private static ClassPath computeClassPath(StandardJavaFileManager m, StandardLocation kind) {
- List<URL> urls = new LinkedList<URL>();
- Iterable<? extends File> files = m.getLocation(kind);
-
- if (files != null) {
- for (File f : files) {
- urls.add(FileUtil.urlForArchiveOrDir(FileUtil.normalizeFile(f.getAbsoluteFile())));
- }
- }
-
- return ClassPathSupport.createClassPath(urls.toArray(new URL[0]));
- }
-
- private final class TaskListenerImpl implements TaskListener {
-
- public TaskListenerImpl() { }
-
- @Override
- public void started(TaskEvent te) {
- }
-
- @Override
- public void finished(TaskEvent te) {
- if (te.getKind() == TaskEvent.Kind.ANALYZE) {
- TypeElement toProcess = te.getTypeElement();
-
- assert toProcess != null;
- doProcessing(toProcess);
- }
- }
-
- }
-
- private static final class ParserFactoryKeyAccessor extends ParserFactory {
- ParserFactoryKeyAccessor() {
- super(null);
- }
- public static Key<ParserFactory> getContextKey() {
- return parserFactoryKey;
- }
- }
-
- private static final class ResolveKeyAccessor extends Resolve {
- ResolveKeyAccessor() {
- super(null);
- }
- public static Key<Resolve> getContextKey() {
- return resolveKey;
- }
- }
-
- static {
- try {
- ClassLoader l = HintsAnnotationProcessingImpl.class.getClassLoader();
-
- if (l == null) {
- l = ClassLoader.getSystemClassLoader();
- }
-
- l.setClassAssertionStatus("org.netbeans.api.java.source.CompilationInfo", false);
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
-}
diff --git a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/IndexingAnnotationProcessor.java b/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/IndexingAnnotationProcessor.java
deleted file mode 100644
index b5b9000..0000000
--- a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/IndexingAnnotationProcessor.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
- * 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.netbeans.modules.jackpot30.compiler;
-
-import com.sun.source.tree.MemberSelectTree;
-import com.sun.source.tree.Tree;
-import com.sun.source.tree.Tree.Kind;
-import com.sun.source.util.Trees;
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.tools.Diagnostic;
-import org.netbeans.api.java.source.ClasspathInfo.PathKind;
-import org.netbeans.api.java.source.CompilationInfoHack;
-import org.netbeans.modules.jackpot30.indexing.index.Indexer;
-import org.netbeans.modules.java.preprocessorbridge.spi.JavaIndexerPlugin;
-import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
-import org.netbeans.modules.parsing.impl.indexing.FileObjectIndexable;
-import org.netbeans.modules.parsing.impl.indexing.SPIAccessor;
-import org.openide.filesystems.FileObject;
-import org.openide.filesystems.FileUtil;
-import org.openide.util.Exceptions;
-import org.openide.util.Lookup;
-import org.openide.util.lookup.Lookups;
-import org.openide.util.lookup.ServiceProvider;
-
-/**
- *
- * @author lahvac
- */
-@ServiceProvider(service=AbstractHintsAnnotationProcessing.class)
-public class IndexingAnnotationProcessor extends AbstractHintsAnnotationProcessing {
-
- static final String CACHE_ROOT = "jackpot30_cache_root";
- static final String SOURCE_ROOT = "jackpot30_root";
- static final String INDEXED_FILES = "jackpot30_indexed_files";
-
- public static final Set<String> OPTIONS = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
- CACHE_ROOT,
- SOURCE_ROOT,
- INDEXED_FILES
- )));
-
- private boolean enabled;
- private Map<FileObject, JavaIndexerPlugin> writers;
-
- @Override
- protected boolean initialize(ProcessingEnvironment processingEnv) {
- String cacheRoot = processingEnv.getOptions().get(CACHE_ROOT);
-
- if (cacheRoot == null) return false;
-
- enabled = true;
-
- File cache = new File(cacheRoot);
- cache.mkdirs();
-
- cache = FileUtil.normalizeFile(cache);
- FileUtil.refreshFor(cache.getParentFile());
- CacheFolder.setCacheFolder(FileUtil.toFileObject(cache));
-
- writers = new HashMap<FileObject, JavaIndexerPlugin>();
-
- return true;
- }
-
- @Override
- protected void doProcess(CompilationInfoHack info, ProcessingEnvironment processingEnv, Reporter reporter) {
- try {
- if (!enabled) return;
-
- FileObject root;
-
- if (processingEnv.getOptions().containsKey(SOURCE_ROOT)) {
- File rootFile = new File(processingEnv.getOptions().get(SOURCE_ROOT));
-
- root = FileUtil.toFileObject(FileUtil.normalizeFile(rootFile));
-
- if (root == null) {
- processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Specified root (" + rootFile.getAbsolutePath() + ") does not exist");
- return;
- }
- } else {
- root = info.getClasspathInfo().getClassPath(PathKind.SOURCE).findOwnerRoot(info.getFileObject());
-
- if (root == null) {
- //try to find the source path from the package clause:
- root = info.getFileObject().getParent();
-
- if (info.getCompilationUnit().getPackageName() != null) {
- Tree t = info.getCompilationUnit().getPackageName();
-
- while (t.getKind() == Kind.MEMBER_SELECT) {
- root = root.getParent();
- t = ((MemberSelectTree) t).getExpression();
- }
-
- root = root.getParent();
- }
- }
- }
-
- JavaIndexerPlugin w = writers.get(root);
- URL sourceRoot = root.toURL();
-
- if (w == null) {
- writers.put(root, w = new Indexer.FactoryImpl().create(sourceRoot, Indexer.resolveCacheFolder(sourceRoot)));
- }
-
- Lookup services = Lookups.fixed(processingEnv.getElementUtils(), processingEnv.getTypeUtils(), Trees.instance(processingEnv));
-
- w.process(info.getCompilationUnit(), SPIAccessor.getInstance().create(new FileObjectIndexable(root, info.getFileObject())), services);
- } catch (IOException ex) {
- Exceptions.printStackTrace(ex);
- }
- }
-
- @Override
- protected void finish() {
- if (!enabled) return;
-
- for (JavaIndexerPlugin w : writers.values()) {
- w.finish();
- }
-
- writers = null;
- }
-
- @Override
- public Set<String> getSupportedOptions() {
- return OPTIONS;
- }
-
-}
diff --git a/cmdline/compiler/src/org/netbeans/modules/java/source/parsing/HackAccessor.java b/cmdline/compiler/src/org/netbeans/modules/java/source/parsing/HackAccessor.java
deleted file mode 100644
index fdb24a0..0000000
--- a/cmdline/compiler/src/org/netbeans/modules/java/source/parsing/HackAccessor.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 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.netbeans.modules.java.source.parsing;
-
-import org.netbeans.api.java.source.ClasspathInfo;
-
-/**
- *
- * @author lahvac
- */
-public class HackAccessor {
-
- public static CompilationInfoImpl createCII(ClasspathInfo cpInfo) {
- return new CompilationInfoImpl(cpInfo);
- }
-
-}
diff --git a/cmdline/compiler/src/org/netbeans/modules/parsing/api/SnapshotHack.java b/cmdline/compiler/src/org/netbeans/modules/parsing/api/SnapshotHack.java
deleted file mode 100644
index e21a3ad..0000000
--- a/cmdline/compiler/src/org/netbeans/modules/parsing/api/SnapshotHack.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 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.netbeans.modules.parsing.api;
-
-import org.netbeans.api.editor.mimelookup.MimePath;
-
-/**
- *
- * @author lahvac
- */
-public class SnapshotHack {
-
- public static Snapshot create(String text) {
- return Snapshot.create(text, new int[0], null, MimePath.get("text/x-java"), new int[][] {new int[] {0, 0}}, new int[][] {new int[] {0, 0}});
- }
-
-}
diff --git a/cmdline/compiler/test/scripted/config b/cmdline/compiler/test/scripted/config
deleted file mode 100755
index 86358e9..0000000
--- a/cmdline/compiler/test/scripted/config
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-#
-# 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.
-
-
-TOOL_NAME=jackpotc
-
-run_tool() {
- "${TOOL_NAME}"/"${TOOL_NAME}" -sourcepath src -d build "$@"
-}
diff --git a/cmdline/compiler/test/scripted/test-ant-1 b/cmdline/compiler/test/scripted/test-ant-1
deleted file mode 100755
index f205b57..0000000
--- a/cmdline/compiler/test/scripted/test-ant-1
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/bash
-#
-# 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.
-
-
-perform_test() {
- create_file src/test/Test.java <<EOF
-package test;
-public class Test {
- private void test() {
- Character.toLowerCase('a');
- }
-}
-EOF
-
- create_file src/META-INF/upgrade/test.hint <<EOF
-'test':
-java.lang.Character.toLowerCase(\$1) :: \$1 instanceof char => java.lang.Character.toUpperCase($1) ;;
-EOF
-
- create_file build.xml <<EOF
-<project name="test">
- <target name="compile">
- <javac srcdir="src"
- destdir="build"/>
- </target>
-</project>
-EOF
-
- ant -lib $WORK_DIR/jackpotc -Dbuild.compiler=org.netbeans.modules.jackpot30.compiler.ant.JackpotCompiler compile
-
- assert_file_content build/META-INF/upgrade/upgrade.diff <<EOF
---- $WORK_DIR/src/test/Test.java
-+++ $WORK_DIR/src/test/Test.java
-@@ -1,6 +1,6 @@
- package test;
- public class Test {
- private void test() {
-- Character.toLowerCase('a');
-+ Character.toUpperCase();
- }
- }
-EOF
-}
-
-. `dirname $0`/harness
diff --git a/cmdline/compiler/test/scripted/test-ant-with-params b/cmdline/compiler/test/scripted/test-ant-with-params
deleted file mode 100755
index bce000b..0000000
--- a/cmdline/compiler/test/scripted/test-ant-with-params
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/bash
-#
-# 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.
-
-
-perform_test() {
- create_file src/test/Test.java <<EOF
-package test;
-public class Test {
- private void test() {
- Character.toLowerCase('a');
- }
-}
-EOF
-
- create_file test.h <<EOF
-'test':
-java.lang.Character.toLowerCase(\$1) :: \$1 instanceof char => java.lang.Character.toUpperCase($1) ;;
-EOF
-
- create_file build.xml <<EOF
-<project name="test">
- <target name="compile">
- <javac srcdir="src"
- destdir="build"/>
- </target>
-</project>
-EOF
-
- ant -lib $WORK_DIR/jackpotc -Dbuild.compiler=org.netbeans.modules.jackpot30.compiler.ant.JackpotCompiler -Djackpot30_extra_hints=test.h compile
-
- assert_file_content build/META-INF/upgrade/upgrade.diff <<EOF
---- $WORK_DIR/src/test/Test.java
-+++ $WORK_DIR/src/test/Test.java
-@@ -1,6 +1,6 @@
- package test;
- public class Test {
- private void test() {
-- Character.toLowerCase('a');
-+ Character.toUpperCase();
- }
- }
-EOF
-}
-
-. `dirname $0`/harness
diff --git a/cmdline/compiler/test/scripted/test-cmdline-1 b/cmdline/compiler/test/scripted/test-cmdline-1
deleted file mode 100755
index 8f192dd..0000000
--- a/cmdline/compiler/test/scripted/test-cmdline-1
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/bash
-#
-# 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.
-
-
-perform_test() {
- create_file src/test/Test.java <<EOF
-package test;
-public class Test {
- private void test() {
- Character.toLowerCase('a');
- }
-}
-EOF
-
- create_file src/META-INF/upgrade/test.hint <<EOF
-'test':
-java.lang.Character.toLowerCase(\$1) :: \$1 instanceof char => java.lang.Character.toUpperCase($1) ;;
-EOF
-
- run_tool src/test/Test.java
-
- assert_file_content build/META-INF/upgrade/upgrade.diff <<EOF
---- $WORK_DIR/src/test/Test.java
-+++ $WORK_DIR/src/test/Test.java
-@@ -1,6 +1,6 @@
- package test;
- public class Test {
- private void test() {
-- Character.toLowerCase('a');
-+ Character.toUpperCase();
- }
- }
-EOF
-}
-
-. `dirname $0`/harness
diff --git a/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/CreateStandaloneCompilerJar.java b/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/CreateStandaloneCompilerJar.java
deleted file mode 100644
index 305811b..0000000
--- a/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/CreateStandaloneCompilerJar.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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.netbeans.modules.jackpot30.compiler;
-
-import org.netbeans.modules.jackpot30.cmdline.lib.CreateStandaloneJar;
-import javax.annotation.processing.Processor;
-import org.netbeans.modules.jackpot30.cmdline.lib.StandaloneTools.UtilitiesSPIImpl;
-import org.netbeans.modules.java.hints.spiimpl.Utilities;
-
-/**
- *
- * @author lahvac
- */
-public class CreateStandaloneCompilerJar extends CreateStandaloneJar {
-
- public CreateStandaloneCompilerJar(String name) {
- super(name, "jackpotc");
- }
-
- @Override
- protected Info computeInfo() {
- return new Info().addAdditionalRoots(UtilitiesSPIImpl.class.getName(), "com.sun.tools.javac.Main", HintsAnnotationProcessing.class.getName(), HintsAnnotationProcessingImpl.class.getName(), IndexingAnnotationProcessor.class.getName())
- .addMetaInfRegistrations(new MetaInfRegistration(Utilities.SPI.class, UtilitiesSPIImpl.class))
- .addMetaInfRegistrations(new MetaInfRegistration(Processor.class, HintsAnnotationProcessingImpl.class))
- .addMetaInfRegistrationToCopy(AbstractHintsAnnotationProcessing.class.getName());
- }
-
-}
diff --git a/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/CreateStandaloneCompilerJarTest.java b/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/CreateStandaloneCompilerJarTest.java
deleted file mode 100644
index 8895477..0000000
--- a/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/CreateStandaloneCompilerJarTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * 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.netbeans.modules.jackpot30.compiler;
-
-import java.io.File;
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-import org.netbeans.junit.NbTestCase;
-import org.netbeans.junit.NbTestSuite;
-
-/**
- *
- * @author lahvac
- */
-public class CreateStandaloneCompilerJarTest extends NbTestCase {
-
- public CreateStandaloneCompilerJarTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- NbTestSuite suite = new NbTestSuite();
-
- suite.addTestSuite(HintsAnnotationProcessingTest.class);
- suite.addTestSuite(IndexingAnnotationProcessorTest.class);
-
- return new TestSetup(suite) {
- private File compiler;
- private File hintsList;
- protected void setUp() throws Exception {
- compiler = File.createTempFile("jackpotc", ".jar");
- hintsList = File.createTempFile("hints", "list");
-
-// if (!compiler.canRead()) {
- new CreateStandaloneCompilerJar("").createCompiler(compiler, hintsList);
-// }
- System.setProperty("test.javacJar", compiler.getAbsolutePath());
- }
- protected void tearDown() {
- compiler.delete();
- hintsList.delete();
- compiler = null;
- hintsList = null;
- }
- };
- }
-
-}
diff --git a/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessingTest.java b/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessingTest.java
deleted file mode 100644
index 1c3cfce..0000000
--- a/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessingTest.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/**
- * 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.netbeans.modules.jackpot30.compiler;
-
-import java.io.File;
-import java.util.Collections;
-import javax.lang.model.type.TypeMirror;
-import org.netbeans.spi.editor.hints.ErrorDescription;
-import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
-import org.netbeans.spi.java.hints.Hint;
-import org.netbeans.spi.java.hints.HintContext;
-import org.netbeans.spi.java.hints.JavaFix;
-import org.netbeans.spi.java.hints.JavaFixUtilities;
-import org.netbeans.spi.java.hints.TriggerPattern;
-
-/**
- *
- * @author lahvac
- */
-public class HintsAnnotationProcessingTest extends HintsAnnotationProcessingTestBase {
-
- public HintsAnnotationProcessingTest(String name) {
- super(name);
- }
-
- public void testRunCompiler1() throws Exception {
- String golden =
- "--- {0}/src/test/Test.java\n" +
- "+++ {0}/src/test/Test.java\n" +
- "@@ -1 +1 @@\n" +
- "-package test; public class Test {private void test(java.io.File f) {f.isDirectory();}}\n" +
- "+package test; public class Test {private void test(java.io.File f) {!f.isFile();}}\n";
-
- doRunCompiler(golden, "src/test/Test.java",
- "package test; public class Test {private void test(java.io.File f) {f.isDirectory();}}\n",
- "src/META-INF/upgrade/joFile.hint",
- "'test':\n$1.isDirectory() :: $1 instanceof java.io.File => !$1.isFile();;",
- null,
- "-A" + HintsAnnotationProcessing.CLASSPATH_HINTS_ENABLE + "=true",
- "-A" + HintsAnnotationProcessing.CLASSPATH_HINTS_FIXES_ENABLE + "=true");
- }
-
- public void testRunCompiler2() throws Exception {
- String golden =
- "--- {0}/src/test/Test.java\n" +
- "+++ {0}/src/test/Test.java\n" +
- "@@ -1 +1 @@\n" +
- "-package test; public class Test {private void test() {Character.toLowerCase('a');}}\n" +
- "+package test; public class Test {private void test() {Character.toUpperCase('a');}}\n";
-
- doRunCompiler(golden, "src/test/Test.java",
- "package test; public class Test {private void test() {Character.toLowerCase('a');}}\n",
- "src/META-INF/upgrade/joFile.hint",
- "'test':\njava.lang.Character.toLowerCase($1) :: $1 instanceof char => java.lang.Character.toUpperCase($1) ;;",
- null,
- "-A" + HintsAnnotationProcessing.CLASSPATH_HINTS_ENABLE + "=true",
- "-A" + HintsAnnotationProcessing.CLASSPATH_HINTS_FIXES_ENABLE + "=true");
- }
-
- public void testRunCompilerMulti() throws Exception {
- String golden =
- "--- {0}/src/test/Test.java\n" +
- "+++ {0}/src/test/Test.java\n" +
- "@@ -1 +1 @@\n" +
- "-package test; public class Test {private void test() {Character.toLowerCase('a'); Dep.test();}}\n" +
- "+package test; public class Test {private void test() {Character.toUpperCase('a'); Dep.test();}}\n" +
- "--- {0}/src/test/Dep.java\n" +
- "+++ {0}/src/test/Dep.java\n" +
- "@@ -1 +1 @@\n" +
- "-package test; public class Dep {static void test() {Character.toLowerCase('a');}}\n" +
- "+package test; public class Dep {static void test() {Character.toUpperCase('a');}}\n";
-
- doRunCompiler(golden, "src/test/Test.java",
- "package test; public class Test {private void test() {Character.toLowerCase('a'); Dep.test();}}\n",
- "src/test/Dep.java",
- "package test; public class Dep {static void test() {Character.toLowerCase('a');}}\n",
- "src/META-INF/upgrade/joFile.hint",
- "'test':\njava.lang.Character.toLowerCase($1) :: $1 instanceof char => java.lang.Character.toUpperCase($1) ;;",
- null,
- "-A" + HintsAnnotationProcessing.CLASSPATH_HINTS_ENABLE + "=true",
- "-A" + HintsAnnotationProcessing.CLASSPATH_HINTS_FIXES_ENABLE + "=true");
- }
-
-// public void testNPEFromAttribute() throws Exception {//TODO: does not reproduce the problem - likely caused by null Env<AttrContext> for annonymous innerclasses
-// String golden = null;
-//
-// doRunCompiler(golden, "src/test/Test.java",
-// "package test; public class Test {private void test() {new Runnable() {public void run() {int i = 0; System.err.println(i);}};}}\n",
-// "src/META-INF/upgrade/joFile.hint",
-// "'test':\njava.lang.Character.toLowerCase($1) :: $1 instanceof char => java.lang.Character.toUpperCase($1) ;;");
-// }
-
- public void testTreesCleaning1() throws Exception {
- String golden = null;
-
- doRunCompiler(golden, "src/test/Test.java",
- "package test; public class Test {private void test() {java.util.Collections.<String>emptyList();}}\n",
- "src/META-INF/upgrade/joFile.hint",
- "'test':\njava.lang.Character.toLowerCase($1) :: $1 instanceof char => java.lang.Character.toUpperCase($1) ;;");
- }
-
- public void testTreesCleaning2() throws Exception {
- String golden = null;
-
- doRunCompiler(golden, "src/test/Test.java",
- "package test; public class Test {enum A { B; A() {}} }\n",
- "src/META-INF/upgrade/joFile.hint",
- "'test':\njava.lang.Character.toLowerCase($1) :: $1 instanceof char => java.lang.Character.toUpperCase($1) ;;");
- }
-
- public void testTreesCleaningEnumTooMuch() throws Exception {
- String golden = null;
-
- doRunCompiler(golden, "src/test/Test.java",
- "package test; public class Test {enum A { B; private final int i; A() {this(1);} A(int i) {this.i = i;}} }\n",
- "src/META-INF/upgrade/joFile.hint",
- "'test':\njava.lang.Character.toLowerCase($1) :: $1 instanceof char => java.lang.Character.toUpperCase($1) ;;");
- }
-
- public void testTreesCleaningEnum3() throws Exception {
- String golden = null;
-
- doRunCompiler(golden, "src/test/Test.java",
- "package test; public class Test {enum A { B(\"a\"){public String toString() {return null;} }; A(String str) {}} }\n",
- "src/META-INF/upgrade/joFile.hint",
- "'test':\njava.lang.Character.toLowerCase($1) :: $1 instanceof char => java.lang.Character.toUpperCase($1) ;;");
- }
-
- public void testCRTable() throws Exception {
- String golden = null;
-
- doRunCompiler(golden, "src/test/Test.java",
- "package test; public class Test {private void test() {Integer i = 0; i++;}}\n",
- "src/META-INF/upgrade/joFile.hint",
- "'test':\njava.lang.Character.toLowerCase($1) :: $1 instanceof char => java.lang.Character.toUpperCase($1) ;;");
- }
-
- public void testCodeAPI() throws Exception {
- String golden = "--- {0}/src/test/Test.java\n"+
- "+++ {0}/src/test/Test.java\n"+
- "@@ -1,2 +1,2 @@\n"+
- "-package test; public class Test {private void test() {Integer i = 0; if (i == null && null == i) System.err.println(i);\n"+
- "+package test; public class Test {private void test() {Integer i = 0; if (i == null) System.err.println(i);\n"+
- " }}\n";
- doRunCompiler(golden, "src/test/Test.java",
- "package test; public class Test {private void test() {Integer i = 0; if (i == null && null == i) System.err.println(i);\n}}\n",
- null,
- "-A" + HintsAnnotationProcessing.HARDCODED_HINTS_ENABLE + "=test-hint");
- }
-
- public void testExtraHints() throws Exception {
- String golden =
- "--- {0}/src/test/Test.java\n" +
- "+++ {0}/src/test/Test.java\n" +
- "@@ -1 +1 @@\n" +
- "-package test; public class Test {private void test() {Character.toLowerCase('a');}}\n" +
- "+package test; public class Test {private void test() {Character.toUpperCase('a');}}\n";
-
- doRunCompiler(golden, "src/test/Test.java",
- "package test; public class Test {private void test() {Character.toLowerCase('a');}}\n",
- "extra.hint",
- "'test':\njava.lang.Character.toLowerCase($1) :: $1 instanceof char => java.lang.Character.toUpperCase($1) ;;",
- null,
- "-A" + HintsAnnotationProcessing.EXTRA_HINTS + "=extra.hint");
-
- }
- public void testHintsOnClassPath() throws Exception {
- String golden =
- "--- {0}/src/test/Test.java\n" +
- "+++ {0}/src/test/Test.java\n" +
- "@@ -1 +1 @@\n" +
- "-package test; public class Test {private void test() {Character.toLowerCase('a');}}\n" +
- "+package test; public class Test {private void test() {Character.toUpperCase('a');}}\n";
-
- doRunCompiler(golden, "src/test/Test.java",
- "package test; public class Test {private void test() {Character.toLowerCase('a');}}\n",
- "comp/META-INF/upgrade/joFile.hint",
- "'test':\njava.lang.Character.toLowerCase($1) :: $1 instanceof char => java.lang.Character.toUpperCase($1) ;;",
- null,
- "-classpath",
- "comp",
- "-A" + HintsAnnotationProcessing.CLASSPATH_HINTS_ENABLE + "=true",
- "-A" + HintsAnnotationProcessing.CLASSPATH_HINTS_FIXES_ENABLE + "=true");
- }
-
- public void testNoDebugInfo() throws Exception {
- String golden =
- "--- {0}/src/test/Test.java\n" +
- "+++ {0}/src/test/Test.java\n" +
- "@@ -1 +1 @@\n" +
- "-package test; public class Test {private void test(java.io.File f) {f.isDirectory();}}\n" +
- "+package test; public class Test {private void test(java.io.File f) {!f.isFile();}}\n";
-
- doRunCompiler(golden, "src/test/Test.java",
- "package test; public class Test {private void test(java.io.File f) {f.isDirectory();}}\n",
- "src/META-INF/upgrade/joFile.hint",
- "'test':\n$1.isDirectory() :: $1 instanceof java.io.File => !$1.isFile();;",
- null,
- "-g:none",
- "-A" + HintsAnnotationProcessing.CLASSPATH_HINTS_ENABLE + "=true",
- "-A" + HintsAnnotationProcessing.CLASSPATH_HINTS_FIXES_ENABLE + "=true");
- }
-
- private void doRunCompiler(String goldenDiff, String... fileContentAndExtraOptions) throws Exception {
- runCompiler(fileContentAndExtraOptions);
-
- File diff = new File(sourceOutput, "META-INF/upgrade/upgrade.diff");
- String diffText = readFully(diff);
-
- goldenDiff = goldenDiff != null ? goldenDiff.replace("{0}", workDir.getAbsolutePath()) : null;
- assertEquals(goldenDiff, diffText);
- }
-
- @Hint(displayName="test", description="test", category="general", id="test-hint")
- @TriggerPattern("$1 == null && null == $1")
- public static ErrorDescription codeHint(HintContext ctx) {
- return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), "test", JavaFixUtilities.rewriteFix(ctx, "test", ctx.getPath(), "$1 == null"));
- }
-
-}
diff --git a/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessingTestBase.java b/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessingTestBase.java
deleted file mode 100644
index e31486b..0000000
--- a/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessingTestBase.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/**
- * 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.netbeans.modules.jackpot30.compiler;
-
-import com.sun.tools.javac.Main;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import org.netbeans.junit.NbTestCase;
-import org.openide.filesystems.FileUtil;
-import org.openide.util.Exceptions;
-
-/**
- *
- * @author lahvac
- */
-public class HintsAnnotationProcessingTestBase extends NbTestCase {
-
- public HintsAnnotationProcessingTestBase(String name) {
- super(name);
- }
-
- protected File workDir;
- protected File src;
- protected File sourceOutput;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- clearWorkDir();
-
- workDir = getWorkDir();
- sourceOutput = new File(workDir, "src-out");
- sourceOutput.mkdirs();
- src = new File(workDir, "src");
- src.mkdirs();
- }
-
- protected void runCompiler(String... fileContentAndExtraOptions) throws Exception {
- List<String> fileAndContent = new LinkedList<String>();
- List<String> extraOptions = new LinkedList<String>();
- List<String> fileContentAndExtraOptionsList = Arrays.asList(fileContentAndExtraOptions);
- int nullPos = fileContentAndExtraOptionsList.indexOf(null);
-
- if (nullPos == (-1)) {
- fileAndContent = fileContentAndExtraOptionsList;
- extraOptions = Collections.emptyList();
- } else {
- fileAndContent = fileContentAndExtraOptionsList.subList(0, nullPos);
- extraOptions = fileContentAndExtraOptionsList.subList(nullPos + 1, fileContentAndExtraOptionsList.size());
- }
-
- assertTrue(fileAndContent.size() % 2 == 0);
-
- List<String> options = new LinkedList<String>();
-
- for (int cntr = 0; cntr < fileAndContent.size(); cntr += 2) {
- String file = createAndFill(fileAndContent.get(cntr), fileAndContent.get(cntr + 1)).getAbsolutePath();
-
- if (file.endsWith(".java")) {
- options.add(file);
- }
- }
-
- if (!extraOptions.contains("-sourcepath")) {
- options.add("-sourcepath");
- options.add(src.getAbsolutePath());
- }
-
- options.add("-s");
- options.add(sourceOutput.getAbsolutePath());
- options.add("-source");
- options.add("1.7");
- options.add("-Xjcov");
-
- for (String eo : extraOptions) {
- options.add(eo.replace("${workdir}", workDir.getAbsolutePath()));
- }
-
- reallyRunCompiler(workDir, options.toArray(new String[0]));
- }
-
- protected void reallyRunCompiler(File workDir, String... params) throws Exception {
- String javacJar = System.getProperty("test.javacJar");
-
- if (javacJar == null) {
- String oldUserDir = System.getProperty("user.dir");
-
- System.setProperty("user.dir", workDir.getAbsolutePath());
-
- try {
- assertEquals(0, Main.compile(params));
- } finally {
- System.setProperty("user.dir", oldUserDir);
- }
- } else {
- File compiler = new File(javacJar);
-
- assertTrue(compiler.exists());
-
- List<String> ll = new LinkedList<String>();
-
- ll.add("java");
-// ll.add("-Xdebug");
-// ll.add("-Xrunjdwp:transport=dt_socket,suspend=y,server=y,address=8889");
- ll.add("-Xbootclasspath/p:" + compiler.getAbsolutePath());
- ll.add("com.sun.tools.javac.Main");
- ll.addAll(Arrays.asList(params));
-
- try {
- Process p = Runtime.getRuntime().exec(ll.toArray(new String[0]), null, workDir);
-
- new CopyStream(p.getInputStream(), System.out).start();
- new CopyStream(p.getErrorStream(), System.err).start();
-
- assertEquals(0, p.waitFor());
- } catch (Throwable t) {
- throw new IOException(t);
- }
- }
- }
-
- private static final class CopyStream extends Thread {
- private final InputStream ins;
- private final OutputStream out;
-
- public CopyStream(InputStream ins, OutputStream out) {
- this.ins = ins;
- this.out = out;
- }
-
- @Override
- public void run() {
- try {
- FileUtil.copy(ins, out);
- } catch (IOException ex) {
- Exceptions.printStackTrace(ex);
- } finally {
- try {
- ins.close();
- } catch (IOException ex) {
- Exceptions.printStackTrace(ex);
- }
- }
- }
-
- }
-
- private File createAndFill(String path, String content) throws IOException {
- File source = new File(workDir, path);
-
- source.getParentFile().mkdirs();
-
- Writer out = new OutputStreamWriter(new FileOutputStream(source));
-
- out.write(content);
-
- out.close();
-
- return source;
- }
-
- protected static String readFully(File file) throws IOException {
- if (!file.canRead()) return null;
- StringBuilder res = new StringBuilder();
- Reader in = new InputStreamReader(new FileInputStream(file));
- int read;
-
- while ((read = in.read()) != (-1)) {
- res.append((char) read);
- }
-
- return res.toString();
- }
-
-}
diff --git a/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/IndexingAnnotationProcessorTest.java b/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/IndexingAnnotationProcessorTest.java
deleted file mode 100644
index 018ffec..0000000
--- a/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/IndexingAnnotationProcessorTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * 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.netbeans.modules.jackpot30.compiler;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
-import org.netbeans.api.java.source.ClasspathInfo;
-import org.netbeans.api.java.source.CompilationController;
-import org.netbeans.api.java.source.JavaSource;
-import org.netbeans.api.java.source.Task;
-import org.netbeans.modules.jackpot30.indexing.index.IndexQuery;
-import org.netbeans.modules.java.hints.declarative.Hacks;
-import org.netbeans.modules.java.hints.spiimpl.pm.BulkSearch;
-import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
-import org.openide.filesystems.FileUtil;
-
-/**
- *
- * @author lahvac
- */
-public class IndexingAnnotationProcessorTest extends HintsAnnotationProcessingTestBase {
- public IndexingAnnotationProcessorTest(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- cache = new File(workDir, "cache");
- CacheFolder.setCacheFolder(FileUtil.createFolder(cache));
- }
-
- private File cache;
-
- public void testSimpleIndexing() throws Exception {
- runCompiler("src/test/Test1.java",
- "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }",
- "src/test/Test2.java",
- "package test; public class Test2 { private void test() { new javax.swing.ImageIcon((byte[]) null); } }",
- null,
- "-A" + IndexingAnnotationProcessor.CACHE_ROOT + "=" + cache.getAbsolutePath());
-
- String[] patterns = new String[]{
- "$1.isDirectory()",
- "new ImageIcon($1)"
- };
-
- verifyIndex(patterns, "test/Test1.java", "test/Test2.java");
- }
-
- public void testNoSourcePath() throws Exception {
- runCompiler("src/test/Test1.java",
- "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }",
- "src/test/Test2.java",
- "package test; public class Test2 { private void test() { new javax.swing.ImageIcon((byte[]) null); } }",
- null,
- "-A" + IndexingAnnotationProcessor.CACHE_ROOT + "=" + cache.getAbsolutePath(),
- "-sourcepath",
- "");
-
- String[] patterns = new String[]{
- "$1.isDirectory()",
- "new ImageIcon($1)"
- };
-
- verifyIndex(patterns, "test/Test1.java", "test/Test2.java");
- }
-
- private void verifyIndex(final String[] patterns, String... containedIn) throws Exception {
- ClasspathInfo cpInfo = Hacks.createUniversalCPInfo();
- final Set<String> real = new HashSet<String>();
-
- JavaSource.create(cpInfo).runUserActionTask(new Task<CompilationController>() {
- public void run(CompilationController parameter) throws Exception {
- real.addAll(IndexQuery.open(src.toURI().toURL()).findCandidates(BulkSearch.getDefault().create(parameter, new AtomicBoolean(), patterns)));
- }
- }, true);
-
- Set<String> golden = new HashSet<String>(Arrays.asList(containedIn));
-
- assertEquals(golden, real);
- }
-}
diff --git a/cmdline/lib/build.xml b/cmdline/lib/build.xml
index b5b2701..7b17037 100644
--- a/cmdline/lib/build.xml
+++ b/cmdline/lib/build.xml
@@ -22,7 +22,7 @@
<project name="org.netbeans.modules.jackpot30.compiler" default="netbeans" basedir=".">
<description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.compiler.</description>
<import file="nbproject/build-impl.xml"/>
- <import file="${suite.dir}/../findbugs-import.xml"/>
+ <!--<import file="${suite.dir}/../findbugs-import.xml"/>-->
<target name="create-cmdline-lib" depends="init">
<mkdir dir="${build.classes.dir}/../lib" />
diff --git a/cmdline/lib/nbproject/project.properties b/cmdline/lib/nbproject/project.properties
index aea31b2..78f7f90 100644
--- a/cmdline/lib/nbproject/project.properties
+++ b/cmdline/lib/nbproject/project.properties
@@ -16,5 +16,4 @@
is.autoload=true
javac.source=1.7
javac.compilerargs=-Xlint -Xlint:-serial
-requires.nb.javac=true
spec.version.base=1.16.0
diff --git a/cmdline/lib/nbproject/project.xml b/cmdline/lib/nbproject/project.xml
index e151cb7..bbc68bc 100644
--- a/cmdline/lib/nbproject/project.xml
+++ b/cmdline/lib/nbproject/project.xml
@@ -93,14 +93,6 @@
</run-dependency>
</dependency>
<dependency>
- <code-name-base>org.netbeans.modules.jackpot30.remoting.api</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <specification-version>1.0</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
<code-name-base>org.netbeans.modules.java.hints</code-name-base>
<run-dependency>
<release-version>1</release-version>
@@ -236,20 +228,15 @@
<compile-dependency/>
</test-dependency>
<test-dependency>
- <code-name-base>org.netbeans.modules.jackpot30.common</code-name-base>
- <compile-dependency/>
- </test-dependency>
- <test-dependency>
- <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
- <recursive/>
+ <code-name-base>org.netbeans.modules.java.hints</code-name-base>
<compile-dependency/>
</test-dependency>
<test-dependency>
- <code-name-base>org.netbeans.modules.java.hints</code-name-base>
+ <code-name-base>org.netbeans.modules.java.hints.declarative</code-name-base>
<compile-dependency/>
</test-dependency>
<test-dependency>
- <code-name-base>org.netbeans.modules.java.hints.declarative</code-name-base>
+ <code-name-base>org.netbeans.modules.java.j2seplatform</code-name-base>
<compile-dependency/>
</test-dependency>
<test-dependency>
diff --git a/cmdline/lib/src/org/netbeans/modules/jackpot30/cmdline/lib/DumpHints.java b/cmdline/lib/src/org/netbeans/modules/jackpot30/cmdline/lib/DumpHints.java
index 485ba83..db46a0e 100644
--- a/cmdline/lib/src/org/netbeans/modules/jackpot30/cmdline/lib/DumpHints.java
+++ b/cmdline/lib/src/org/netbeans/modules/jackpot30/cmdline/lib/DumpHints.java
@@ -22,7 +22,7 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import org.codeviation.pojson.Pojson;
+//import org.codeviation.pojson.Pojson;
import org.netbeans.modules.java.hints.providers.spi.HintMetadata;
import org.netbeans.modules.java.hints.spiimpl.RulesManager;
@@ -33,21 +33,22 @@ import org.netbeans.modules.java.hints.spiimpl.RulesManager;
public class DumpHints {
public static String dumpHints() {
- List<Map<String, String>> data = new LinkedList<Map<String, String>>();
-
- for (HintMetadata hm : RulesManager.getInstance().readHints(null, null, null).keySet()) {
- Map<String, String> hintData = new HashMap<String, String>();
-
- hintData.put("id", hm.id);
- hintData.put("category", hm.category);
- hintData.put("displayName", hm.displayName);
- hintData.put("description", hm.description);
- hintData.put("enabled", Boolean.toString(hm.enabled));
-
- data.add(hintData);
- }
-
- return Pojson.save(data);
+// List<Map<String, String>> data = new LinkedList<Map<String, String>>();
+//
+// for (HintMetadata hm : RulesManager.getInstance().readHints(null, null, null).keySet()) {
+// Map<String, String> hintData = new HashMap<String, String>();
+//
+// hintData.put("id", hm.id);
+// hintData.put("category", hm.category);
+// hintData.put("displayName", hm.displayName);
+// hintData.put("description", hm.description);
+// hintData.put("enabled", Boolean.toString(hm.enabled));
+//
+// data.add(hintData);
+// }
+//
+// return Pojson.save(data);
+ throw new IllegalStateException();
}
public static void main(String[] args) {
diff --git a/cmdline/lib/src/org/netbeans/modules/jackpot30/cmdline/lib/StandaloneTools.java b/cmdline/lib/src/org/netbeans/modules/jackpot30/cmdline/lib/StandaloneTools.java
index 298e569..6dcfa74 100644
--- a/cmdline/lib/src/org/netbeans/modules/jackpot30/cmdline/lib/StandaloneTools.java
+++ b/cmdline/lib/src/org/netbeans/modules/jackpot30/cmdline/lib/StandaloneTools.java
@@ -65,6 +65,9 @@ import org.openide.util.NbPreferences;
import org.openide.util.NbPreferences.Provider;
import org.openide.util.lookup.Lookups;
import org.openide.util.lookup.ServiceProvider;
+import org.openide.xml.EntityCatalog;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
/**XXX: should not include JavaCustomIndexer for tools that do not strictly require it
*
@@ -235,15 +238,13 @@ public class StandaloneTools {
List<URL> layers = new LinkedList<URL>();
boolean found = false;
- for (Enumeration<URL> en = Thread.currentThread().getContextClassLoader().getResources("META-INF/generated-layer.xml"); en.hasMoreElements();) {
+ for (Enumeration<URL> en = RepositoryImpl.class.getClassLoader().getResources("META-INF/generated-layer.xml"); en.hasMoreElements();) {
found = true;
layers.add(en.nextElement());
}
assert found;
- System.err.println("layers=" + layers);
-
XMLFileSystem xmlFS = new XMLFileSystem();
xmlFS.setXmlUrls(layers.toArray(new URL[0]));
@@ -262,39 +263,11 @@ public class StandaloneTools {
@Override
public ClasspathInfo createUniversalCPInfo() {
- return ClasspathInfo.create(sysProp2CP("sun.boot.class.path"), ClassPath.EMPTY, ClassPath.EMPTY);
+ return ClasspathInfo.create(Utils.createDefaultBootClassPath(), ClassPath.EMPTY, ClassPath.EMPTY);
}
}
- //Copied from FallbackDefaultJavaPlatform:
- private static ClassPath sysProp2CP(String propname) {
- String sbcp = System.getProperty(propname);
- if (sbcp == null) {
- return null;
- }
- List<URL> roots = new ArrayList<URL>();
- StringTokenizer tok = new StringTokenizer(sbcp, File.pathSeparator);
- while (tok.hasMoreTokens()) {
- File f = new File(tok.nextToken());
- if (!f.exists()) {
- continue;
- }
- f = FileUtil.normalizeFile(f);
- URL u;
- try {
- u = f.toURI().toURL();
- } catch (MalformedURLException x) {
- throw new AssertionError(x);
- }
- if (FileUtil.isArchiveFile(u)) {
- u = FileUtil.getArchiveRoot(u);
- }
- roots.add(u);
- }
- return ClassPathSupport.createClassPath(roots.toArray(new URL[roots.size()]));
- }
-
@ServiceProvider(service=MIMEResolver.class)
public static final class JavaMimeResolver extends MIMEResolver {
@@ -355,4 +328,17 @@ public class StandaloneTools {
}
}
+
+ @ServiceProvider(service=EntityCatalog.class, position=100)
+ public static final class EntityCatalogImpl extends EntityCatalog {
+
+ @Override
+ public InputSource resolveEntity(String arg0, String arg1) throws SAXException, IOException {
+ if ("-//NetBeans//DTD Tool Configuration 1.0//EN".equals(arg0)) {
+ return new InputSource(EntityCatalogImpl.class.getResourceAsStream("/org/netbeans/modules/editor/tools/storage/ToolConfiguration-1_0.dtd"));
+ }
+ return null;
+ }
+
+ }
}
diff --git a/cmdline/lib/src/org/netbeans/modules/jackpot30/cmdline/lib/Utils.java b/cmdline/lib/src/org/netbeans/modules/jackpot30/cmdline/lib/Utils.java
index 0bddeba..36ecc04 100644
--- a/cmdline/lib/src/org/netbeans/modules/jackpot30/cmdline/lib/Utils.java
+++ b/cmdline/lib/src/org/netbeans/modules/jackpot30/cmdline/lib/Utils.java
@@ -18,10 +18,27 @@
*/
package org.netbeans.modules.jackpot30.cmdline.lib;
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.regex.Pattern;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.java.classpath.ClassPath;
import org.netbeans.modules.java.hints.providers.spi.HintDescription;
+import org.netbeans.spi.java.classpath.PathResourceImplementation;
+import org.netbeans.spi.java.classpath.support.ClassPathSupport;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.filesystems.URLMapper;
+import org.openide.util.BaseUtilities;
/**
*
@@ -68,4 +85,76 @@ public class Utils {
put("!=", "not_equals");
}};
+ //copied from BootClassPathUtil:
+ public static ClassPath createDefaultBootClassPath() {
+ String cp = System.getProperty("sun.boot.class.path");
+ if (cp != null) {
+ List<URL> urls = new ArrayList<>();
+ String[] paths = cp.split(Pattern.quote(System.getProperty("path.separator")));
+ for (String path : paths) {
+ File f = new File(path);
+
+ if (!f.canRead())
+ continue;
+
+ FileObject fo = FileUtil.toFileObject(f);
+ if (FileUtil.isArchiveFile(fo)) {
+ fo = FileUtil.getArchiveRoot(fo);
+ }
+ if (fo != null) {
+ urls.add(fo.toURL());
+ }
+ }
+ return ClassPathSupport.createClassPath((URL[])urls.toArray(new URL[0]));
+ } else {
+ try {
+ Class.forName("org.netbeans.ProxyURLStreamHandlerFactory").getMethod("register")
+ .invoke(null);
+ } catch (ClassNotFoundException | NoSuchMethodException |
+ SecurityException | IllegalAccessException |
+ IllegalArgumentException | InvocationTargetException ex) {
+ throw new IllegalStateException(ex);
+ }
+ final List<PathResourceImplementation> modules = new ArrayList<>();
+ final File installDir = new File(System.getProperty("java.home"));
+ final URI imageURI = getImageURI(installDir);
+ try {
+ final FileObject jrtRoot = URLMapper.findFileObject(imageURI.toURL());
+ final FileObject root = getModulesRoot(jrtRoot);
+ for (FileObject module : root.getChildren()) {
+ modules.add(ClassPathSupport.createResource(module.toURL()));
+ }
+ } catch (MalformedURLException e) {
+ throw new IllegalStateException(e);
+ }
+ if (modules.isEmpty()) {
+ throw new IllegalStateException("No modules!");
+ }
+ return ClassPathSupport.createClassPath(modules);
+ }
+ }
+
+ private static final String PROTOCOL = "nbjrt"; //NOI18N
+
+ private static URI getImageURI(@NonNull final File jdkHome) {
+ try {
+ return new URI(String.format(
+ "%s:%s!/%s", //NOI18N
+ PROTOCOL,
+ BaseUtilities.toURI(jdkHome).toString(),
+ ""));
+ } catch (URISyntaxException e) {
+ throw new IllegalStateException();
+ }
+ }
+
+ @NonNull
+ private static FileObject getModulesRoot(@NonNull final FileObject jrtRoot) {
+ final FileObject modules = jrtRoot.getFileObject("modules"); //NOI18N
+ //jimage v1 - modules are located in the root
+ //jimage v2 - modules are located in "modules" folder
+ return modules == null ?
+ jrtRoot :
+ modules;
+ }
}
diff --git a/cmdline/lib/test/unit/src/org/netbeans/modules/jackpot30/cmdline/lib/CreateStandaloneJar.java b/cmdline/lib/test/unit/src/org/netbeans/modules/jackpot30/cmdline/lib/CreateStandaloneJar.java
index 34d32ff..c8a023e 100644
--- a/cmdline/lib/test/unit/src/org/netbeans/modules/jackpot30/cmdline/lib/CreateStandaloneJar.java
+++ b/cmdline/lib/test/unit/src/org/netbeans/modules/jackpot30/cmdline/lib/CreateStandaloneJar.java
@@ -18,8 +18,6 @@
*/
package org.netbeans.modules.jackpot30.cmdline.lib;
-import com.sun.source.tree.Tree;
-import com.sun.tools.javac.api.JavacTool;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -31,6 +29,7 @@ import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.net.URL;
+import java.net.URLStreamHandlerFactory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -45,7 +44,6 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import org.apache.lucene.analysis.tokenattributes.OffsetAttributeImpl;
@@ -57,11 +55,12 @@ import org.netbeans.modules.classfile.ClassFile;
import org.netbeans.modules.classfile.ClassName;
import org.netbeans.modules.editor.mimelookup.MimeLookupCacheSPI;
import org.netbeans.modules.editor.mimelookup.SharedMimeLookupCache;
+import org.netbeans.modules.editor.tools.storage.api.ToolPreferences;
import org.netbeans.modules.jackpot30.cmdline.lib.StandaloneTools.ActiveDocumentProviderImpl;
import org.netbeans.modules.jackpot30.cmdline.lib.StandaloneTools.EditorMimeTypesImplementationImpl;
+import org.netbeans.modules.jackpot30.cmdline.lib.StandaloneTools.EntityCatalogImpl;
import org.netbeans.modules.jackpot30.cmdline.lib.StandaloneTools.JavaMimeResolver;
import org.netbeans.modules.jackpot30.cmdline.lib.StandaloneTools.RepositoryImpl;
-import org.netbeans.modules.jackpot30.common.api.IndexAccess;
import org.netbeans.modules.java.classpath.DefaultGlobalPathRegistryImplementation;
import org.netbeans.modules.java.hints.StandardJavacWarnings.CompilerSettingsImpl;
import org.netbeans.modules.java.hints.declarative.DeclarativeHintRegistry;
@@ -73,8 +72,16 @@ import org.netbeans.modules.java.hints.providers.spi.HintProvider;
import org.netbeans.modules.java.hints.spiimpl.RulesManager;
import org.netbeans.modules.java.hints.spiimpl.RulesManagerImpl;
import org.netbeans.modules.java.hints.spiimpl.Utilities.SPI;
+import org.netbeans.modules.java.j2seplatform.platformdefinition.jrtfs.NBJRTURLMapper;
+import org.netbeans.modules.java.j2seplatform.platformdefinition.jrtfs.NBJRTURLStreamHandler;
import org.netbeans.modules.java.source.DefaultPositionRefProvider;
import org.netbeans.modules.java.source.PositionRefProvider;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileWorkerProvider;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.DefaultCompileWorkerProvider;
+import org.netbeans.modules.java.source.parsing.JavacParser;
+import org.netbeans.modules.java.source.parsing.JavacParser.ContextEnhancer;
+import org.netbeans.modules.java.source.parsing.JavacParser.VanillaJavacContextEnhancer;
+import org.netbeans.modules.java.source.parsing.ModuleOraculum;
import org.netbeans.modules.java.source.tasklist.CompilerSettings;
import org.netbeans.modules.openide.util.DefaultMutexImplementation;
import org.netbeans.modules.openide.util.NbMutexEventProvider;
@@ -88,8 +95,10 @@ import org.netbeans.spi.editor.document.EditorMimeTypesImplementation;
import org.netbeans.spi.editor.mimelookup.MimeDataProvider;
import org.netbeans.spi.java.classpath.GlobalPathRegistryImplementation;
import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.queries.CompilerOptionsQueryImplementation;
import org.netbeans.spi.project.ProjectManagerImplementation;
import org.openide.filesystems.MIMEResolver;
+import org.openide.filesystems.Repository;
import org.openide.util.NbCollections;
import org.openide.util.NbPreferences.Provider;
import org.openide.util.spi.MutexEventProvider;
@@ -177,12 +186,12 @@ public abstract class CreateStandaloneJar extends NbTestCase {
Class<?> clazz = Class.forName(fqn, false, this.getClass().getClassLoader());
if ( clazz.getProtectionDomain().getCodeSource() == null
- && !clazz.getName().startsWith("com.sun.source")
- && !clazz.getName().startsWith("com.sun.javadoc")
- && !clazz.getName().startsWith("com.sun.tools")
- && !clazz.getName().startsWith("javax.tools")
- && !clazz.getName().startsWith("javax.annotation.processing")
- && !clazz.getName().startsWith("javax.lang.model")) {
+ || clazz.getName().startsWith("com.sun.source")
+ || clazz.getName().startsWith("com.sun.javadoc")
+ || clazz.getName().startsWith("com.sun.tools")
+ || clazz.getName().startsWith("javax.tools")
+ || clazz.getName().startsWith("javax.annotation.processing")
+ || clazz.getName().startsWith("javax.lang.model")) {
//probably platform class:
continue;
}
@@ -279,6 +288,14 @@ public abstract class CreateStandaloneJar extends NbTestCase {
registrations.add(new MetaInfRegistration(CompilerSettings.class.getName(), CompilerSettingsImpl.class.getName()));
registrations.add(new MetaInfRegistration(MutexImplementation.class.getName(), DefaultMutexImplementation.class.getName()));
registrations.add(new MetaInfRegistration(MutexEventProvider.class.getName(), NbMutexEventProvider.class.getName()));
+ registrations.add(new MetaInfRegistration(CompilerOptionsQueryImplementation.class.getName(), ModuleOraculum.class.getName()));
+ registrations.add(new MetaInfRegistration(URLStreamHandlerFactory.class.getName(), NBJRTURLStreamHandler.FactoryImpl.class.getName()));
+ registrations.add(new MetaInfRegistration(ContextEnhancer.class.getName(), JavacParser.VanillaJavacContextEnhancer.class.getName()));
+ registrations.add(new MetaInfRegistration(Repository.class.getName(), RepositoryImpl.class.getName()));
+ registrations.add(new MetaInfRegistration(RulesManager.class.getName(), RulesManagerImpl.class.getName()));
+ registrations.add(new MetaInfRegistration(EntityCatalog.class.getName(), EntityCatalogImpl.class.getName()));
+ registrations.add(new MetaInfRegistration(CompileWorkerProvider.class.getName(), DefaultCompileWorkerProvider.class.getName()));
+
registrations.addAll(info.metaInf);
Map<String, Collection<MetaInfRegistration>> api2Registrations = new HashMap<String, Collection<MetaInfRegistration>>();
@@ -496,7 +513,6 @@ public abstract class CreateStandaloneJar extends NbTestCase {
"org.netbeans.core.NbLoaderPool",
"org.netbeans.core.startup.preferences.PreferencesProviderImpl",
"org.netbeans.modules.java.platform.DefaultJavaPlatformProvider",
- IndexAccess.class.getName(),
RulesManagerImpl.class.getName(),
"com.sun.tools.javac.resources.compiler",
@@ -507,8 +523,6 @@ public abstract class CreateStandaloneJar extends NbTestCase {
, "org.netbeans.modules.java.hints.legacy.spi.RulesManager$HintProviderImpl"
- , Tree.class.getName()
- ,JavacTool.class.getName()
,JavaMimeResolver.class.getName()
, "org.netbeans.api.java.source.support.OpenedEditors",
SharedMimeLookupCache.class.getName(),
@@ -520,7 +534,14 @@ public abstract class CreateStandaloneJar extends NbTestCase {
NbMutexEventProvider.class.getName(),
DefaultMutexImplementation.class.getName(),
Utils.class.getName(),
- IndexerControl.class.getName()
+ IndexerControl.class.getName(),
+ ModuleOraculum.class.getName(),
+ ToolPreferences.class.getName(),
+ NBJRTURLStreamHandler.FactoryImpl.class.getName(),
+ NBJRTURLMapper.class.getName(),
+ VanillaJavacContextEnhancer.class.getName(),
+ EntityCatalogImpl.class.getName(),
+ DefaultCompileWorkerProvider.class.getName()
));
private static final Set<String> COPY_REGISTRATION = new HashSet<String>(Arrays.<String>asList(
@@ -529,7 +550,6 @@ public abstract class CreateStandaloneJar extends NbTestCase {
"org.openide.util.Lookup",
"org.netbeans.modules.openide.util.PreferencesProvider",
ClassPathBasedHintProvider.class.getName(),
- IndexAccess.class.getName(),
RulesManager.class.getName(),
MimeLookupCacheSPI.class.getName(),
EnvironmentFactory.class.getName(),
@@ -539,21 +559,12 @@ public abstract class CreateStandaloneJar extends NbTestCase {
));
private static final Set<String> RESOURCES = new HashSet<String>(Arrays.asList(
- "com/sun/tools/javac/resources/javac_zh_CN.properties",
- "com/sun/tools/javac/resources/compiler_ja.properties",
- "com/sun/tools/javac/resources/compiler_zh_CN.properties",
- "com/sun/tools/javac/resources/legacy.properties",
- "com/sun/tools/javac/resources/compiler.properties",
- "com/sun/tools/javac/resources/javac_ja.properties",
- "com/sun/tools/javac/resources/javac.properties",
- "com/sun/tools/javadoc/resources/javadoc.properties",
- "com/sun/tools/javadoc/resources/javadoc_ja.properties",
- "com/sun/tools/javadoc/resources/javadoc_zh_CN.properties",
"org/netbeans/modules/java/source/resources/icons/error-badge.gif",
"org/netbeans/modules/java/source/resources/layer.xml",
"org/netbeans/modules/java/j2seproject/ui/resources/brokenProjectBadge.gif",
"org/netbeans/modules/java/j2seproject/ui/resources/compileOnSaveDisabledBadge.gif",
- "org/netbeans/modules/parsing/impl/resources/error-badge.gif"
+ "org/netbeans/modules/parsing/impl/resources/error-badge.gif",
+ "org/netbeans/modules/editor/tools/storage/ToolConfiguration-1_0.dtd"
));
}
diff --git a/cmdline/maven/pom.xml b/cmdline/maven/pom.xml
index 3dca82f..474d465 100644
--- a/cmdline/maven/pom.xml
+++ b/cmdline/maven/pom.xml
@@ -21,7 +21,7 @@
<groupId>org.netbeans.modules.jackpot30</groupId>
<artifactId>jackpot30-maven-plugin</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>9.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>Jackpot 3.0 Command Line Tool Maven Bridge</name>
@@ -41,7 +41,7 @@
<dependency>
<groupId>org.netbeans.modules.jackpot30</groupId>
<artifactId>tool</artifactId>
- <version>7.3-SNAPSHOT</version>
+ <version>9.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
diff --git a/cmdline/nbproject/platform.properties b/cmdline/nbproject/platform.properties
index ef77a7e..a143850 100644
--- a/cmdline/nbproject/platform.properties
+++ b/cmdline/nbproject/platform.properties
@@ -15,25 +15,13 @@
cluster.path=\
${nbplatform.active.dir}/apisupport:\
- ${nbplatform.active.dir}/cnd:\
- ${nbplatform.active.dir}/dlight:\
- ${nbplatform.active.dir}/enterprise:\
+ ${nbplatform.active.dir}/extide:\
${nbplatform.active.dir}/harness:\
${nbplatform.active.dir}/ide:\
- ${nbplatform.active.dir}/extide:\
${nbplatform.active.dir}/java:\
${nbplatform.active.dir}/nb:\
${nbplatform.active.dir}/platform:\
${nbplatform.active.dir}/profiler:\
- ${nbplatform.active.dir}/websvccommon:\
- ../borrowedtests/build/cluster:\
- ../remoting/ide/build/cluster:\
- ../language/ide/build/cluster:\
- ../remoting/common/build/cluster
-extcluster.../language/ide/build/cluster.javadoc=
-extcluster.../language/ide/build/cluster.sources=
-extcluster.../remoting/common/build/cluster.javadoc=
-extcluster.../remoting/common/build/cluster.sources=
-extcluster.../remoting/ide/build/cluster.javadoc=
-extcluster.../remoting/ide/build/cluster.sources=
+ ${nbplatform.active.dir}/websvccommon
+nbjdk.active=default
nbplatform.active=default
diff --git a/cmdline/nbproject/project.properties b/cmdline/nbproject/project.properties
index de70cb3..3585040 100644
--- a/cmdline/nbproject/project.properties
+++ b/cmdline/nbproject/project.properties
@@ -15,11 +15,7 @@
modules=\
${project.org.netbeans.modules.jackpot30.cmdline.lib}:\
- ${project.org.netbeans.modules.jackpot30.compiler}:\
- ${project.org.netbeans.modules.jackpot30.cmdline}:\
- ${project.org.netbeans.modules.jackpot30.ap}
-project.org.netbeans.modules.jackpot30.ap=ap
+ ${project.org.netbeans.modules.jackpot30.cmdline}
project.org.netbeans.modules.jackpot30.cmdline=tool
project.org.netbeans.modules.jackpot30.cmdline.lib=lib
-project.org.netbeans.modules.jackpot30.compiler=compiler
diff --git a/cmdline/tool/build.xml b/cmdline/tool/build.xml
index 595fc0f..191c89d 100644
--- a/cmdline/tool/build.xml
+++ b/cmdline/tool/build.xml
@@ -22,7 +22,21 @@
<project name="org.netbeans.modules.jackpot30.cmdline" default="netbeans" basedir=".">
<description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.cmdline.</description>
<import file="nbproject/build-impl.xml"/>
- <import file="${suite.dir}/../findbugs-import.xml"/>
+ <!--<import file="${suite.dir}/../findbugs-import.xml"/>-->
+
+ <target name="-check-joptsimple">
+ <condition property="has.joptsimple">
+ <available file="lib/jopt-simple-3.2.jar" />
+ </condition>
+ </target>
+
+ <target name="-download-joptsimple" depends="-check-joptsimple" unless="has.joptsimple">
+ <mkdir dir="lib" />
+ <get src="http://central.maven.org/maven2/net/sf/jopt-simple/jopt-simple/3.2/jopt-simple-3.2.jar"
+ dest="lib/jopt-simple-3.2.jar" usetimestamp="true"/>
+ </target>
+
+ <target name="build-init" depends="harness.build-init,-download-joptsimple" />
<target name="create-standalone-tool" depends="init,netbeans">
<mkdir dir="${build.classes.dir}/../jackpot" />
@@ -49,5 +63,22 @@
</target>
<target name="test-build" depends="projectized-common.test-build,-prepare-scripted-tests" />
-
+
+ <target name="-prepare-scripted-tests" depends="-check-scripted-tests" if="has.scripted.tests">
+ <mkdir dir="build/test/scripted" />
+ <copy todir="build/test/scripted">
+ <fileset dir="test/scripted"/>
+ </copy>
+ <copy todir="build/test/scripted">
+ <fileset dir="../test/scripted"/>
+ </copy>
+ <chmod dir="build/test/scripted" perm="u+x" includes="**/*" />
+ </target>
+
+ <target name="-check-scripted-tests" depends="build-init">
+ <condition property="has.scripted.tests" value="true">
+ <available file="test/scripted/config" />
+ </condition>
+ </target>
+
</project>
diff --git a/cmdline/tool/nbproject/project.properties b/cmdline/tool/nbproject/project.properties
index 1a7c0b9..2c863ee 100644
--- a/cmdline/tool/nbproject/project.properties
+++ b/cmdline/tool/nbproject/project.properties
@@ -13,9 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-javac.source=1.7
+javac.source=1.8
javac.compilerargs=-Xlint -Xlint:-serial
-cp.extra=../../lib/jopt-simple/jopt-simple-3.2.jar
+cp.extra=lib/jopt-simple-3.2.jar:${tools.jar}
spec.version.base=1.16.0
test.timeout=6000000
-requires.nb.javac=true
diff --git a/cmdline/tool/nbproject/project.xml b/cmdline/tool/nbproject/project.xml
index 2aed2e3..0cced1a 100644
--- a/cmdline/tool/nbproject/project.xml
+++ b/cmdline/tool/nbproject/project.xml
@@ -91,23 +91,15 @@
</run-dependency>
</dependency>
<dependency>
- <code-name-base>org.netbeans.modules.jackpot30.cmdline.lib</code-name-base>
+ <code-name-base>org.netbeans.modules.editor.tools.storage</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
- <implementation-version/>
+ <specification-version>1.10</specification-version>
</run-dependency>
</dependency>
<dependency>
- <code-name-base>org.netbeans.modules.jackpot30.indexing</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <implementation-version/>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.modules.jackpot30.ui</code-name-base>
+ <code-name-base>org.netbeans.modules.jackpot30.cmdline.lib</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
@@ -361,10 +353,6 @@
<test/>
</test-dependency>
<test-dependency>
- <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
- <compile-dependency/>
- </test-dependency>
- <test-dependency>
<code-name-base>org.netbeans.modules.java.freeform</code-name-base>
<recursive/>
<compile-dependency/>
diff --git a/cmdline/tool/scripts/jackpot b/cmdline/tool/scripts/jackpot
index a8a9073..39995c1 100755
--- a/cmdline/tool/scripts/jackpot
+++ b/cmdline/tool/scripts/jackpot
@@ -18,4 +18,4 @@
JACKPOT_JAR=`readlink -f "$0"`
JACKPOT_JAR=`dirname "$JACKPOT_JAR"`/jackpot.jar
-java -classpath `dirname "$JACKPOT_JAR"`/jackpot.jar org.netbeans.modules.jackpot30.cmdline.Main "$@"
+java --add-exports jdk.javadoc/com.sun.tools.javadoc.main=ALL-UNNAMED -classpath `dirname "$JACKPOT_JAR"`/jackpot.jar org.netbeans.modules.jackpot30.cmdline.Main "$@"
diff --git a/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java b/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java
index c830dcb..39d995a 100644
--- a/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java
+++ b/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java
@@ -28,8 +28,13 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
+import java.io.UncheckedIOException;
import java.io.Writer;
+import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
@@ -45,12 +50,15 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.AbstractPreferences;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import javax.lang.model.SourceVersion;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
@@ -65,16 +73,18 @@ import org.netbeans.api.java.classpath.ClassPath;
import org.netbeans.api.java.classpath.GlobalPathRegistry;
import org.netbeans.api.java.source.CompilationController;
import org.netbeans.api.java.source.ModificationResult;
-import org.netbeans.core.startup.MainLookup;
+import org.netbeans.modules.editor.tools.storage.api.ToolPreferences;
import org.netbeans.modules.jackpot30.cmdline.lib.Utils;
-import org.netbeans.modules.jackpot30.ui.settings.XMLHintPreferences;
+//import org.netbeans.modules.jackpot30.ui.settings.XMLHintPreferences;
import org.netbeans.modules.java.hints.declarative.DeclarativeHintRegistry;
import org.netbeans.modules.java.hints.declarative.test.TestParser;
import org.netbeans.modules.java.hints.declarative.test.TestParser.TestCase;
import org.netbeans.modules.java.hints.declarative.test.TestPerformer;
+import org.netbeans.modules.java.hints.declarative.test.TestPerformer.TestClassPathProvider;
import org.netbeans.modules.java.hints.jackpot.spi.PatternConvertor;
import org.netbeans.modules.java.hints.providers.spi.HintDescription;
import org.netbeans.modules.java.hints.providers.spi.HintMetadata;
+import org.netbeans.modules.java.hints.providers.spi.HintMetadata.Options;
import org.netbeans.modules.java.hints.spiimpl.MessageImpl;
import org.netbeans.modules.java.hints.spiimpl.RulesManager;
import org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch;
@@ -97,12 +107,15 @@ import org.netbeans.spi.editor.hints.ErrorDescriptionFactory;
import org.netbeans.spi.editor.hints.Fix;
import org.netbeans.spi.editor.hints.Severity;
import org.netbeans.spi.java.classpath.ClassPathProvider;
+import org.netbeans.spi.java.classpath.PathResourceImplementation;
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
import org.netbeans.spi.java.hints.Hint.Kind;
import org.netbeans.spi.java.queries.SourceLevelQueryImplementation2;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileStateInvalidException;
import org.openide.filesystems.FileUtil;
+import org.openide.filesystems.URLMapper;
+import org.openide.util.BaseUtilities;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
import org.openide.util.Pair;
@@ -129,6 +142,12 @@ public class Main {
}
public static int compile(String... args) throws IOException, ClassNotFoundException {
+ try {
+ Class.forName("javax.lang.model.element.ModuleElement");
+ } catch (ClassNotFoundException ex) {
+ System.err.println("Error: no suitable javac found, please run on JDK 10+.");
+ return 1;
+ }
System.setProperty("netbeans.user", "/tmp/tmp-foo");
OptionParser parser = new OptionParser();
@@ -276,14 +295,16 @@ public class Main {
boolean apply;
boolean runDeclarative;
boolean runDeclarativeTests;
+ boolean useDefaultEnabledSetting;
if (parsed.has(configFile)) {
- Preferences settingsFromConfigFile;
- settingsFromConfigFile = XMLHintPreferences.from(parsed.valueOf(configFile));
- hintSettingsPreferences = settingsFromConfigFile.node("settings");
- apply = settingsFromConfigFile.getBoolean("apply", false);
- runDeclarative = settingsFromConfigFile.getBoolean("runDeclarative", true);
- runDeclarativeTests = settingsFromConfigFile.getBoolean("runDeclarativeTests", false);
+ ToolPreferences toolPrefs = ToolPreferences.from(parsed.valueOf(configFile).toURI());
+ hintSettingsPreferences = toolPrefs.getPreferences("hints", "text/x-java");
+ Preferences toolSettings = toolPrefs.getPreferences("standalone", "text/x-java");
+ apply = toolSettings.getBoolean("apply", false);
+ runDeclarative = toolSettings.getBoolean("runDeclarative", true);
+ runDeclarativeTests = toolSettings.getBoolean("runDeclarativeTests", false);
+ useDefaultEnabledSetting = true; //TODO: read from the configuration file?
if (parsed.has(hint)) {
System.err.println("cannot specify --hint and --config-file together");
return 1;
@@ -296,6 +317,7 @@ public class Main {
apply = false;
runDeclarative = true;
runDeclarativeTests = parsed.has(RUN_TESTS);
+ useDefaultEnabledSetting = false;
}
if (parsed.has(config) && !parsed.has(hint)) {
@@ -312,7 +334,7 @@ public class Main {
GroupResult result = GroupResult.NOTHING_TO_DO;
try (Writer outS = parsed.has(out) ? new BufferedWriter(new OutputStreamWriter(new FileOutputStream(parsed.valueOf(out)))) : null) {
- GlobalConfiguration globalConfig = new GlobalConfiguration(hintSettingsPreferences, apply, runDeclarative, runDeclarativeTests, parsed.valueOf(hint), parsed.valueOf(hintFile), outS, parsed.has(OPTION_FAIL_ON_WARNINGS));
+ GlobalConfiguration globalConfig = new GlobalConfiguration(hintSettingsPreferences, apply, runDeclarative, runDeclarativeTests, useDefaultEnabledSetting, parsed.valueOf(hint), parsed.valueOf(hintFile), outS, parsed.has(OPTION_FAIL_ON_WARNINGS));
for (RootConfiguration groupConfig : groups) {
result = result.join(handleGroup(groupConfig, progress, globalConfig, parsed.valuesOf(config)));
@@ -401,7 +423,7 @@ public class Main {
ProgressHandleWrapper progress = w.startNextPartWithEmbedding(1);
Preferences settings = globalConfig.configurationPreferences != null ? globalConfig.configurationPreferences : new MemoryPreferences();
- HintsSettings hintSettings = HintsSettings.createPreferencesBasedHintsSettings(settings, false, null);
+ HintsSettings hintSettings = HintsSettings.createPreferencesBasedHintsSettings(settings, globalConfig.useDefaultEnabledSetting, null);
if (globalConfig.hint != null) {
hints = findHints(rootConfiguration.sourceCP, rootConfiguration.binaryCP, globalConfig.hint, hintSettings);
@@ -504,29 +526,38 @@ public class Main {
new SourceLevelQueryImpl(rootConfiguration.sourceCP, sourceLevel)
};
- try {
- for (Object toRegister : register2Lookup) {
- MainLookup.register(toRegister);
- }
+ GroupResult[] result = new GroupResult[1];
- if (globalConfig.apply) {
- apply(hints, rootConfiguration.rootFolders.toArray(new Folder[0]), progress, hintSettings, globalConfig.out);
+ Lookups.executeWith(new ProxyLookup(Lookups.fixed(register2Lookup), Lookup.getDefault()), () -> {
+ try {
+ Field implementations = ClassPath.class.getDeclaredField("implementations");
+ implementations.setAccessible(true);
+ AtomicReference r = (AtomicReference) implementations.get(null);
+ r.set(null);
+ } catch (Throwable t) {
+ throw new IllegalStateException(t);
+ }
- return GroupResult.SUCCESS; //TODO: WarningsAndErrors?
- } else {
- findOccurrences(hints, rootConfiguration.rootFolders.toArray(new Folder[0]), progress, hintSettings, wae);
+ try {
+ if (globalConfig.apply) {
+ apply(hints, rootConfiguration.rootFolders.toArray(new Folder[0]), progress, hintSettings, globalConfig.out);
- if (wae.errors != 0 || (wae.warnings != 0 && globalConfig.failOnWarnings)) {
- return GroupResult.FAILURE;
+ result[0] = GroupResult.SUCCESS; //TODO: WarningsAndErrors?
} else {
- return GroupResult.SUCCESS;
+ findOccurrences(hints, rootConfiguration.rootFolders.toArray(new Folder[0]), progress, hintSettings, wae);
+
+ if (wae.errors != 0 || (wae.warnings != 0 && globalConfig.failOnWarnings)) {
+ result[0] = GroupResult.FAILURE;
+ } else {
+ result[0] = GroupResult.SUCCESS;
+ }
}
+ } catch (IOException t) {
+ throw new UncheckedIOException(t);
}
- } finally {
- for (Object toUnRegister : register2Lookup) {
- MainLookup.unregister(toUnRegister);
- }
- }
+ });
+
+ return result[0];
}
private static class MemoryPreferences extends AbstractPreferences {
@@ -655,7 +686,8 @@ public class Main {
for (Entry<HintMetadata, ? extends Collection<? extends HintDescription>> entry: all.entrySet()) {
if (hardcoded.containsKey(entry.getKey())) {
- if (toEnableIn.isEnabled(entry.getKey())) {
+ if (toEnableIn.isEnabled(entry.getKey()) && entry.getKey().kind == Kind.INSPECTION && !entry.getKey().options.contains(Options.NO_BATCH)) {
+ System.err.println("enabled:" + entry.getKey().displayName);
descs.addAll(entry.getValue());
}
} else {
@@ -684,6 +716,9 @@ public class Main {
BatchSearch.getVerifiedSpans(occurrences, w, new VerifiedSpansCallBack() {
@Override public void groupStarted() {}
@Override public boolean spansVerified(CompilationController wc, Resource r, Collection<? extends ErrorDescription> hints) throws Exception {
+ hints = hints.stream()
+ .sorted((ed1, ed2) -> ed1.getRange().getBegin().getOffset() - ed2.getRange().getBegin().getOffset())
+ .collect(Collectors.toList());
for (ErrorDescription ed : hints) {
print(ed, wae, id2DisplayName);
}
@@ -735,7 +770,8 @@ public class Main {
if (out != null) {
for (ModificationResult mr : diffs) {
- org.netbeans.modules.jackpot30.indexing.batch.BatchUtilities.exportDiff(mr, null, out);
+ //XXX:
+// org.netbeans.modules.jackpot30.indexing.batch.BatchUtilities.exportDiff(mr, null, out);
}
} else {
for (ModificationResult mr : diffs) {
@@ -756,35 +792,6 @@ public class Main {
}
}
- private static ClassPath createDefaultBootClassPath() throws IOException {
- try {
- String cp = System.getProperty("sun.boot.class.path");
- List<URL> urls = new ArrayList<URL>();
- String[] paths = cp.split(Pattern.quote(System.getProperty("path.separator")));
-
- for (String path : paths) {
- File f = new File(path);
-
- if (!f.canRead())
- continue;
-
- FileObject fo = FileUtil.toFileObject(FileUtil.normalizeFile(f));
-
- if (FileUtil.isArchiveFile(fo)) {
- fo = FileUtil.getArchiveRoot(fo);
- }
-
- if (fo != null) {
- urls.add(fo.getURL());
- }
- }
-
- return ClassPathSupport.createClassPath(urls.toArray(new URL[0]));
- } catch (FileStateInvalidException e) {
- throw e;
- }
- }
-
private static ClassPath createClassPath(Iterable<? extends File> roots, ClassPath def) {
if (roots == null) return def;
@@ -798,37 +805,37 @@ public class Main {
}
private static void showGUICustomizer(File settingsFile, ClassPath binaryCP, ClassPath sourceCP) throws IOException, BackingStoreException {
- GlobalPathRegistry.getDefault().register(ClassPath.COMPILE, new ClassPath[] {binaryCP});
- GlobalPathRegistry.getDefault().register(ClassPath.SOURCE, new ClassPath[] {sourceCP});
- ClassPathBasedHintWrapper hints = new ClassPathBasedHintWrapper();
- final Preferences p = XMLHintPreferences.from(settingsFile);
- JPanel hintPanel = new HintsPanel(p.node("settings"), hints, true);
- final JCheckBox runDeclarativeHints = new JCheckBox("Always Run Declarative Rules");
-
- runDeclarativeHints.setToolTipText("Always run the declarative rules found on classpath? (Only those selected above will be run when unchecked.)");
- runDeclarativeHints.setSelected(p.getBoolean("runDeclarative", true));
- runDeclarativeHints.addActionListener(new ActionListener() {
- @Override public void actionPerformed(ActionEvent e) {
- p.putBoolean("runDeclarative", runDeclarativeHints.isSelected());
- }
- });
-
- JPanel customizer = new JPanel(new BorderLayout());
-
- customizer.add(hintPanel, BorderLayout.CENTER);
- customizer.add(runDeclarativeHints, BorderLayout.SOUTH);
- JOptionPane jop = new JOptionPane(customizer, JOptionPane.PLAIN_MESSAGE);
- JDialog dialog = jop.createDialog("Select Hints");
-
- jop.selectInitialValue();
- dialog.setVisible(true);
- dialog.dispose();
-
- Object result = jop.getValue();
-
- if (result.equals(JOptionPane.OK_OPTION)) {
- p.flush();
- }
+// GlobalPathRegistry.getDefault().register(ClassPath.COMPILE, new ClassPath[] {binaryCP});
+// GlobalPathRegistry.getDefault().register(ClassPath.SOURCE, new ClassPath[] {sourceCP});
+// ClassPathBasedHintWrapper hints = new ClassPathBasedHintWrapper();
+// final Preferences p = XMLHintPreferences.from(settingsFile);
+// JPanel hintPanel = new HintsPanel(p.node("settings"), hints, true);
+// final JCheckBox runDeclarativeHints = new JCheckBox("Always Run Declarative Rules");
+//
+// runDeclarativeHints.setToolTipText("Always run the declarative rules found on classpath? (Only those selected above will be run when unchecked.)");
+// runDeclarativeHints.setSelected(p.getBoolean("runDeclarative", true));
+// runDeclarativeHints.addActionListener(new ActionListener() {
+// @Override public void actionPerformed(ActionEvent e) {
+// p.putBoolean("runDeclarative", runDeclarativeHints.isSelected());
+// }
+// });
+//
+// JPanel customizer = new JPanel(new BorderLayout());
+//
+// customizer.add(hintPanel, BorderLayout.CENTER);
+// customizer.add(runDeclarativeHints, BorderLayout.SOUTH);
+// JOptionPane jop = new JOptionPane(customizer, JOptionPane.PLAIN_MESSAGE);
+// JDialog dialog = jop.createDialog("Select Hints");
+//
+// jop.selectInitialValue();
+// dialog.setVisible(true);
+// dialog.dispose();
+//
+// Object result = jop.getValue();
+//
+// if (result.equals(JOptionPane.OK_OPTION)) {
+// p.flush();
+// }
}
static String[] splitGroupArg(String arg) {
@@ -889,7 +896,7 @@ public class Main {
}
}
- this.bootCP = createClassPath(parsed.has(groupOptions.bootclasspath) ? parsed.valuesOf(groupOptions.bootclasspath) : null, createDefaultBootClassPath());
+ this.bootCP = createClassPath(parsed.has(groupOptions.bootclasspath) ? parsed.valuesOf(groupOptions.bootclasspath) : null, Utils.createDefaultBootClassPath());
this.compileCP = createClassPath(parsed.has(groupOptions.classpath) ? parsed.valuesOf(groupOptions.classpath) : null, ClassPath.EMPTY);
this.sourceCP = createClassPath(parsed.has(groupOptions.sourcepath) ? parsed.valuesOf(groupOptions.sourcepath) : null, ClassPathSupport.createClassPath(roots.toArray(new FileObject[0])));
this.binaryCP = ClassPathSupport.createProxyClassPath(bootCP, compileCP);
@@ -903,16 +910,18 @@ public class Main {
private final boolean apply;
private final boolean runDeclarative;
private final boolean runDeclarativeTests;
+ private final boolean useDefaultEnabledSetting;
private final String hint;
private final File hintFile;
private final Writer out;
private final boolean failOnWarnings;
- public GlobalConfiguration(Preferences configurationPreferences, boolean apply, boolean runDeclarative, boolean runDeclarativeTests, String hint, File hintFile, Writer out, boolean failOnWarnings) {
+ public GlobalConfiguration(Preferences configurationPreferences, boolean apply, boolean runDeclarative, boolean runDeclarativeTests, boolean useDefaultEnabledSetting, String hint, File hintFile, Writer out, boolean failOnWarnings) {
this.configurationPreferences = configurationPreferences;
this.apply = apply;
this.runDeclarative = runDeclarative;
this.runDeclarativeTests = runDeclarativeTests;
+ this.useDefaultEnabledSetting = useDefaultEnabledSetting;
this.hint = hint;
this.hintFile = hintFile;
this.out = out;
@@ -1067,4 +1076,27 @@ public class Main {
}
+ @ServiceProvider(service=ClassPathProvider.class, position=9999/*DefaultClassPathProvider has 10000*/)
+ public static final class BCPFallBack implements ClassPathProvider {
+
+ @Override
+ public ClassPath findClassPath(FileObject file, String type) {
+ //hack, TestClassPathProvider does not have a reasonable position:
+ for (ClassPathProvider p : Lookup.getDefault().lookupAll(ClassPathProvider.class)) {
+ if (p instanceof TestClassPathProvider) {
+ ClassPath cp = ((TestClassPathProvider) p).findClassPath(file, type);
+
+ if (cp != null) {
+ return cp;
+ }
+ }
+ }
+
+ if (ClassPath.BOOT.equals(type)) {
+ return Utils.createDefaultBootClassPath();
+ }
+ return null;
+ }
+
+ }
}
diff --git a/cmdline/ap/src/org/netbeans/modules/jackpot30/ap/ProcessorImpl.java b/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/ProcessorImpl.java
similarity index 53%
rename from cmdline/ap/src/org/netbeans/modules/jackpot30/ap/ProcessorImpl.java
rename to cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/ProcessorImpl.java
index 8e479ae..74784bc 100644
--- a/cmdline/ap/src/org/netbeans/modules/jackpot30/ap/ProcessorImpl.java
+++ b/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/ProcessorImpl.java
@@ -16,21 +16,31 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.netbeans.modules.jackpot30.ap;
+package org.netbeans.modules.jackpot30.cmdline;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.Tree;
+import com.sun.source.util.JavacTask;
import com.sun.source.util.SourcePositions;
+import com.sun.source.util.TaskEvent;
+import com.sun.source.util.TaskListener;
import com.sun.source.util.TreePath;
import com.sun.source.util.TreePathScanner;
import com.sun.source.util.Trees;
+import com.sun.tools.javac.comp.Resolve;
+import com.sun.tools.javac.util.Context;
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
+import java.net.URI;
import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -44,7 +54,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.AbstractPreferences;
import java.util.prefs.BackingStoreException;
-import java.util.prefs.Preferences;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
@@ -71,11 +80,12 @@ import org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker;
import org.netbeans.modules.java.hints.spiimpl.options.HintsSettings;
import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
import org.netbeans.spi.editor.hints.ErrorDescription;
-import org.netbeans.spi.editor.hints.Severity;
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
+import org.netbeans.spi.java.hints.Hint;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.filesystems.URLMapper;
+import org.openide.util.Exceptions;
import org.openide.util.Lookup;
/**
@@ -87,144 +97,162 @@ import org.openide.util.Lookup;
public class ProcessorImpl extends AbstractProcessor {
public static final String CONFIGURATION_OPTION = "hintsConfiguration";
- private final Map<URL, String> sources = new HashMap<>();
+ private final Map<URL, CompilationUnitTree> sources = new HashMap<>();
+ private static final Logger TOP_LOGGER = Logger.getLogger("");
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- final Trees trees = Trees.instance(processingEnv);
if (!roundEnv.processingOver()) {
+ Trees trees = Trees.instance(processingEnv);
for (Element root : roundEnv.getRootElements()) {
TypeElement outtermost = outtermostType(root);
TreePath path = trees.getPath(outtermost);
-
if (path == null) {
//TODO: log
continue;
}
-
try {
- sources.put(path.getCompilationUnit().getSourceFile().toUri().toURL(), outtermost.getQualifiedName().toString());
+ sources.put(path.getCompilationUnit().getSourceFile().toUri().toURL(), path.getCompilationUnit());
} catch (MalformedURLException ex) {
processingEnv.getMessager().printMessage(Kind.ERROR, "Unexpected exception: " + ex.getMessage());
Logger.getLogger(ProcessorImpl.class.getName()).log(Level.SEVERE, null, ex);
}
}
} else {
- try {
- Field contextField = processingEnv.getClass().getDeclaredField("context");
- contextField.setAccessible(true);
- Object context = contextField.get(processingEnv);
- Method get = context.getClass().getDeclaredMethod("get", Class.class);
- JavaFileManager fileManager = (JavaFileManager) get.invoke(context, JavaFileManager.class);
-
- if (!(fileManager instanceof StandardJavaFileManager)) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "The file manager is not a StandardJavaFileManager, cannot run Jackpot 3.0.");
- return false;
+ JavacTask.instance(processingEnv).addTaskListener(new TaskListener() {
+ @Override
+ public void started(TaskEvent e) {}
+ @Override
+ public void finished(TaskEvent evt) {
+ if (evt.getKind() == TaskEvent.Kind.ENTER) {
+ runHints();
+ }
}
- setupCache();
+ });
+ }
- StandardJavaFileManager sfm = (StandardJavaFileManager) fileManager;
+ return false;
+ }
- ClassPath bootCP = toClassPath(sfm.getLocation(StandardLocation.PLATFORM_CLASS_PATH));
- ClassPath compileCP = toClassPath(sfm.getLocation(StandardLocation.CLASS_PATH));
- Iterable<? extends File> sourcePathLocation = sfm.getLocation(StandardLocation.SOURCE_PATH);
- ClassPath sourceCP = sourcePathLocation != null ? toClassPath(sourcePathLocation) : inferSourcePath();
+ private void runHints() {
+ Trees trees = Trees.instance(processingEnv);
+ Level originalLoggerLevel = TOP_LOGGER.getLevel();
+ Path toDelete = null;
+ try {
+ TOP_LOGGER.setLevel(Level.OFF);
+ System.setProperty("RepositoryUpdate.increasedLogLevel", "OFF");
+ Field contextField = processingEnv.getClass().getDeclaredField("context");
+ contextField.setAccessible(true);
+ Object context = contextField.get(processingEnv);
+ Method get = context.getClass().getDeclaredMethod("get", Class.class);
+ JavaFileManager fileManager = (JavaFileManager) get.invoke(context, JavaFileManager.class);
+
+ if (!(fileManager instanceof StandardJavaFileManager)) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "The file manager is not a StandardJavaFileManager, cannot run Jackpot 3.0.");
+ return ;
+ }
- final Map<FileObject, String> sourceFiles = new HashMap<>();
+ setupCache();
- for (Entry<URL, String> e : sources.entrySet()) {
- FileObject fo = URLMapper.findFileObject(e.getKey());
- if (fo == null) {
- //XXX:
- return false;
- }
- sourceFiles.put(fo, e.getValue());
- }
+ StandardJavaFileManager sfm = (StandardJavaFileManager) fileManager;
+
+ ClassPath bootCP = /*XXX*/Utils.createDefaultBootClassPath();//toClassPath(sfm.getLocation(StandardLocation.PLATFORM_CLASS_PATH));
+ ClassPath compileCP = toClassPath(sfm.getLocation(StandardLocation.CLASS_PATH));
+ Iterable<? extends File> sourcePathLocation = sfm.getLocation(StandardLocation.SOURCE_PATH);
+ ClassPath sourceCP = sourcePathLocation != null ? toClassPath(sourcePathLocation) : inferSourcePath();
- final Map<HintMetadata, ? extends Collection<? extends HintDescription>> allHints = RulesManager.getInstance().readHints(null, Arrays.asList(bootCP, compileCP, sourceCP), new AtomicBoolean());
- List<HintDescription> hints = new ArrayList<>();
- for (Collection<? extends HintDescription> v : allHints.values()) {
- hints.addAll(v);
+ final Map<FileObject, CompilationUnitTree> sourceFiles = new HashMap<>();
+
+ for (Entry<URL, CompilationUnitTree> e : sources.entrySet()) {
+ FileObject fo = URLMapper.findFileObject(e.getKey());
+ if (fo == null) {
+ //XXX:
+ return ;
}
- final Map<String, String> id2DisplayName = Utils.computeId2DisplayName(hints);
- final Map<HintMetadata, ? extends Collection<? extends HintDescription>> hardcodedHints = RulesManager.getInstance().readHints(null, null, new AtomicBoolean());
- final HintsSettings settings;
- String configurationFileLoc = processingEnv.getOptions().get(CONFIGURATION_OPTION);
- File configurationFile = configurationFileLoc != null ? new File(configurationFileLoc) : null;
-
- if (configurationFile == null || !configurationFile.canRead()) {
- settings = new HintsSettings() {
-
- @Override
- public boolean isEnabled(HintMetadata hm) {
- return !hardcodedHints.containsKey(hm) ? hm.enabled : false;
- }
+ sourceFiles.put(fo, e.getValue());
+ }
- @Override
- public void setEnabled(HintMetadata hm, boolean bln) {
- throw new UnsupportedOperationException();
- }
+ URI settingsURI;
+ String configurationFileLoc = processingEnv.getOptions().get(CONFIGURATION_OPTION);
+ File configurationFile = configurationFileLoc != null ? new File(configurationFileLoc) : null;
+
+ if (configurationFile == null || !configurationFile.canRead()) {
+ URL cfg = ProcessorImpl.class.getResource("/org/netbeans/modules/jackpot30/cmdline/cfg_hints.xml");
+ Path tmp = Files.createTempFile("cfg_hints", "xml"); //TODO: delete
+ try (InputStream cfgIn = cfg.openStream();
+ OutputStream out = Files.newOutputStream(tmp)) {
+ int read;
+ while ((read = cfgIn.read()) != (-1))
+ out.write(read);
+ }
+ settingsURI = tmp.toUri();
+ toDelete = tmp;
+ } else {
+ settingsURI = configurationFile.toURI();
+ }
- @Override
- public Preferences getHintPreferences(HintMetadata hm) {
- return new DummyPreferences(null, "");
- }
+ HintsSettings settings = HintsSettings.createPreferencesBasedHintsSettings(ToolPreferences.from(settingsURI).getPreferences("hints", "text/x-java"), true, null);
- @Override
- public Severity getSeverity(HintMetadata hm) {
- return hm.severity;
- }
+ final Map<HintMetadata, ? extends Collection<? extends HintDescription>> allHints = RulesManager.getInstance().readHints(null, Arrays.asList(bootCP, compileCP, sourceCP), new AtomicBoolean());
+ List<HintDescription> hints = new ArrayList<>();
- @Override
- public void setSeverity(HintMetadata hm, Severity svrt) {
- throw new UnsupportedOperationException();
- }
- };
- } else {
- settings = HintsSettings.createPreferencesBasedHintsSettings(ToolPreferences.from(configurationFile.toURI()).getPreferences("hints", "text/x-java"), true, null);
+ for (Entry<HintMetadata, ? extends Collection<? extends HintDescription>> e : allHints.entrySet()) {
+ if (settings.isEnabled(e.getKey()) && e.getKey().kind == Hint.Kind.INSPECTION && !e.getKey().options.contains(HintMetadata.Options.NO_BATCH)) {
+ hints.addAll(e.getValue());
}
+ }
+ final Map<String, String> id2DisplayName = Utils.computeId2DisplayName(hints);
+ ClasspathInfo cpInfo = new ClasspathInfo.Builder(bootCP).setClassPath(compileCP).setSourcePath(sourceCP).setModuleBootPath(bootCP).build();
- ClasspathInfo cpInfo = ClasspathInfo.create(bootCP, compileCP, sourceCP);
+ JavaSource.create(cpInfo, sourceFiles.keySet()).runUserActionTask(new Task<CompilationController>() {
- JavaSource.create(cpInfo, sourceFiles.keySet()).runUserActionTask(new Task<CompilationController>() {
+ @Override
+ public void run(CompilationController parameter) throws Exception {
+ if (parameter.toPhase(JavaSource.Phase.RESOLVED).compareTo(JavaSource.Phase.RESOLVED) < 0) {
+ return;
+ }
- @Override
- public void run(CompilationController parameter) throws Exception {
- if (parameter.toPhase(JavaSource.Phase.RESOLVED).compareTo(JavaSource.Phase.RESOLVED) < 0) {
- return;
- }
+ List<ErrorDescription> eds = new HintsInvoker(settings, /*XXX*/new AtomicBoolean()).computeHints(parameter, hints);
- List<ErrorDescription> eds = new HintsInvoker(settings, /*XXX*/new AtomicBoolean()).computeHints(parameter);
-
- if (eds != null) {
- for (ErrorDescription ed : eds) {
- String outtermost = sourceFiles.get(ed.getFile());
- TypeElement type = processingEnv.getElementUtils().getTypeElement(outtermost); //XXX: package-info!!!
- TreePath typePath = trees.getPath(type);
- TreePath posPath = pathFor(typePath.getCompilationUnit(), trees.getSourcePositions(), ed.getRange().getBegin().getOffset());
- String category = Utils.categoryName(ed.getId(), id2DisplayName);
- Kind diagKind;
- switch (ed.getSeverity()) {
- case ERROR: diagKind = Kind.ERROR; break;
- case VERIFIER:
- case WARNING: diagKind = Kind.WARNING; break;
- case HINT:
- default: diagKind = Kind.NOTE; break;
- }
- trees.printMessage(diagKind, category + ed.getDescription(), posPath.getLeaf(), posPath.getCompilationUnit());
+ if (eds != null) {
+ //TODO: sort errors!!!
+ for (ErrorDescription ed : eds) {
+ CompilationUnitTree originalUnit = sourceFiles.get(ed.getFile());
+ if (originalUnit == null) {
+ //XXX: log properly!!!
+ continue;
+ }
+ TreePath posPath = pathFor(originalUnit, trees.getSourcePositions(), ed.getRange().getBegin().getOffset());
+ String category = Utils.categoryName(ed.getId(), id2DisplayName);
+ Kind diagKind;
+ switch (ed.getSeverity()) {
+ case ERROR: diagKind = Kind.ERROR; break;
+ case VERIFIER:
+ case WARNING: diagKind = Kind.WARNING; break;
+ case HINT:
+ default: diagKind = Kind.NOTE; break;
}
+ trees.printMessage(diagKind, category + ed.getDescription(), posPath.getLeaf(), posPath.getCompilationUnit());
}
}
- }, true);
- } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException | NoSuchMethodException | InvocationTargetException | IOException ex) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "Unexpected exception: " + ex.getMessage());
- Logger.getLogger(ProcessorImpl.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }, true);
+ } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException | NoSuchMethodException | InvocationTargetException | IOException ex) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Unexpected exception: " + ex.getMessage());
+ Logger.getLogger(ProcessorImpl.class.getName()).log(Level.SEVERE, null, ex);
+ } finally {
+ TOP_LOGGER.setLevel(originalLoggerLevel);
+ if (toDelete != null) {
+ try {
+ Files.delete(toDelete);
+ } catch (IOException ex) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Unexpected exception: " + ex.getMessage());
+ Logger.getLogger(ProcessorImpl.class.getName()).log(Level.SEVERE, null, ex);
+ }
}
}
-
- return false;
}
private static ClassPath toClassPath(Iterable<? extends File> files) throws MalformedURLException {
@@ -257,9 +285,11 @@ public class ProcessorImpl extends AbstractProcessor {
}
private TypeElement outtermostType(Element el) {
- while (el.getEnclosingElement().getKind() != ElementKind.PACKAGE) { //XXX: package-info!
+ while (/*XXX: package/module-info!*/el.getEnclosingElement() != null && el.getEnclosingElement().getKind() != ElementKind.PACKAGE) {
el = el.getEnclosingElement();
}
+ if (el.getKind() == ElementKind.PACKAGE || el.getKind().name().equals("MODULE"))
+ return null;
return (TypeElement) el;
}
@@ -292,13 +322,14 @@ public class ProcessorImpl extends AbstractProcessor {
private ClassPath inferSourcePath() {
if (sources.isEmpty())
return ClassPath.EMPTY;
- Entry<URL, String> e = sources.entrySet().iterator().next();
+ Entry<URL, CompilationUnitTree> e = sources.entrySet().iterator().next();
FileObject sourceRoot = URLMapper.findFileObject(e.getKey());
if (sourceRoot == null) {
//unexpected
return ClassPath.EMPTY;
}
- for (String part : e.getValue().split("\\.")) {
+ sourceRoot = sourceRoot.getParent();
+ for (String part : e.getValue().getPackageName().toString().split("\\.")) {
sourceRoot = sourceRoot.getParent();
}
return ClassPathSupport.createClassPath(sourceRoot);
@@ -319,6 +350,15 @@ public class ProcessorImpl extends AbstractProcessor {
}
}
+ private static final class ModuleAndClass {
+ public final String module;
+ public final String name;
+ public ModuleAndClass(String module, String name) {
+ this.module = module;
+ this.name = name;
+ }
+ }
+
private static final class DummyPreferences extends AbstractPreferences {
private final Map<String, String> values = new HashMap<>();
diff --git a/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/cfg_hints.xml b/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/cfg_hints.xml
new file mode 100644
index 0000000..76c8954
--- /dev/null
+++ b/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/cfg_hints.xml
@@ -0,0 +1,241 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE configuration PUBLIC "-//NetBeans//DTD Tool Configuration 1.0//EN" "http://www.netbeans.org/dtds/ToolConfiguration-1_0.dtd">
+<configuration>
+ <tool kind="hints" type="text/x-java">
+ <node name="org.netbeans.modules.java.hints.IncompatibleMask">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.ShiftOutOfRange">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.PointlessBitwiseExpression">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.ClassStructure.finalPrivateMethod">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.jdk.ConvertToStringSwitch">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.perf.SizeEqualsZero">
+ <attribute name="check.not.equals" value="true"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.finalize.FinalizeDeclared">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="o.n.m.j2ee.jpa.verification.NoIdClassOnEntitySubclass">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="Javac_canUseDiamond">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.apisupport.hints.HelpCtxHint">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="o.n.m.j2ee.jpa.verification.IdClassOverridesEqualsAndHashCode">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.jdk.UnnecessaryBoxing.run">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="o.n.m.j2ee.jpa.verification.HasNoArgConstructor">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="o.n.m.j2ee.jpa.verification.QueriesProperlyDefined">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.jdk.JoinCatches">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="Imports_DEFAULT_PACKAGE">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.errors.ErrorFixesFakeHintCREATE_FINAL_FIELD_CTOR">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.suggestions.ConstantNameHint">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="o.n.m.j2ee.jpa.verification.OnlyEntityOrMappedSuperclassCanUseIdClass">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.ExportNonAccessibleElement">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="Imports_EXCLUDED">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="o.n.m.j2ee.jpa.verification.ValidAttributes">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="o.n.m.j2ee.jpa.verification.IdDefinedInHierarchy">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.SuspiciousNamesCombination">
+ <attribute name="groups" value="x, width|y, height"/>
+ </node>
+ <node name="o.n.m.j2ee.jpa.verification.NonFinalClass">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.jdk.IndexOfToContains">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.LoggerNotStaticFinal">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.errors.ErrorFixesFakeHintSURROUND_WITH_TRY_CATCH">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.jackpot.hintsimpl.LoggerStringConcat">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.jdk.UseSpecificCatch">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="o.n.m.j2ee.jpa.verification.PublicClass">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.MultipleLoggers">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="EmptyStatements_WHILE_LOOP">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="create-javadoc">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.suggestions.ConvertIfToSwitch">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.perf.Tiny.constantIntern">
+ <attribute name="enabled" value="true"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.testing.Tiny.assertEqualsForArrays">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.jdk.ConvertToARM">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="EmptyStatements_DO_WHILE_LOOP">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.StaticNonFinalUsedInInitialization">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.testing.Tiny.incovertibleTypes">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="o.n.m.j2ee.jpa.verification.JPAAnnotsOnlyOnAccesor">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="o.n.m.j2ee.jpa.verification.LegalCombinationOfAnnotations">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.bugs.NPECheck">
+ <attribute name="unboxing-unknown" value="false"/>
+ <attribute name="enable-for-fields" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.jdk.IteratorToFor">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="o.n.m.j2ee.jpa.verification.ValidPrimaryTableName">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.testing.Tiny.mismatchedConstantVSReal">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="EmptyStatements_FOR_LOOP">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="o.n.m.j2ee.jpa.verification.SerializableClass">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="o.n.m.j2ee.jpa.verification.PersistenceUnitPresent">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="EmptyStatements_BLOCK">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.finalize.FinalizeDoesNotCallSuper">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="Javac_canUseLambda">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.perf.Tiny.getClassInsteadOfDotClass">
+ <attribute name="enabled" value="true"/>
+ </node>
+ <node name="Imports_SAME_PACKAGE">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="Imports_UNUSED">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="Inspection.hint">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.errors.ErrorFixesFakeHintCREATE_LOCAL_VARIABLE">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.apisupport.hints.UseNbBundleMessages">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.LeakingThisInConstructor">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.InitializerCanBeStatic">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.OverridableMethodCallInConstructor">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="o.n.m.j2ee.jpa.verification.UniqueEntityName">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.errors.ErrorFixesFakeHintIMPORT_CLASS">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.jdk.ConvertToVarHint">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="o.n.m.j2ee.jpa.verification.TopLevelClass">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.ObsoleteCollection">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.jdk.ConvertVarToExplicitType">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.finalize.CallFinalize">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.jdk.UnnecessaryUnboxing">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="o.n.m.j2ee.jpa.verification.JPQLValidation">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="MAVEN_SEARCH_HINT">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.jdk.AnnotationProcessors.oGSA">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="o.n.m.j2ee.jpa.verification.ConsistentAccessType">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="error-in-javadoc">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.AddOverrideAnnotation">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="AnnotationAsSuperInterface">
+ <attribute name="enabled" value="false"/>
+ </node>
+ <node name="org.netbeans.modules.java.hints.perf.Tiny.stringEqualsEmpty">
+ <attribute name="enabled" value="true"/>
+ </node>
+ </tool>
+</configuration>
diff --git a/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/CreateTool.java b/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/CreateTool.java
index 9388d1f..1418643 100644
--- a/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/CreateTool.java
+++ b/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/CreateTool.java
@@ -19,6 +19,8 @@
package org.netbeans.modules.jackpot30.cmdline;
import java.util.regex.Pattern;
+import javax.annotation.processing.Processor;
+import org.netbeans.modules.jackpot30.cmdline.Main.BCPFallBack;
import org.netbeans.modules.jackpot30.cmdline.lib.CreateStandaloneJar;
import org.netbeans.modules.jackpot30.cmdline.lib.CreateStandaloneJar.Info;
import org.netbeans.modules.java.hints.declarative.PatternConvertorImpl;
@@ -27,6 +29,7 @@ import org.netbeans.modules.java.hints.jackpot.spi.PatternConvertor;
import org.netbeans.modules.java.j2seproject.J2SEProject;
import org.netbeans.modules.java.platform.DefaultJavaPlatformProvider;
import org.netbeans.modules.project.ui.OpenProjectsTrampolineImpl;
+import org.netbeans.spi.java.classpath.ClassPathProvider;
/**
*
@@ -40,13 +43,14 @@ public class CreateTool extends CreateStandaloneJar {
@Override
protected Info computeInfo() {
- return new Info().addAdditionalRoots(Main.class.getName(), DeclarativeHintsTestBase.class.getName(), OpenProjectsTrampolineImpl.class.getName(), J2SEProject.class.getName(), DefaultJavaPlatformProvider.class.getName(), PatternConvertorImpl.class.getName())
- .addAdditionalResources("org/netbeans/modules/java/hints/resources/Bundle.properties", "org/netbeans/modules/java/hints/declarative/resources/Bundle.properties")
+ return new Info().addAdditionalRoots(Main.class.getName(), DeclarativeHintsTestBase.class.getName(), OpenProjectsTrampolineImpl.class.getName(), J2SEProject.class.getName(), DefaultJavaPlatformProvider.class.getName(), PatternConvertorImpl.class.getName(), ProcessorImpl.class.getName(), BCPFallBack.class.getName())
+ .addAdditionalResources("org/netbeans/modules/java/hints/resources/Bundle.properties", "org/netbeans/modules/java/hints/declarative/resources/Bundle.properties", "org/netbeans/modules/jackpot30/cmdline/cfg_hints.xml")
.addAdditionalLayers("org/netbeans/modules/java/hints/resources/layer.xml", "org/netbeans/modules/java/hints/declarative/resources/layer.xml")
.addMetaInfRegistrations(new MetaInfRegistration(org.netbeans.modules.project.uiapi.OpenProjectsTrampoline.class, OpenProjectsTrampolineImpl.class))
+ .addMetaInfRegistrations(new MetaInfRegistration(Processor.class, ProcessorImpl.class))
+ .addMetaInfRegistrations(new MetaInfRegistration(ClassPathProvider.class.getName(), BCPFallBack.class.getName(), 9999))
.addMetaInfRegistrationToCopy(PatternConvertor.class.getName())
- .addExcludePattern(Pattern.compile("junit\\.framework\\..*"))
- .setEscapeJavaxLang();
+ .addExcludePattern(Pattern.compile("junit\\.framework\\..*"));
}
}
diff --git a/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/CreateToolTest.java b/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/CreateToolProcessorTest.java
similarity index 58%
copy from cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/CreateToolTest.java
copy to cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/CreateToolProcessorTest.java
index 6db5b71..49f55ee 100644
--- a/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/CreateToolTest.java
+++ b/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/CreateToolProcessorTest.java
@@ -23,17 +23,11 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import java.util.Set;
import junit.extensions.TestSetup;
import junit.framework.Test;
-import org.hamcrest.Condition;
-import org.junit.runner.JUnitCore;
import org.netbeans.junit.NbTestSuite;
import org.openide.filesystems.FileUtil;
import org.openide.util.Exceptions;
@@ -42,28 +36,28 @@ import org.openide.util.Exceptions;
*
* @author lahvac
*/
-public class CreateToolTest extends MainTest {
+public class CreateToolProcessorTest extends ProcessorImplTest {
- public CreateToolTest(String name) {
+ public CreateToolProcessorTest(String name) {
super(name);
}
private static File compiler;
@Override
- protected void reallyRunCompiler(File workingDir, int exitcode, String[] output, String... params) throws Exception {
+ protected void reallyRunCompiler(File workDir, int exitcode, String[] output, String... params) throws Exception {
assertNotNull(compiler);
List<String> ll = new LinkedList<String>();
- ll.add("java");
- ll.add("-Xbootclasspath/p:" + compiler.getAbsolutePath());
+ ll.addAll(Utils.findJavacLauncher());
-// ll.add("-Xdebug");
-// ll.add("-Xrunjdwp:transport=dt_socket,suspend=y,server=y,address=8889");
+// ll.add("-J-Xdebug");
+// ll.add("-J-Xrunjdwp:transport=dt_socket,suspend=y,server=y,address=8889");
- ll.add("org.netbeans.modules.jackpot30.cmdline.Main");
+ ll.add("-classpath"); ll.add(compiler.getAbsolutePath());
ll.addAll(Arrays.asList(params));
+ System.err.println("ll=" + ll);
try {
- Process p = Runtime.getRuntime().exec(ll.toArray(new String[0]), null, workingDir);
+ Process p = Runtime.getRuntime().exec(ll.toArray(new String[0]), null, workDir);
CopyStream outCopy = new CopyStream(p.getInputStream(), output, 0);
CopyStream errCopy = new CopyStream(p.getErrorStream(), output, 1);
@@ -78,55 +72,6 @@ public class CreateToolTest extends MainTest {
throw new IOException(t);
}
}
-
- private static final Set<String> MUST_CONTAIN = new HashSet<String>(Arrays.asList(" 1 failure", "/h.test/neg", "Tests run: 2, Failures: 1"));
- private static final Set<String> MUST_NOT_CONTAIN = new HashSet<String>(Arrays.asList("/h.test/pos"));
-
- @Override
- protected void runAndTest(File classes) throws Exception {
- List<String> ll = new LinkedList<String>();
- ll.add("java");
- ll.add("-classpath");
- ll.add(compiler.getAbsolutePath() + File.pathSeparator + classes.getAbsolutePath() + File.pathSeparator + new File(JUnitCore.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getAbsolutePath() + File.pathSeparator + new File(Condition.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getAbsolutePath());
-
-// ll.add("-Xdebug");
-// ll.add("-Xrunjdwp:transport=dt_socket,suspend=y,server=y,address=8889");
-
- ll.add("org.junit.runner.JUnitCore");
- ll.add("org.netbeans.modules.jackpot30.cmdline.testtool.DoRunTests");
-
- System.err.println("ll=" + ll);
- Process p = Runtime.getRuntime().exec(ll.toArray(new String[0]), null, getWorkDir());
- String[] output = new String[2];
- CopyStream outCopy = new CopyStream(p.getInputStream(), output, 0);
- CopyStream errCopy = new CopyStream(p.getErrorStream(), output, 1);
-
- outCopy.start();
- errCopy.start();
-
- p.waitFor();
-
- outCopy.doJoin();
- errCopy.doJoin();
-
- Set<String> mustContainCopy = new HashSet<String>(MUST_CONTAIN);
-
- System.err.println(output[0]);
- System.err.println(output[1]);
-
- verify(output[0], mustContainCopy);
- verify(output[1], mustContainCopy);
- }
-
- private void verify(String output, Set<String> mustContainCopy) {
- for (Iterator<String> it = mustContainCopy.iterator(); it.hasNext();) {
- assertTrue(output.contains(it.next()));
- it.remove();
- }
- for (String nc : MUST_NOT_CONTAIN) {
- assertFalse(output.contains(nc));
- }
- }
private static final class CopyStream extends Thread {
private final InputStream ins;
@@ -166,8 +111,8 @@ public class CreateToolTest extends MainTest {
public static Test suite() {
NbTestSuite suite = new NbTestSuite();
-
- suite.addTestSuite(CreateToolTest.class);
+
+ suite.addTestSuite(CreateToolProcessorTest.class);
return new TestSetup(suite) {
private File hintsList;
diff --git a/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/CreateToolTest.java b/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/CreateToolTest.java
index 6db5b71..2e3fe02 100644
--- a/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/CreateToolTest.java
+++ b/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/CreateToolTest.java
@@ -23,7 +23,6 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
@@ -54,8 +53,8 @@ public class CreateToolTest extends MainTest {
protected void reallyRunCompiler(File workingDir, int exitcode, String[] output, String... params) throws Exception {
assertNotNull(compiler);
List<String> ll = new LinkedList<String>();
- ll.add("java");
- ll.add("-Xbootclasspath/p:" + compiler.getAbsolutePath());
+ ll.addAll(Utils.findJavaLauncher());
+ ll.add("-classpath"); ll.add(compiler.getAbsolutePath());
// ll.add("-Xdebug");
// ll.add("-Xrunjdwp:transport=dt_socket,suspend=y,server=y,address=8889");
@@ -85,7 +84,7 @@ public class CreateToolTest extends MainTest {
@Override
protected void runAndTest(File classes) throws Exception {
List<String> ll = new LinkedList<String>();
- ll.add("java");
+ ll.addAll(Utils.findJavaLauncher());
ll.add("-classpath");
ll.add(compiler.getAbsolutePath() + File.pathSeparator + classes.getAbsolutePath() + File.pathSeparator + new File(JUnitCore.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getAbsolutePath() + File.pathSeparator + new File(Condition.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getAbsolutePath());
diff --git a/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/MainTest.java b/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/MainTest.java
index ed7bfbf..f8db885 100644
--- a/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/MainTest.java
+++ b/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/MainTest.java
@@ -21,9 +21,7 @@ package org.netbeans.modules.jackpot30.cmdline;
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.PrintStream;
import java.net.URI;
import java.net.URISyntaxException;
@@ -38,9 +36,7 @@ import java.util.regex.Pattern;
import javax.tools.SimpleJavaFileObject;
import javax.tools.ToolProvider;
import org.junit.runner.Result;
-import org.netbeans.api.java.source.TestUtilities;
import org.netbeans.junit.NbTestCase;
-import org.openide.filesystems.FileUtil;
/**XXX: should also test error conditions
*
@@ -195,11 +191,51 @@ public class MainTest extends NbTestCase {
"}\n",
"settings.xml",
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
- "<hints apply=\"true\">\n" +
- " <settings>\n" +
- " <org.netbeans.modules.java.hints.perf.SizeEqualsZero check.not.equals=\"false\" enabled=\"true\" hintSeverity=\"VERIFIER\"/>\n" +
- " </settings>\n" +
- "</hints>\n",
+ "<!DOCTYPE configuration PUBLIC \"-//NetBeans//DTD Tool Configuration 1.0//EN\" \"http://www.netbeans.org/dtds/ToolConfiguration-1_0.dtd\">\n" +
+ "<configuration>\n" +
+ " <tool kind=\"hints\" type=\"text/x-java\">\n" +
+ " <node name=\"org.netbeans.modules.java.hints.perf.SizeEqualsZero\">\n" +
+ " <attribute name=\"enabled\" value=\"true\"/>\n" +
+ " </node>\n" +
+ " </tool>\n" +
+ " <tool kind=\"standalone\" type=\"text/x-java\">\n" +
+ " <attribute name=\"apply\" value=\"true\"/>\n" +
+ " </tool>\n" +
+ "</configuration>\n",
+ null,
+ "--config-file",
+ "${workdir}/settings.xml",
+ "--source",
+ "1.6");
+ }
+
+ public void testConfigurationFileDisable() throws Exception {
+ String golden =
+ "package test;\n" +
+ "public class Test {\n" +
+ " private void test(java.util.Collection c) {\n" +
+ " boolean b = c.size() == 0;\n" +
+ " }\n" +
+ "}\n";
+
+ doRunCompiler(golden,
+ null,
+ null,
+ "src/test/Test.java",
+ golden,
+ "settings.xml",
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<!DOCTYPE configuration PUBLIC \"-//NetBeans//DTD Tool Configuration 1.0//EN\" \"http://www.netbeans.org/dtds/ToolConfiguration-1_0.dtd\">\n" +
+ "<configuration>\n" +
+ " <tool kind=\"hints\" type=\"text/x-java\">\n" +
+ " <node name=\"org.netbeans.modules.java.hints.perf.SizeEqualsZero\">\n" +
+ " <attribute name=\"enabled\" value=\"false\"/>\n" +
+ " </node>\n" +
+ " </tool>\n" +
+ " <tool kind=\"standalone\" type=\"text/x-java\">\n" +
+ " <attribute name=\"apply\" value=\"true\"/>\n" +
+ " </tool>\n" +
+ "</configuration>\n",
null,
"--config-file",
"${workdir}/settings.xml",
@@ -230,11 +266,17 @@ public class MainTest extends NbTestCase {
"}\n",
"settings.xml",
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
- "<hints apply=\"true\">\n" +
- " <settings>\n" +
- " <org.netbeans.modules.java.hints.perf.SizeEqualsZero check.not.equals=\"false\" enabled=\"true\" hintSeverity=\"VERIFIER\"/>\n" +
- " </settings>\n" +
- "</hints>\n",
+ "<!DOCTYPE configuration PUBLIC \"-//NetBeans//DTD Tool Configuration 1.0//EN\" \"http://www.netbeans.org/dtds/ToolConfiguration-1_0.dtd\">\n" +
+ "<configuration>\n" +
+ " <tool kind=\"hints\" type=\"text/x-java\">\n" +
+ " <node name=\"org.netbeans.modules.java.hints.perf.SizeEqualsZero\">\n" +
+ " <attribute name=\"enabled\" value=\"true\"/>\n" +
+ " </node>\n" +
+ " </tool>\n" +
+ " <tool kind=\"standalone\" type=\"text/x-java\">\n" +
+ " <attribute name=\"apply\" value=\"true\"/>\n" +
+ " </tool>\n" +
+ "</configuration>\n",
null,
"--config-file",
"${workdir}/settings.xml",
@@ -299,11 +341,66 @@ public class MainTest extends NbTestCase {
"$c.size() <= 0 :: $c instanceof java.util.Collection => $c.isEmpty();;\n",
"settings.xml",
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
- "<hints apply=\"true\" runDeclarative=\"false\">\n" +
- " <settings>\n" +
- " <test1.hint enabled=\"true\"/>\n" +
- " </settings>\n" +
- "</hints>\n",
+ "<!DOCTYPE configuration PUBLIC \"-//NetBeans//DTD Tool Configuration 1.0//EN\" \"http://www.netbeans.org/dtds/ToolConfiguration-1_0.dtd\">\n" +
+ "<configuration>\n" +
+ " <tool kind=\"hints\" type=\"text/x-java\">\n" +
+ " <node name=\"org.netbeans.modules.java.hints.perf.SizeEqualsZero\">\n" +
+ " <attribute name=\"enabled\" value=\"false\"/>\n" +
+ " </node>\n" +
+ " <node name=\"test1.hint\">\n" +
+ " <attribute name=\"enabled\" value=\"true\"/>\n" +
+ " </node>\n" +
+ " </tool>\n" +
+ " <tool kind=\"standalone\" type=\"text/x-java\">\n" +
+ " <attribute name=\"apply\" value=\"true\"/>\n" +
+ " <attribute name=\"runDeclarative\" value=\"false\"/>\n" +
+ " </tool>\n" +
+ "</configuration>\n",
+ null,
+ "--config-file",
+ "${workdir}/settings.xml",
+ "--source",
+ "1.6");
+ }
+
+ public void testConfigurationFileDeclarative1a() throws Exception {
+ String code =
+ "package test;\n" +
+ "public class Test {\n" +
+ " private void test(java.util.Collection c) {\n" +
+ " boolean b1 = c.size() == 0;\n" +
+ " boolean b2 = c.size() <= 0;\n" +
+ " }\n" +
+ "}\n";
+
+ doRunCompiler(code,
+ "${workdir}/src/test/Test.java:4: warning: [test1] test1\n" +
+ " boolean b1 = c.size() == 0;\n" +
+ " ^\n",
+ null,
+ "src/test/Test.java",
+ code,
+ "META-INF/upgrade/test1.hint",
+ "$c.size() == 0 :: $c instanceof java.util.Collection => $c.isEmpty();;\n",
+ "META-INF/upgrade/test2.hint",
+ "$c.size() <= 0 :: $c instanceof java.util.Collection => $c.isEmpty();;\n",
+ "settings.xml",
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<!DOCTYPE configuration PUBLIC \"-//NetBeans//DTD Tool Configuration 1.0//EN\" \"http://www.netbeans.org/dtds/ToolConfiguration-1_0.dtd\">\n" +
+ "<configuration>\n" +
+ " <tool kind=\"hints\" type=\"text/x-java\">\n" +
+ " <node name=\"org.netbeans.modules.java.hints.perf.SizeEqualsZero\">\n" +
+ " <attribute name=\"enabled\" value=\"false\"/>\n" +
+ " </node>\n" +
+ " <node name=\"test1.hint\">\n" +
+ " <attribute name=\"enabled\" value=\"true\"/>\n" +
+ " </node>\n" +
+ " </tool>\n" +
+ " <tool kind=\"standalone\" type=\"text/x-java\">\n" +
+ " <attribute name=\"apply\" value=\"false\"/>\n" +
+ " <attribute name=\"runDeclarative\" value=\"false\"/>\n" +
+ " </tool>\n" +
+ "</configuration>\n",
null,
"--config-file",
"${workdir}/settings.xml",
@@ -338,11 +435,21 @@ public class MainTest extends NbTestCase {
"$c.size() <= 0 :: $c instanceof java.util.Collection => $c.isEmpty();;\n",
"settings.xml",
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
- "<hints apply=\"true\" runDeclarative=\"true\">\n" +
- " <settings>\n" +
- " <test1.hint enabled=\"true\"/>\n" +
- " </settings>\n" +
- "</hints>\n",
+ "<!DOCTYPE configuration PUBLIC \"-//NetBeans//DTD Tool Configuration 1.0//EN\" \"http://www.netbeans.org/dtds/ToolConfiguration-1_0.dtd\">\n" +
+ "<configuration>\n" +
+ " <tool kind=\"hints\" type=\"text/x-java\">\n" +
+ " <node name=\"org.netbeans.modules.java.hints.perf.SizeEqualsZero\">\n" +
+ " <attribute name=\"enabled\" value=\"false\"/>\n" +
+ " </node>\n" +
+ " <node name=\"test1.hint\">\n" +
+ " <attribute name=\"enabled\" value=\"true\"/>\n" +
+ " </node>\n" +
+ " </tool>\n" +
+ " <tool kind=\"standalone\" type=\"text/x-java\">\n" +
+ " <attribute name=\"apply\" value=\"true\"/>\n" +
+ " <attribute name=\"runDeclarative\" value=\"true\"/>\n" +
+ " </tool>\n" +
+ "</configuration>\n",
null,
"--config-file",
"${workdir}/settings.xml",
@@ -517,6 +624,10 @@ public class MainTest extends NbTestCase {
}
public void testAutomaticTestRun() throws Exception {
+ if (System.getProperty("sun.boot.class.path") != null) {
+ //TODO XXX: this test does not pass on JDK 8
+ return ;
+ }
class Config {
private final String commandLineOption;
private final int result;
@@ -667,10 +778,7 @@ public class MainTest extends NbTestCase {
public void testMethodRef() throws Exception {
doRunCompiler(null,
- equivalentValidator("${workdir}/src/test/Test.java:8: warning: [test] test\n" +
- " I3 i3b = String::new;\n" +
- " ^\n" +
- "${workdir}/src/test/Test.java:4: warning: [test] test\n" +
+ equivalentValidator("${workdir}/src/test/Test.java:4: warning: [test] test\n" +
" Runnable r = Test::m1;\n" +
" ^\n" +
"${workdir}/src/test/Test.java:5: warning: [test] test\n" +
@@ -681,6 +789,9 @@ public class MainTest extends NbTestCase {
" ^\n" +
"${workdir}/src/test/Test.java:7: warning: [test] test\n" +
" I3 i3a = String::toLowerCase;\n" +
+ " ^\n" +
+ "${workdir}/src/test/Test.java:8: warning: [test] test\n" +
+ " I3 i3b = String::new;\n" +
" ^\n"),
equivalentValidator(""),
"src/META-INF/upgrade/test.hint",
@@ -752,7 +863,7 @@ public class MainTest extends NbTestCase {
target.getParentFile().mkdirs();
- TestUtilities.copyStringToFile(target, fileAndContent.get(cntr + 1));
+ Utils.copyStringToFile(target, fileAndContent.get(cntr + 1));
}
File wd = getWorkDir();
@@ -761,8 +872,11 @@ public class MainTest extends NbTestCase {
List<String> options = new LinkedList<String>();
boolean appendPath = true;
+ File cache = new File(getWorkDir(), "cache");
+
options.add("--cache");
- options.add("/tmp/cachex");
+ options.add(cache.getAbsolutePath());
+
for (String extraOption : extraOptions) {
if (extraOption == DONT_APPEND_PATH) {
appendPath = false;
@@ -782,7 +896,7 @@ public class MainTest extends NbTestCase {
reallyRunCompiler(wd, exitcode, output, options.toArray(new String[0]));
if (fileContentValidator != null) {
- fileContentValidator.validate(TestUtilities.copyFileToString(source));
+ fileContentValidator.validate(Utils.copyFileToString(source));
}
if (stdOutValidator != null) {
stdOutValidator.validate(output[0].replaceAll(Pattern.quote(wd.getAbsolutePath()), Matcher.quoteReplacement("${workdir}")));
@@ -839,7 +953,7 @@ public class MainTest extends NbTestCase {
File classes = new File(wd, "classes");
classes.mkdirs();
- TestUtilities.copyStringToFile(new File(classes, "h.hint"), "$1.equals(\"\") :: $1 instanceof java.lang.String => $1.isEmpty();;");
+ Utils.copyStringToFile(new File(classes, "h.hint"), "$1.equals(\"\") :: $1 instanceof java.lang.String => $1.isEmpty();;");
String test = "%%TestCase pos\n" +
"package test;\n" +
@@ -861,9 +975,9 @@ public class MainTest extends NbTestCase {
"public class Test {{\n" +
" System.err.println(\"a\".isEmpty());\n" +
"}}\n";
- TestUtilities.copyStringToFile(new File(classes, "h.test"), test);
+ Utils.copyStringToFile(new File(classes, "h.test"), test);
- List<String> options = Arrays.asList("-d", classes.getAbsolutePath());
+ List<String> options = Arrays.asList("-d", classes.getAbsolutePath(), "-source", "8", "-target", "8");
List<SourceFO> files = Arrays.asList(new SourceFO("DoRunTests.java", CODE_RUN_DECLARATIVE));
assertTrue(ToolProvider.getSystemJavaCompiler().getTask(null, null, null, options, null, files).call());
@@ -871,6 +985,12 @@ public class MainTest extends NbTestCase {
runAndTest(classes);
}
+ @Override
+ protected void setUp() throws Exception {
+ clearWorkDir();
+ super.setUp();
+ }
+
private static final class SourceFO extends SimpleJavaFileObject {
private final String code;
diff --git a/cmdline/ap/test/unit/src/org/netbeans/modules/jackpot30/ap/ProcessorImplTest.java b/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/ProcessorImplTest.java
similarity index 83%
rename from cmdline/ap/test/unit/src/org/netbeans/modules/jackpot30/ap/ProcessorImplTest.java
rename to cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/ProcessorImplTest.java
index eb64413..88c68fd 100644
--- a/cmdline/ap/test/unit/src/org/netbeans/modules/jackpot30/ap/ProcessorImplTest.java
+++ b/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/ProcessorImplTest.java
@@ -16,11 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.netbeans.modules.jackpot30.ap;
+package org.netbeans.modules.jackpot30.cmdline;
import com.sun.tools.javac.Main;
+import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
@@ -31,8 +34,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertTrue;
-import org.netbeans.api.java.source.TestUtilities;
import org.netbeans.junit.NbTestCase;
+import org.openide.filesystems.FileUtil;
/**
*
@@ -46,7 +49,13 @@ public class ProcessorImplTest extends NbTestCase {
public void testHardcoded1() throws Exception {
doRunCompiler("",
- "",
+ "${workdir}/src/test/Test.java:4: warning: [Usage_of_size_equals_0] Usage of .size() == 0 can be replaced with .isEmpty()\n" +
+ " boolean b1 = c.size() == 0;\n" +
+ " ^\n" +
+ "${workdir}/src/test/Test.java:5: warning: [Usage_of_size_equals_0] Usage of .size() == 0 can be replaced with .isEmpty()\n" +
+ "\tboolean b2 = c.size() == 0;\n" +
+ "\t ^\n" +
+ "2 warnings\n",
"src/test/Test.java",
"package test;\n" +
"public class Test {\n" +
@@ -83,6 +92,9 @@ public class ProcessorImplTest extends NbTestCase {
"<!DOCTYPE configuration PUBLIC \"-//NetBeans//DTD Tool Configuration 1.0//EN\" \"http://www.netbeans.org/dtds/ToolConfiguration-1_0.dtd\">\n" +
"<configuration>\n" +
" <tool kind=\"hints\" type=\"text/x-java\">\n" +
+ " <node name=\"org.netbeans.modules.java.hints.jdk.ConvertToVarHint\">\n" +
+ " <attribute name=\"enabled\" value=\"false\"/>\n" +
+ " </node>\n" +
" </tool>\n" +
"</configuration>\n",
null,
@@ -104,13 +116,14 @@ public class ProcessorImplTest extends NbTestCase {
"src/test/Test.java",
"package test;\n" +
"public class Test {\n" +
- " private void test(java.util.Collection c) {\n" +
+ " private void test(Test c) {\n" +
" boolean b1 = c.size() == 0;\n" +
"\tboolean b2 = c.size() == 0;\n" +
" }\n" +
+ " public int size() { return 0; }\n" +
"}\n",
"src/META-INF/upgrade/test.hint",
- "$coll.size() == 0 :: $coll instanceof java.util.Collection;;\n",
+ "$coll.size() == 0 :: $coll test.Test;;\n",
null,
"-source",
"7",
@@ -131,13 +144,14 @@ public class ProcessorImplTest extends NbTestCase {
"src/test/Test.java",
"package test;\n" +
"public class Test {\n" +
- " private void test(java.util.Collection c) {\n" +
+ " private void test(Test c) {\n" +
" boolean b1 = c.size() == 0;\n" +
"\tboolean b2 = c.size() == 0;\n" +
" }\n" +
+ " public int size() { return 0; }\n" +
"}\n",
"src/META-INF/upgrade/test.hint",
- "$coll.size() == 0 :: $coll instanceof java.util.Collection;;\n",
+ "$coll.size() == 0 :: $coll test.Test;;\n",
null,
"-source",
"7",
@@ -164,12 +178,15 @@ public class ProcessorImplTest extends NbTestCase {
List<String> params = new ArrayList<>();
+ params.add("-processor");
+ params.add(ProcessorImpl.class.getName());
+
for (int cntr = 0; cntr < fileAndContent.size(); cntr += 2) {
File target = new File(getWorkDir(), fileAndContent.get(cntr));
target.getParentFile().mkdirs();
- TestUtilities.copyStringToFile(target, fileAndContent.get(cntr + 1));
+ Utils.copyStringToFile(target, fileAndContent.get(cntr + 1));
if (target.getName().endsWith(".java"))
params.add(target.getAbsolutePath());
@@ -179,7 +196,7 @@ public class ProcessorImplTest extends NbTestCase {
File wd = getWorkDir();
String[] output = new String[2];
- reallyRunCompiler(wd, output, params.toArray(new String[0]));
+ reallyRunCompiler(wd, 0, output, params.toArray(new String[0]));
if (stdOut != null) {
assertEquals(stdOut, output[0].replaceAll(Pattern.quote(wd.getAbsolutePath()), Matcher.quoteReplacement("${workdir}")));
@@ -190,7 +207,7 @@ public class ProcessorImplTest extends NbTestCase {
}
}
- protected void reallyRunCompiler(File workDir, String[] output, String... params) throws Exception {
+ protected void reallyRunCompiler(File workDir, int exitcode, String[] output, String... params) throws Exception {
String oldUserDir = System.getProperty("user.dir");
System.setProperty("user.dir", workDir.getAbsolutePath());
@@ -204,7 +221,7 @@ public class ProcessorImplTest extends NbTestCase {
System.setErr(new PrintStream(errData, true, "UTF-8"));
try {
- assertEquals(0, Main.compile(params));
+ assertEquals(exitcode, Main.compile(params));
} finally {
System.setProperty("user.dir", oldUserDir);
System.out.close();
diff --git a/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/Utils.java b/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/Utils.java
new file mode 100644
index 0000000..4d5db0c
--- /dev/null
+++ b/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/Utils.java
@@ -0,0 +1,99 @@
+/**
+ * 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.netbeans.modules.jackpot30.cmdline;
+
+import java.io.ByteArrayInputStream;
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.List;
+import static junit.framework.TestCase.assertNotNull;
+import org.openide.filesystems.FileUtil;
+
+public class Utils {
+
+ public static List<String> findJavaLauncher() {
+ String javaHome = System.getProperty("java.home");
+
+ if (System.getProperty("sun.boot.class.path") != null) {
+ //JDK 8:
+ final String nbJavacPath = System.getProperty("nb.javac.path");
+ assertNotNull("Path to nb-javac must be set in the 'nb.javac.path' property!", nbJavacPath);
+ return Arrays.asList(javaHome + "/bin/java",
+ "-Xbootclasspath/p:" + nbJavacPath);
+ } else {
+ //JDK 9+:
+ return Arrays.asList(javaHome + "/bin/java",
+ "--add-exports=jdk.javadoc/com.sun.tools.javadoc.main=ALL-UNNAMED",
+ "--add-opens=java.base/java.net=ALL-UNNAMED", //stream handler factory
+ "--add-opens=java.desktop/sun.awt=ALL-UNNAMED" //org.openide.util.RequestProcessor$TopLevelThreadGroup to method sun.awt.AppContext.getAppContext()
+ );
+ }
+ }
+
+ public static List<String> findJavacLauncher() {
+ String javaHome = System.getProperty("java.home");
+
+ if (System.getProperty("sun.boot.class.path") != null) {
+ //JDK 8:
+ final String nbJavacPath = System.getProperty("nb.javac.path");
+ assertNotNull("Path to nb-javac must be set in the 'nb.javac.path' property!", nbJavacPath);
+ return Arrays.asList(javaHome + "/../bin/javac",
+ "-J-Xbootclasspath/p:" + nbJavacPath);
+ } else {
+ //JDK 9+:
+ return Arrays.asList(javaHome + "/bin/javac",
+ "-J--add-exports=jdk.javadoc/com.sun.tools.javadoc.main=ALL-UNNAMED",
+ "-J--add-opens=java.base/java.net=ALL-UNNAMED", //stream handler factory
+ "-J--add-opens=java.desktop/sun.awt=ALL-UNNAMED", //org.openide.util.RequestProcessor$TopLevelThreadGroup to method sun.awt.AppContext.getAppContext()
+ "-J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED", //Illegal reflective access by org.netbeans.modules.jackpot30.cmdline.ProcessorImpl to field com.sun.tools.javac.processing.JavacProcessingEnvironment.context
+ "-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" //Illegal reflective access by org.netbeans.modules.jackpot30.cmdline.ProcessorImpl to method com.sun.tools.javac.util.Context.get(java.lang.Class)
+ );
+ }
+ }
+
+ //from TestUtilities:
+ public final static File copyStringToFile (File f, String content) throws Exception {
+ FileOutputStream os = new FileOutputStream(f);
+ InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
+
+ FileUtil.copy(is, os);
+
+ os.close ();
+ is.close();
+
+ return f;
+
+ }
+
+ public final static String copyFileToString (java.io.File f) throws java.io.IOException {
+ int s = (int)f.length ();
+ byte[] data = new byte[s];
+ int len = new FileInputStream (f).read (data);
+
+ if (len != s)
+ throw new EOFException("truncated file");
+
+ return new String (data);
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists