You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by po...@apache.org on 2017/09/03 17:33:41 UTC
[48/51] [partial] incubator-netbeans-jackpot30 git commit:
INFRA-15006 Import for http://bits.netbeans.org/download/apache-donation
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/cmdline/compiler/build.xml
----------------------------------------------------------------------
diff --git a/cmdline/compiler/build.xml b/cmdline/compiler/build.xml
new file mode 100644
index 0000000..9354963
--- /dev/null
+++ b/cmdline/compiler/build.xml
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+
+Copyright 2009-2017 Oracle and/or its affiliates. All rights reserved.
+
+Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+Other names may be trademarks of their respective owners.
+
+The contents of this file are subject to the terms of either the GNU
+General Public License Version 2 only ("GPL") or the Common
+Development and Distribution License("CDDL") (collectively, the
+"License"). You may not use this file except in compliance with the
+License. You can obtain a copy of the License at
+http://www.netbeans.org/cddl-gplv2.html
+or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+specific language governing permissions and limitations under the
+License. When distributing the software, include this License Header
+Notice in each file and include the License file at
+nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+particular file as subject to the "Classpath" exception as provided
+by Oracle in the GPL Version 2 section of the License file that
+accompanied this code. If applicable, add the following below the
+License Header, with the fields enclosed by brackets [] replaced by
+your own identifying information:
+"Portions Copyrighted [year] [name of copyright owner]"
+
+Contributor(s):
+
+The Original Software is NetBeans. The Initial Developer of the Original
+Software is Sun Microsystems, Inc. Portions Copyright 2009-2010 Sun
+Microsystems, Inc. All Rights Reserved.
+
+If you wish your version of this file to be governed by only the CDDL
+or only the GPL Version 2, indicate your decision by adding
+"[Contributor] elects to include this software in this distribution
+under the [CDDL or GPL Version 2] license." If you do not indicate a
+single choice of license, a recipient has the option to distribute
+your version of this file under either the CDDL, the GPL Version 2 or
+to extend the choice of license to its licensees as provided above.
+However, if you add GPL Version 2 code and therefore, elected the GPL
+Version 2 license, then the option applies only if the new code is
+made subject to such option by the copyright holder.
+-->
+<!-- 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>
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/cmdline/compiler/manifest.mf
----------------------------------------------------------------------
diff --git a/cmdline/compiler/manifest.mf b/cmdline/compiler/manifest.mf
new file mode 100644
index 0000000..fa5d74e
--- /dev/null
+++ b/cmdline/compiler/manifest.mf
@@ -0,0 +1,5 @@
+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
+
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/cmdline/compiler/nbproject/build-impl.xml
----------------------------------------------------------------------
diff --git a/cmdline/compiler/nbproject/build-impl.xml b/cmdline/compiler/nbproject/build-impl.xml
new file mode 100644
index 0000000..b230f27
--- /dev/null
+++ b/cmdline/compiler/nbproject/build-impl.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+
+Copyright 2009-2017 Oracle and/or its affiliates. All rights reserved.
+
+Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+Other names may be trademarks of their respective owners.
+
+The contents of this file are subject to the terms of either the GNU
+General Public License Version 2 only ("GPL") or the Common
+Development and Distribution License("CDDL") (collectively, the
+"License"). You may not use this file except in compliance with the
+License. You can obtain a copy of the License at
+http://www.netbeans.org/cddl-gplv2.html
+or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+specific language governing permissions and limitations under the
+License. When distributing the software, include this License Header
+Notice in each file and include the License file at
+nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+particular file as subject to the "Classpath" exception as provided
+by Oracle in the GPL Version 2 section of the License file that
+accompanied this code. If applicable, add the following below the
+License Header, with the fields enclosed by brackets [] replaced by
+your own identifying information:
+"Portions Copyrighted [year] [name of copyright owner]"
+
+Contributor(s):
+
+The Original Software is NetBeans. The Initial Developer of the Original
+Software is Sun Microsystems, Inc. Portions Copyright 2009-2010 Sun
+Microsystems, Inc. All Rights Reserved.
+
+If you wish your version of this file to be governed by only the CDDL
+or only the GPL Version 2, indicate your decision by adding
+"[Contributor] elects to include this software in this distribution
+under the [CDDL or GPL Version 2] license." If you do not indicate a
+single choice of license, a recipient has the option to distribute
+your version of this file under either the CDDL, the GPL Version 2 or
+to extend the choice of license to its licensees as provided above.
+However, if you add GPL Version 2 code and therefore, elected the GPL
+Version 2 license, then the option applies only if the new code is
+made subject to such option by the copyright holder.
+-->
+<!--
+*** 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>
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/cmdline/compiler/nbproject/genfiles.properties
----------------------------------------------------------------------
diff --git a/cmdline/compiler/nbproject/genfiles.properties b/cmdline/compiler/nbproject/genfiles.properties
new file mode 100644
index 0000000..b6e6c2c
--- /dev/null
+++ b/cmdline/compiler/nbproject/genfiles.properties
@@ -0,0 +1,49 @@
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+#
+# Copyright 2009-2017 Oracle and/or its affiliates. All rights reserved.
+#
+# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+# Other names may be trademarks of their respective owners.
+#
+# The contents of this file are subject to the terms of either the GNU
+# General Public License Version 2 only ("GPL") or the Common
+# Development and Distribution License("CDDL") (collectively, the
+# "License"). You may not use this file except in compliance with the
+# License. You can obtain a copy of the License at
+# http://www.netbeans.org/cddl-gplv2.html
+# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+# specific language governing permissions and limitations under the
+# License. When distributing the software, include this License Header
+# Notice in each file and include the License file at
+# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the GPL Version 2 section of the License file that
+# accompanied this code. If applicable, add the following below the
+# License Header, with the fields enclosed by brackets [] replaced by
+# your own identifying information:
+# "Portions Copyrighted [year] [name of copyright owner]"
+#
+# Contributor(s):
+#
+# The Original Software is NetBeans. The Initial Developer of the Original
+# Software is Sun Microsystems, Inc. Portions Copyright 2009-2010 Sun
+# Microsystems, Inc. All Rights Reserved.
+#
+# If you wish your version of this file to be governed by only the CDDL
+# or only the GPL Version 2, indicate your decision by adding
+# "[Contributor] elects to include this software in this distribution
+# under the [CDDL or GPL Version 2] license." If you do not indicate a
+# single choice of license, a recipient has the option to distribute
+# your version of this file under either the CDDL, the GPL Version 2 or
+# to extend the choice of license to its licensees as provided above.
+# However, if you add GPL Version 2 code and therefore, elected the GPL
+# Version 2 license, then the option applies only if the new code is
+# made subject to such option by the copyright holder.
+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
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/cmdline/compiler/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/cmdline/compiler/nbproject/project.properties b/cmdline/compiler/nbproject/project.properties
new file mode 100644
index 0000000..1c15324
--- /dev/null
+++ b/cmdline/compiler/nbproject/project.properties
@@ -0,0 +1,49 @@
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+#
+# Copyright 2009-2017 Oracle and/or its affiliates. All rights reserved.
+#
+# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+# Other names may be trademarks of their respective owners.
+#
+# The contents of this file are subject to the terms of either the GNU
+# General Public License Version 2 only ("GPL") or the Common
+# Development and Distribution License("CDDL") (collectively, the
+# "License"). You may not use this file except in compliance with the
+# License. You can obtain a copy of the License at
+# http://www.netbeans.org/cddl-gplv2.html
+# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+# specific language governing permissions and limitations under the
+# License. When distributing the software, include this License Header
+# Notice in each file and include the License file at
+# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the GPL Version 2 section of the License file that
+# accompanied this code. If applicable, add the following below the
+# License Header, with the fields enclosed by brackets [] replaced by
+# your own identifying information:
+# "Portions Copyrighted [year] [name of copyright owner]"
+#
+# Contributor(s):
+#
+# The Original Software is NetBeans. The Initial Developer of the Original
+# Software is Sun Microsystems, Inc. Portions Copyright 2009-2010 Sun
+# Microsystems, Inc. All Rights Reserved.
+#
+# If you wish your version of this file to be governed by only the CDDL
+# or only the GPL Version 2, indicate your decision by adding
+# "[Contributor] elects to include this software in this distribution
+# under the [CDDL or GPL Version 2] license." If you do not indicate a
+# single choice of license, a recipient has the option to distribute
+# your version of this file under either the CDDL, the GPL Version 2 or
+# to extend the choice of license to its licensees as provided above.
+# However, if you add GPL Version 2 code and therefore, elected the GPL
+# Version 2 license, then the option applies only if the new code is
+# made subject to such option by the copyright holder.
+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
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/cmdline/compiler/nbproject/project.xml
----------------------------------------------------------------------
diff --git a/cmdline/compiler/nbproject/project.xml b/cmdline/compiler/nbproject/project.xml
new file mode 100644
index 0000000..99031ee
--- /dev/null
+++ b/cmdline/compiler/nbproject/project.xml
@@ -0,0 +1,341 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+
+Copyright 2009-2017 Oracle and/or its affiliates. All rights reserved.
+
+Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+Other names may be trademarks of their respective owners.
+
+The contents of this file are subject to the terms of either the GNU
+General Public License Version 2 only ("GPL") or the Common
+Development and Distribution License("CDDL") (collectively, the
+"License"). You may not use this file except in compliance with the
+License. You can obtain a copy of the License at
+http://www.netbeans.org/cddl-gplv2.html
+or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+specific language governing permissions and limitations under the
+License. When distributing the software, include this License Header
+Notice in each file and include the License file at
+nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+particular file as subject to the "Classpath" exception as provided
+by Oracle in the GPL Version 2 section of the License file that
+accompanied this code. If applicable, add the following below the
+License Header, with the fields enclosed by brackets [] replaced by
+your own identifying information:
+"Portions Copyrighted [year] [name of copyright owner]"
+
+Contributor(s):
+
+The Original Software is NetBeans. The Initial Developer of the Original
+Software is Sun Microsystems, Inc. Portions Copyright 2009-2010 Sun
+Microsystems, Inc. All Rights Reserved.
+
+If you wish your version of this file to be governed by only the CDDL
+or only the GPL Version 2, indicate your decision by adding
+"[Contributor] elects to include this software in this distribution
+under the [CDDL or GPL Version 2] license." If you do not indicate a
+single choice of license, a recipient has the option to distribute
+your version of this file under either the CDDL, the GPL Version 2 or
+to extend the choice of license to its licensees as provided above.
+However, if you add GPL Version 2 code and therefore, elected the GPL
+Version 2 license, then the option applies only if the new code is
+made subject to such option by the copyright holder.
+-->
+<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>
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/cmdline/compiler/nbproject/suite.properties
----------------------------------------------------------------------
diff --git a/cmdline/compiler/nbproject/suite.properties b/cmdline/compiler/nbproject/suite.properties
new file mode 100644
index 0000000..942e12b
--- /dev/null
+++ b/cmdline/compiler/nbproject/suite.properties
@@ -0,0 +1,42 @@
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+#
+# Copyright 2009-2017 Oracle and/or its affiliates. All rights reserved.
+#
+# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+# Other names may be trademarks of their respective owners.
+#
+# The contents of this file are subject to the terms of either the GNU
+# General Public License Version 2 only ("GPL") or the Common
+# Development and Distribution License("CDDL") (collectively, the
+# "License"). You may not use this file except in compliance with the
+# License. You can obtain a copy of the License at
+# http://www.netbeans.org/cddl-gplv2.html
+# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+# specific language governing permissions and limitations under the
+# License. When distributing the software, include this License Header
+# Notice in each file and include the License file at
+# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the GPL Version 2 section of the License file that
+# accompanied this code. If applicable, add the following below the
+# License Header, with the fields enclosed by brackets [] replaced by
+# your own identifying information:
+# "Portions Copyrighted [year] [name of copyright owner]"
+#
+# Contributor(s):
+#
+# The Original Software is NetBeans. The Initial Developer of the Original
+# Software is Sun Microsystems, Inc. Portions Copyright 2009-2010 Sun
+# Microsystems, Inc. All Rights Reserved.
+#
+# If you wish your version of this file to be governed by only the CDDL
+# or only the GPL Version 2, indicate your decision by adding
+# "[Contributor] elects to include this software in this distribution
+# under the [CDDL or GPL Version 2] license." If you do not indicate a
+# single choice of license, a recipient has the option to distribute
+# your version of this file under either the CDDL, the GPL Version 2 or
+# to extend the choice of license to its licensees as provided above.
+# However, if you add GPL Version 2 code and therefore, elected the GPL
+# Version 2 license, then the option applies only if the new code is
+# made subject to such option by the copyright holder.
+suite.dir=${basedir}/..
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/cmdline/compiler/scripts/README
----------------------------------------------------------------------
diff --git a/cmdline/compiler/scripts/README b/cmdline/compiler/scripts/README
new file mode 100644
index 0000000..71930f7
--- /dev/null
+++ b/cmdline/compiler/scripts/README
@@ -0,0 +1,32 @@
+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.
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/cmdline/compiler/scripts/jackpotc
----------------------------------------------------------------------
diff --git a/cmdline/compiler/scripts/jackpotc b/cmdline/compiler/scripts/jackpotc
new file mode 100755
index 0000000..eb1762f
--- /dev/null
+++ b/cmdline/compiler/scripts/jackpotc
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+#
+# Copyright 2009-2017 Oracle and/or its affiliates. All rights reserved.
+#
+# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+# Other names may be trademarks of their respective owners.
+#
+# The contents of this file are subject to the terms of either the GNU
+# General Public License Version 2 only ("GPL") or the Common
+# Development and Distribution License("CDDL") (collectively, the
+# "License"). You may not use this file except in compliance with the
+# License. You can obtain a copy of the License at
+# http://www.netbeans.org/cddl-gplv2.html
+# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+# specific language governing permissions and limitations under the
+# License. When distributing the software, include this License Header
+# Notice in each file and include the License file at
+# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the GPL Version 2 section of the License file that
+# accompanied this code. If applicable, add the following below the
+# License Header, with the fields enclosed by brackets [] replaced by
+# your own identifying information:
+# "Portions Copyrighted [year] [name of copyright owner]"
+#
+# Contributor(s):
+#
+# The Original Software is NetBeans. The Initial Developer of the Original
+# Software is Sun Microsystems, Inc. Portions Copyright 2009-2010 Sun
+# Microsystems, Inc. All Rights Reserved.
+#
+# If you wish your version of this file to be governed by only the CDDL
+# or only the GPL Version 2, indicate your decision by adding
+# "[Contributor] elects to include this software in this distribution
+# under the [CDDL or GPL Version 2] license." If you do not indicate a
+# single choice of license, a recipient has the option to distribute
+# your version of this file under either the CDDL, the GPL Version 2 or
+# to extend the choice of license to its licensees as provided above.
+# However, if you add GPL Version 2 code and therefore, elected the GPL
+# Version 2 license, then the option applies only if the new code is
+# made subject to such option by the copyright holder.
+
+java -Xbootclasspath/p:`dirname $0`/jackpotc.jar com.sun.tools.javac.Main -Xjcov "$@"
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/cmdline/compiler/src/org/netbeans/api/java/source/CompilationInfoHack.java
----------------------------------------------------------------------
diff --git a/cmdline/compiler/src/org/netbeans/api/java/source/CompilationInfoHack.java b/cmdline/compiler/src/org/netbeans/api/java/source/CompilationInfoHack.java
new file mode 100644
index 0000000..743504e
--- /dev/null
+++ b/cmdline/compiler/src/org/netbeans/api/java/source/CompilationInfoHack.java
@@ -0,0 +1,278 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
+ */
+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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/AbstractHintsAnnotationProcessing.java
----------------------------------------------------------------------
diff --git a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/AbstractHintsAnnotationProcessing.java b/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/AbstractHintsAnnotationProcessing.java
new file mode 100644
index 0000000..c04640c
--- /dev/null
+++ b/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/AbstractHintsAnnotationProcessing.java
@@ -0,0 +1,63 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2009-2011 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2009-2011 Sun Microsystems, Inc.
+ */
+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);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/Bundle.properties
----------------------------------------------------------------------
diff --git a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/Bundle.properties b/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/Bundle.properties
new file mode 100644
index 0000000..191e40d
--- /dev/null
+++ b/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/Bundle.properties
@@ -0,0 +1,39 @@
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+#
+# Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
+#
+# The contents of this file are subject to the terms of either the GNU
+# General Public License Version 2 only ("GPL") or the Common
+# Development and Distribution License("CDDL") (collectively, the
+# "License"). You may not use this file except in compliance with the
+# License. You can obtain a copy of the License at
+# http://www.netbeans.org/cddl-gplv2.html
+# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+# specific language governing permissions and limitations under the
+# License. When distributing the software, include this License Header
+# Notice in each file and include the License file at
+# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Sun in the GPL Version 2 section of the License file that
+# accompanied this code. If applicable, add the following below the
+# License Header, with the fields enclosed by brackets [] replaced by
+# your own identifying information:
+# "Portions Copyrighted [year] [name of copyright owner]"
+#
+# If you wish your version of this file to be governed by only the CDDL
+# or only the GPL Version 2, indicate your decision by adding
+# "[Contributor] elects to include this software in this distribution
+# under the [CDDL or GPL Version 2] license." If you do not indicate a
+# single choice of license, a recipient has the option to distribute
+# your version of this file under either the CDDL, the GPL Version 2 or
+# to extend the choice of license to its licensees as provided above.
+# However, if you add GPL Version 2 code and therefore, elected the GPL
+# Version 2 license, then the option applies only if the new code is
+# made subject to such option by the copyright holder.
+#
+# Contributor(s):
+#
+# Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
+#
+OpenIDE-Module-Name=Jackpot 3.0 Standalone Compiler
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/CompilerResourcesImpl.java
----------------------------------------------------------------------
diff --git a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/CompilerResourcesImpl.java b/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/CompilerResourcesImpl.java
new file mode 100644
index 0000000..57cc1da
--- /dev/null
+++ b/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/CompilerResourcesImpl.java
@@ -0,0 +1,75 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2010 Sun Microsystems, Inc.
+ */
+
+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();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessing.java
----------------------------------------------------------------------
diff --git a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessing.java b/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessing.java
new file mode 100644
index 0000000..bd88561
--- /dev/null
+++ b/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessing.java
@@ -0,0 +1,349 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2009 Sun Microsystems, Inc.
+ */
+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();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessingImpl.java
----------------------------------------------------------------------
diff --git a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessingImpl.java b/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessingImpl.java
new file mode 100644
index 0000000..367e1c6
--- /dev/null
+++ b/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessingImpl.java
@@ -0,0 +1,283 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2009-2011 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2009-2011 Sun Microsystems, Inc.
+ */
+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();
+ }
+ }
+
+}