1.1 --- a/.hgignore Fri Jan 27 13:35:56 2012 +0100
1.2 +++ b/.hgignore Mon Mar 12 21:10:10 2012 +0100
1.3 @@ -8,7 +8,7 @@
1.4 ^external$
1.5 .*/external$
1.6 \.old$
1.7 -^server/lib$
1.8 +^lib$
1.9 .*/nbproject-.*/private.xml
1.10 \.aux$
1.11 \.dvi$
2.1 --- a/api/build.xml Fri Jan 27 13:35:56 2012 +0100
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,23 +0,0 @@
2.4 -<?xml version="1.0" encoding="UTF-8"?>
2.5 -<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
2.6 -<!-- for some information on what you could do (e.g. targets to override). -->
2.7 -<!-- If you delete this file and reopen the project it will be recreated. -->
2.8 -<project name="org.netbeans.modules.jackpot30.api" default="netbeans" basedir=".">
2.9 - <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.api.</description>
2.10 - <import file="nbproject/build-impl.xml"/>
2.11 - <import file="${suite.dir}/findbugs-import.xml"/>
2.12 -
2.13 - <!-- Mac -->
2.14 - <pathconvert property="retouche.javac">
2.15 - <fileset dir="${nbplatform.active.dir}">
2.16 - <filename name="java*/modules/ext/javac*.jar"/>
2.17 - </fileset>
2.18 - <fileset dir="${java.home}/../Classes" erroronmissingdir="false">
2.19 - <include name="*.jar"/>
2.20 - </fileset>
2.21 - </pathconvert>
2.22 - <echo message="${retouche.javac}"/>
2.23 - <condition property="bootclasspath.mac" value="${retouche.javac}">
2.24 - <os family="mac"/>
2.25 - </condition>
2.26 -</project>
3.1 --- a/api/manifest.mf Fri Jan 27 13:35:56 2012 +0100
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,7 +0,0 @@
3.4 -Manifest-Version: 1.0
3.5 -AutoUpdate-Show-In-Client: false
3.6 -OpenIDE-Module: org.netbeans.modules.jackpot30.api
3.7 -OpenIDE-Module-Implementation-Version: 1
3.8 -OpenIDE-Module-Layer: org/netbeans/modules/jackpot30/impl/resources/layer.xml
3.9 -OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/impl/resources/Bundle.properties
3.10 -
4.1 --- a/api/nbproject/build-impl.xml Fri Jan 27 13:35:56 2012 +0100
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,45 +0,0 @@
4.4 -<?xml version="1.0" encoding="UTF-8"?>
4.5 -<!--
4.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
4.7 -*** EDIT ../build.xml INSTEAD ***
4.8 --->
4.9 -<project name="org.netbeans.modules.jackpot30.api-impl" basedir="..">
4.10 - <fail message="Please build using Ant 1.7.1 or higher.">
4.11 - <condition>
4.12 - <not>
4.13 - <antversion atleast="1.7.1"/>
4.14 - </not>
4.15 - </condition>
4.16 - </fail>
4.17 - <property file="nbproject/private/suite-private.properties"/>
4.18 - <property file="nbproject/suite.properties"/>
4.19 - <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
4.20 - <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
4.21 - <property file="${suite.dir}/nbproject/platform.properties"/>
4.22 - <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
4.23 - <attribute name="name"/>
4.24 - <attribute name="value"/>
4.25 - <sequential>
4.26 - <property name="@{name}" value="${@{value}}"/>
4.27 - </sequential>
4.28 - </macrodef>
4.29 - <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
4.30 - <attribute name="property"/>
4.31 - <attribute name="value"/>
4.32 - <sequential>
4.33 - <property name="@{property}" value="@{value}"/>
4.34 - </sequential>
4.35 - </macrodef>
4.36 - <property file="${user.properties.file}"/>
4.37 - <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
4.38 - <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
4.39 - <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
4.40 - <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
4.41 - <condition>
4.42 - <not>
4.43 - <contains string="${cluster.path.evaluated}" substring="platform"/>
4.44 - </not>
4.45 - </condition>
4.46 - </fail>
4.47 - <import file="${harness.dir}/build.xml"/>
4.48 -</project>
5.1 --- a/api/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,8 +0,0 @@
5.4 -build.xml.data.CRC32=f9c1509c
5.5 -build.xml.script.CRC32=0abcaef9
5.6 -build.xml.stylesheet.CRC32=79c3b980@1.28.0.7
5.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
5.9 -nbproject/build-impl.xml.data.CRC32=035c9b32
5.10 -nbproject/build-impl.xml.script.CRC32=c4574e66
5.11 -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.47
6.1 --- a/api/nbproject/project.properties Fri Jan 27 13:35:56 2012 +0100
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,3 +0,0 @@
6.4 -javac.source=1.5
6.5 -javac.compilerargs=-Xlint -Xlint:-serial
6.6 -spec.version.base=1.16.0
7.1 --- a/api/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
7.3 @@ -1,433 +0,0 @@
7.4 -<?xml version="1.0" encoding="UTF-8"?>
7.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
7.6 - <type>org.netbeans.modules.apisupport.project</type>
7.7 - <configuration>
7.8 - <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
7.9 - <code-name-base>org.netbeans.modules.jackpot30.api</code-name-base>
7.10 - <suite-component/>
7.11 - <module-dependencies>
7.12 - <dependency>
7.13 - <code-name-base>org.jdesktop.layout</code-name-base>
7.14 - <build-prerequisite/>
7.15 - <compile-dependency/>
7.16 - <run-dependency>
7.17 - <release-version>1</release-version>
7.18 - <specification-version>1.7.0.103</specification-version>
7.19 - </run-dependency>
7.20 - </dependency>
7.21 - <dependency>
7.22 - <code-name-base>org.netbeans.api.annotations.common</code-name-base>
7.23 - <build-prerequisite/>
7.24 - <compile-dependency/>
7.25 - <run-dependency>
7.26 - <release-version>1</release-version>
7.27 - <specification-version>1.0</specification-version>
7.28 - </run-dependency>
7.29 - </dependency>
7.30 - <dependency>
7.31 - <code-name-base>org.netbeans.api.java.classpath</code-name-base>
7.32 - <build-prerequisite/>
7.33 - <compile-dependency/>
7.34 - <run-dependency>
7.35 - <release-version>1</release-version>
7.36 - <specification-version>1.19</specification-version>
7.37 - </run-dependency>
7.38 - </dependency>
7.39 - <dependency>
7.40 - <code-name-base>org.netbeans.api.progress</code-name-base>
7.41 - <build-prerequisite/>
7.42 - <compile-dependency/>
7.43 - <run-dependency>
7.44 - <release-version>1</release-version>
7.45 - <specification-version>1.13.0.1</specification-version>
7.46 - </run-dependency>
7.47 - </dependency>
7.48 - <dependency>
7.49 - <code-name-base>org.netbeans.libs.javacapi</code-name-base>
7.50 - <build-prerequisite/>
7.51 - <compile-dependency/>
7.52 - <run-dependency>
7.53 - <specification-version>7.5.0.3</specification-version>
7.54 - </run-dependency>
7.55 - </dependency>
7.56 - <dependency>
7.57 - <code-name-base>org.netbeans.libs.javacimpl</code-name-base>
7.58 - <build-prerequisite/>
7.59 - <compile-dependency/>
7.60 - <run-dependency>
7.61 - <release-version>1</release-version>
7.62 - <implementation-version/>
7.63 - </run-dependency>
7.64 - </dependency>
7.65 - <dependency>
7.66 - <code-name-base>org.netbeans.libs.lucene</code-name-base>
7.67 - <build-prerequisite/>
7.68 - <compile-dependency/>
7.69 - <run-dependency>
7.70 - <release-version>1-3</release-version>
7.71 - <specification-version>2.13</specification-version>
7.72 - </run-dependency>
7.73 - </dependency>
7.74 - <dependency>
7.75 - <code-name-base>org.netbeans.modules.diff</code-name-base>
7.76 - <build-prerequisite/>
7.77 - <compile-dependency/>
7.78 - <run-dependency>
7.79 - <release-version>1</release-version>
7.80 - <implementation-version/>
7.81 - </run-dependency>
7.82 - </dependency>
7.83 - <dependency>
7.84 - <code-name-base>org.netbeans.modules.editor</code-name-base>
7.85 - <build-prerequisite/>
7.86 - <compile-dependency/>
7.87 - <run-dependency>
7.88 - <release-version>3</release-version>
7.89 - <specification-version>1.56.0.5.13.6</specification-version>
7.90 - </run-dependency>
7.91 - </dependency>
7.92 - <dependency>
7.93 - <code-name-base>org.netbeans.modules.editor.lib</code-name-base>
7.94 - <build-prerequisite/>
7.95 - <compile-dependency/>
7.96 - <run-dependency>
7.97 - <release-version>1-3</release-version>
7.98 - <specification-version>1.38.0.9.2</specification-version>
7.99 - </run-dependency>
7.100 - </dependency>
7.101 - <dependency>
7.102 - <code-name-base>org.netbeans.modules.editor.lib2</code-name-base>
7.103 - <build-prerequisite/>
7.104 - <compile-dependency/>
7.105 - <run-dependency>
7.106 - <release-version>1</release-version>
7.107 - <specification-version>1.13.0.2</specification-version>
7.108 - </run-dependency>
7.109 - </dependency>
7.110 - <dependency>
7.111 - <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
7.112 - <build-prerequisite/>
7.113 - <compile-dependency/>
7.114 - <run-dependency>
7.115 - <release-version>1</release-version>
7.116 - <specification-version>1.12</specification-version>
7.117 - </run-dependency>
7.118 - </dependency>
7.119 - <dependency>
7.120 - <code-name-base>org.netbeans.modules.editor.settings</code-name-base>
7.121 - <build-prerequisite/>
7.122 - <compile-dependency/>
7.123 - <run-dependency>
7.124 - <release-version>1</release-version>
7.125 - <specification-version>1.25</specification-version>
7.126 - </run-dependency>
7.127 - </dependency>
7.128 - <dependency>
7.129 - <code-name-base>org.netbeans.modules.jackpot30.remoting.api</code-name-base>
7.130 - <build-prerequisite/>
7.131 - <compile-dependency/>
7.132 - <run-dependency>
7.133 - <specification-version>1.0</specification-version>
7.134 - </run-dependency>
7.135 - </dependency>
7.136 - <dependency>
7.137 - <code-name-base>org.netbeans.modules.java.editor</code-name-base>
7.138 - <build-prerequisite/>
7.139 - <compile-dependency/>
7.140 - <run-dependency>
7.141 - <release-version>1</release-version>
7.142 - <implementation-version/>
7.143 - </run-dependency>
7.144 - </dependency>
7.145 - <dependency>
7.146 - <code-name-base>org.netbeans.modules.java.hints</code-name-base>
7.147 - <build-prerequisite/>
7.148 - <compile-dependency/>
7.149 - <run-dependency>
7.150 - <release-version>1</release-version>
7.151 - <implementation-version/>
7.152 - </run-dependency>
7.153 - </dependency>
7.154 - <dependency>
7.155 - <code-name-base>org.netbeans.modules.java.lexer</code-name-base>
7.156 - <build-prerequisite/>
7.157 - <compile-dependency/>
7.158 - <run-dependency>
7.159 - <release-version>1</release-version>
7.160 - <specification-version>1.9</specification-version>
7.161 - </run-dependency>
7.162 - </dependency>
7.163 - <dependency>
7.164 - <code-name-base>org.netbeans.modules.java.platform</code-name-base>
7.165 - <build-prerequisite/>
7.166 - <compile-dependency/>
7.167 - <run-dependency>
7.168 - <release-version>1</release-version>
7.169 - <specification-version>1.12</specification-version>
7.170 - </run-dependency>
7.171 - </dependency>
7.172 - <dependency>
7.173 - <code-name-base>org.netbeans.modules.java.preprocessorbridge</code-name-base>
7.174 - <build-prerequisite/>
7.175 - <compile-dependency/>
7.176 - <run-dependency>
7.177 - <implementation-version/>
7.178 - </run-dependency>
7.179 - </dependency>
7.180 - <dependency>
7.181 - <code-name-base>org.netbeans.modules.java.source</code-name-base>
7.182 - <build-prerequisite/>
7.183 - <compile-dependency/>
7.184 - <run-dependency>
7.185 - <implementation-version/>
7.186 - </run-dependency>
7.187 - </dependency>
7.188 - <dependency>
7.189 - <code-name-base>org.netbeans.modules.lexer</code-name-base>
7.190 - <build-prerequisite/>
7.191 - <compile-dependency/>
7.192 - <run-dependency>
7.193 - <release-version>2</release-version>
7.194 - <specification-version>1.34</specification-version>
7.195 - </run-dependency>
7.196 - </dependency>
7.197 - <dependency>
7.198 - <code-name-base>org.netbeans.modules.options.api</code-name-base>
7.199 - <build-prerequisite/>
7.200 - <compile-dependency/>
7.201 - <run-dependency>
7.202 - <release-version>1</release-version>
7.203 - <specification-version>1.20</specification-version>
7.204 - </run-dependency>
7.205 - </dependency>
7.206 - <dependency>
7.207 - <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
7.208 - <build-prerequisite/>
7.209 - <compile-dependency/>
7.210 - <run-dependency>
7.211 - <release-version>1</release-version>
7.212 - <implementation-version/>
7.213 - </run-dependency>
7.214 - </dependency>
7.215 - <dependency>
7.216 - <code-name-base>org.netbeans.modules.projectapi</code-name-base>
7.217 - <build-prerequisite/>
7.218 - <compile-dependency/>
7.219 - <run-dependency>
7.220 - <release-version>1</release-version>
7.221 - <specification-version>1.24</specification-version>
7.222 - </run-dependency>
7.223 - </dependency>
7.224 - <dependency>
7.225 - <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
7.226 - <build-prerequisite/>
7.227 - <compile-dependency/>
7.228 - <run-dependency>
7.229 - <release-version>1</release-version>
7.230 - <specification-version>1.35.0.6</specification-version>
7.231 - </run-dependency>
7.232 - </dependency>
7.233 - <dependency>
7.234 - <code-name-base>org.netbeans.modules.queries</code-name-base>
7.235 - <build-prerequisite/>
7.236 - <compile-dependency/>
7.237 - <run-dependency>
7.238 - <release-version>1</release-version>
7.239 - <specification-version>1.15</specification-version>
7.240 - </run-dependency>
7.241 - </dependency>
7.242 - <dependency>
7.243 - <code-name-base>org.netbeans.modules.refactoring.api</code-name-base>
7.244 - <build-prerequisite/>
7.245 - <compile-dependency/>
7.246 - <run-dependency>
7.247 - <specification-version>1.6</specification-version>
7.248 - </run-dependency>
7.249 - </dependency>
7.250 - <dependency>
7.251 - <code-name-base>org.netbeans.modules.refactoring.java</code-name-base>
7.252 - <build-prerequisite/>
7.253 - <compile-dependency/>
7.254 - <run-dependency>
7.255 - <release-version>1</release-version>
7.256 - <specification-version>1.6</specification-version>
7.257 - </run-dependency>
7.258 - </dependency>
7.259 - <dependency>
7.260 - <code-name-base>org.netbeans.modules.sendopts</code-name-base>
7.261 - <build-prerequisite/>
7.262 - <compile-dependency/>
7.263 - <run-dependency>
7.264 - <release-version>2</release-version>
7.265 - <specification-version>2.4</specification-version>
7.266 - </run-dependency>
7.267 - </dependency>
7.268 - <dependency>
7.269 - <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
7.270 - <build-prerequisite/>
7.271 - <compile-dependency/>
7.272 - <run-dependency>
7.273 - <release-version>0-1</release-version>
7.274 - <specification-version>1.7.0.7.2</specification-version>
7.275 - </run-dependency>
7.276 - </dependency>
7.277 - <dependency>
7.278 - <code-name-base>org.openide.awt</code-name-base>
7.279 - <build-prerequisite/>
7.280 - <compile-dependency/>
7.281 - <run-dependency>
7.282 - <specification-version>7.7.0.1</specification-version>
7.283 - </run-dependency>
7.284 - </dependency>
7.285 - <dependency>
7.286 - <code-name-base>org.openide.dialogs</code-name-base>
7.287 - <build-prerequisite/>
7.288 - <compile-dependency/>
7.289 - <run-dependency>
7.290 - <specification-version>7.10</specification-version>
7.291 - </run-dependency>
7.292 - </dependency>
7.293 - <dependency>
7.294 - <code-name-base>org.openide.filesystems</code-name-base>
7.295 - <build-prerequisite/>
7.296 - <compile-dependency/>
7.297 - <run-dependency>
7.298 - <specification-version>7.21.0.1.1</specification-version>
7.299 - </run-dependency>
7.300 - </dependency>
7.301 - <dependency>
7.302 - <code-name-base>org.openide.loaders</code-name-base>
7.303 - <build-prerequisite/>
7.304 - <compile-dependency/>
7.305 - <run-dependency>
7.306 - <specification-version>7.5</specification-version>
7.307 - </run-dependency>
7.308 - </dependency>
7.309 - <dependency>
7.310 - <code-name-base>org.openide.modules</code-name-base>
7.311 - <build-prerequisite/>
7.312 - <compile-dependency/>
7.313 - <run-dependency>
7.314 - <specification-version>7.10</specification-version>
7.315 - </run-dependency>
7.316 - </dependency>
7.317 - <dependency>
7.318 - <code-name-base>org.openide.nodes</code-name-base>
7.319 - <build-prerequisite/>
7.320 - <compile-dependency/>
7.321 - <run-dependency>
7.322 - <specification-version>7.9.0.1</specification-version>
7.323 - </run-dependency>
7.324 - </dependency>
7.325 - <dependency>
7.326 - <code-name-base>org.openide.text</code-name-base>
7.327 - <build-prerequisite/>
7.328 - <compile-dependency/>
7.329 - <run-dependency>
7.330 - <specification-version>6.22</specification-version>
7.331 - </run-dependency>
7.332 - </dependency>
7.333 - <dependency>
7.334 - <code-name-base>org.openide.util</code-name-base>
7.335 - <build-prerequisite/>
7.336 - <compile-dependency/>
7.337 - <run-dependency>
7.338 - <specification-version>8.0</specification-version>
7.339 - </run-dependency>
7.340 - </dependency>
7.341 - <dependency>
7.342 - <code-name-base>org.openide.util.lookup</code-name-base>
7.343 - <build-prerequisite/>
7.344 - <compile-dependency/>
7.345 - <run-dependency>
7.346 - <specification-version>8.0.0.1</specification-version>
7.347 - </run-dependency>
7.348 - </dependency>
7.349 - <dependency>
7.350 - <code-name-base>org.openide.windows</code-name-base>
7.351 - <build-prerequisite/>
7.352 - <compile-dependency/>
7.353 - <run-dependency>
7.354 - <specification-version>6.27</specification-version>
7.355 - </run-dependency>
7.356 - </dependency>
7.357 - </module-dependencies>
7.358 - <test-dependencies>
7.359 - <test-type>
7.360 - <name>unit</name>
7.361 - <test-dependency>
7.362 - <code-name-base>org.netbeans.bootstrap</code-name-base>
7.363 - </test-dependency>
7.364 - <test-dependency>
7.365 - <code-name-base>org.netbeans.core.startup</code-name-base>
7.366 - </test-dependency>
7.367 - <test-dependency>
7.368 - <code-name-base>org.netbeans.insane</code-name-base>
7.369 - <compile-dependency/>
7.370 - </test-dependency>
7.371 - <test-dependency>
7.372 - <code-name-base>org.netbeans.libs.junit4</code-name-base>
7.373 - <compile-dependency/>
7.374 - </test-dependency>
7.375 - <test-dependency>
7.376 - <code-name-base>org.netbeans.modules.classfile</code-name-base>
7.377 - </test-dependency>
7.378 - <test-dependency>
7.379 - <code-name-base>org.netbeans.modules.defaults</code-name-base>
7.380 - </test-dependency>
7.381 - <test-dependency>
7.382 - <code-name-base>org.netbeans.modules.editor</code-name-base>
7.383 - </test-dependency>
7.384 - <test-dependency>
7.385 - <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
7.386 - </test-dependency>
7.387 - <test-dependency>
7.388 - <code-name-base>org.netbeans.modules.editor.settings</code-name-base>
7.389 - </test-dependency>
7.390 - <test-dependency>
7.391 - <code-name-base>org.netbeans.modules.editor.settings.storage</code-name-base>
7.392 - </test-dependency>
7.393 - <test-dependency>
7.394 - <code-name-base>org.netbeans.modules.editor.util</code-name-base>
7.395 - </test-dependency>
7.396 - <test-dependency>
7.397 - <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
7.398 - <recursive/>
7.399 - <compile-dependency/>
7.400 - </test-dependency>
7.401 - <test-dependency>
7.402 - <code-name-base>org.netbeans.modules.java.hints</code-name-base>
7.403 - <compile-dependency/>
7.404 - </test-dependency>
7.405 - <test-dependency>
7.406 - <code-name-base>org.netbeans.modules.java.hints.declarative</code-name-base>
7.407 - </test-dependency>
7.408 - <test-dependency>
7.409 - <code-name-base>org.netbeans.modules.java.lexer</code-name-base>
7.410 - </test-dependency>
7.411 - <test-dependency>
7.412 - <code-name-base>org.netbeans.modules.masterfs</code-name-base>
7.413 - </test-dependency>
7.414 - <test-dependency>
7.415 - <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
7.416 - <compile-dependency/>
7.417 - </test-dependency>
7.418 - <test-dependency>
7.419 - <code-name-base>org.netbeans.modules.progress.ui</code-name-base>
7.420 - </test-dependency>
7.421 - <test-dependency>
7.422 - <code-name-base>org.netbeans.modules.projectui</code-name-base>
7.423 - </test-dependency>
7.424 - <test-dependency>
7.425 - <code-name-base>org.openidex.util</code-name-base>
7.426 - </test-dependency>
7.427 - </test-type>
7.428 - </test-dependencies>
7.429 - <public-packages>
7.430 - <package>org.netbeans.modules.jackpot30.spi</package>
7.431 - <package>org.netbeans.modules.jackpot30.spi.refactoring</package>
7.432 - <package>org.netbeans.modules.jackpot30.spi.support</package>
7.433 - </public-packages>
7.434 - </data>
7.435 - </configuration>
7.436 -</project>
8.1 --- a/api/nbproject/suite.properties Fri Jan 27 13:35:56 2012 +0100
8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
8.3 @@ -1,1 +0,0 @@
8.4 -suite.dir=${basedir}/..
9.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/batch/BatchUtilities.java Fri Jan 27 13:35:56 2012 +0100
9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
9.3 @@ -1,121 +0,0 @@
9.4 -/*
9.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
9.6 - *
9.7 - * Copyright 2008-2010 Sun Microsystems, Inc. All rights reserved.
9.8 - *
9.9 - * The contents of this file are subject to the terms of either the GNU
9.10 - * General Public License Version 2 only ("GPL") or the Common
9.11 - * Development and Distribution License("CDDL") (collectively, the
9.12 - * "License"). You may not use this file except in compliance with the
9.13 - * License. You can obtain a copy of the License at
9.14 - * http://www.netbeans.org/cddl-gplv2.html
9.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
9.16 - * specific language governing permissions and limitations under the
9.17 - * License. When distributing the software, include this License Header
9.18 - * Notice in each file and include the License file at
9.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
9.20 - * particular file as subject to the "Classpath" exception as provided
9.21 - * by Sun in the GPL Version 2 section of the License file that
9.22 - * accompanied this code. If applicable, add the following below the
9.23 - * License Header, with the fields enclosed by brackets [] replaced by
9.24 - * your own identifying information:
9.25 - * "Portions Copyrighted [year] [name of copyright owner]"
9.26 - *
9.27 - * If you wish your version of this file to be governed by only the CDDL
9.28 - * or only the GPL Version 2, indicate your decision by adding
9.29 - * "[Contributor] elects to include this software in this distribution
9.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
9.31 - * single choice of license, a recipient has the option to distribute
9.32 - * your version of this file under either the CDDL, the GPL Version 2 or
9.33 - * to extend the choice of license to its licensees as provided above.
9.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
9.35 - * Version 2 license, then the option applies only if the new code is
9.36 - * made subject to such option by the copyright holder.
9.37 - *
9.38 - * Contributor(s):
9.39 - *
9.40 - * Portions Copyrighted 2008-2010 Sun Microsystems, Inc.
9.41 - */
9.42 -
9.43 -package org.netbeans.modules.jackpot30.impl.batch;
9.44 -
9.45 -import java.io.IOException;
9.46 -import java.io.Reader;
9.47 -import java.io.StringReader;
9.48 -import java.io.Writer;
9.49 -import java.nio.charset.Charset;
9.50 -import org.netbeans.api.annotations.common.NullAllowed;
9.51 -import org.netbeans.api.java.source.ModificationResult;
9.52 -import org.netbeans.api.queries.FileEncodingQuery;
9.53 -import org.netbeans.modules.diff.builtin.provider.BuiltInDiffProvider;
9.54 -import org.netbeans.modules.diff.builtin.visualizer.TextDiffVisualizer;
9.55 -import org.netbeans.spi.diff.DiffProvider;
9.56 -import org.openide.filesystems.FileObject;
9.57 -import org.openide.filesystems.FileUtil;
9.58 -
9.59 -/**
9.60 - *
9.61 - * @author Jan Lahoda
9.62 - */
9.63 -public class BatchUtilities {
9.64 -
9.65 - public static void exportDiff(ModificationResult result, @NullAllowed FileObject relativeTo, Writer out) throws IOException {
9.66 - for (FileObject f : result.getModifiedFileObjects()) {
9.67 - Charset c = FileEncodingQuery.getEncoding(f);
9.68 - String orig = new String(f.asBytes(), c);
9.69 - String nue = result.getResultingSource(f);
9.70 -
9.71 - if (orig.equals(nue)) {
9.72 - continue;
9.73 - }
9.74 -
9.75 - String name = relativeTo != null ? FileUtil.getRelativePath(relativeTo, f) : FileUtil.toFile(f).getAbsolutePath();
9.76 -
9.77 - doExportDiff(name, orig, nue, out);
9.78 - }
9.79 - }
9.80 -
9.81 - //copied from the diff module:
9.82 - private static void doExportDiff(String name, String original, String modified, Writer out) throws IOException {
9.83 - DiffProvider diff = new BuiltInDiffProvider();//(DiffProvider) Lookup.getDefault().lookup(DiffProvider.class);
9.84 -
9.85 - Reader r1 = null;
9.86 - Reader r2 = null;
9.87 - org.netbeans.api.diff.Difference[] differences;
9.88 -
9.89 - try {
9.90 - r1 = new StringReader(original);
9.91 - r2 = new StringReader(modified);
9.92 - differences = diff.computeDiff(r1, r2);
9.93 - } finally {
9.94 - if (r1 != null) try { r1.close(); } catch (Exception e) {}
9.95 - if (r2 != null) try { r2.close(); } catch (Exception e) {}
9.96 - }
9.97 -
9.98 - try {
9.99 - r1 = new StringReader(original);
9.100 - r2 = new StringReader(modified);
9.101 - TextDiffVisualizer.TextDiffInfo info = new TextDiffVisualizer.TextDiffInfo(
9.102 - name, // NOI18N
9.103 - name, // NOI18N
9.104 - null,
9.105 - null,
9.106 - r1,
9.107 - r2,
9.108 - differences
9.109 - );
9.110 - info.setContextMode(true, 3);
9.111 - String diffText;
9.112 -// if (format == unifiedFilter) {
9.113 - diffText = TextDiffVisualizer.differenceToUnifiedDiffText(info);
9.114 -// } else {
9.115 -// diffText = TextDiffVisualizer.differenceToNormalDiffText(info);
9.116 -// }
9.117 - out.write(diffText);
9.118 - } finally {
9.119 - if (r1 != null) try { r1.close(); } catch (Exception e) {}
9.120 - if (r2 != null) try { r2.close(); } catch (Exception e) {}
9.121 - }
9.122 - }
9.123 -
9.124 -}
10.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/batch/Bundle.properties Fri Jan 27 13:35:56 2012 +0100
10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
10.3 @@ -1,49 +0,0 @@
10.4 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
10.5 -#
10.6 -# Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
10.7 -#
10.8 -# The contents of this file are subject to the terms of either the GNU
10.9 -# General Public License Version 2 only ("GPL") or the Common
10.10 -# Development and Distribution License("CDDL") (collectively, the
10.11 -# "License"). You may not use this file except in compliance with the
10.12 -# License. You can obtain a copy of the License at
10.13 -# http://www.netbeans.org/cddl-gplv2.html
10.14 -# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
10.15 -# specific language governing permissions and limitations under the
10.16 -# License. When distributing the software, include this License Header
10.17 -# Notice in each file and include the License file at
10.18 -# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
10.19 -# particular file as subject to the "Classpath" exception as provided
10.20 -# by Sun in the GPL Version 2 section of the License file that
10.21 -# accompanied this code. If applicable, add the following below the
10.22 -# License Header, with the fields enclosed by brackets [] replaced by
10.23 -# your own identifying information:
10.24 -# "Portions Copyrighted [year] [name of copyright owner]"
10.25 -#
10.26 -# Contributor(s):
10.27 -#
10.28 -#The Original Software is NetBeans. The Initial Developer of the Original
10.29 -# Software is Sun Microsystems, Inc. Portions Copyright 2008-2009 Sun
10.30 -#Microsystems, Inc. All Rights Reserved.
10.31 -#
10.32 -# If you wish your version of this file to be governed by only the CDDL
10.33 -# or only the GPL Version 2, indicate your decision by adding
10.34 -# "[Contributor] elects to include this software in this distribution
10.35 -# under the [CDDL or GPL Version 2] license." If you do not indicate a
10.36 -# single choice of license, a recipient has the option to distribute
10.37 -# your version of this file under either the CDDL, the GPL Version 2 or
10.38 -# to extend the choice of license to its licensees as provided above.
10.39 -# However, if you add GPL Version 2 code and therefore, elected the GPL
10.40 -# Version 2 license, then the option applies only if the new code is
10.41 -# made subject to such option by the copyright holder.
10.42 -
10.43 -CTL_BatchApplyAction=Batch Apply Hint
10.44 -SD_ApplyTransformations=applies specified transformation(s) on specified project or all opened projects
10.45 -SD_ApplyTransformationsProject=projects on which the transformations should be applied
10.46 -SelectHint.jLabel1.text=Select Hint:
10.47 -SelectHint.addHint.text=>>
10.48 -SelectHint.addAllHints.text=>>>
10.49 -SelectHint.removeHint.text=<<
10.50 -SelectHint.removeAllHints.text=<<<
10.51 -SelectHint.selectedHintsLabel.text=Selected Hints
10.52 -SelectHint.allHintsLabel.text_1=All Hints:
11.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/batch/EnhancedScopes.java Fri Jan 27 13:35:56 2012 +0100
11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
11.3 @@ -1,458 +0,0 @@
11.4 -/*
11.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
11.6 - *
11.7 - * Copyright 2009-2011 Sun Microsystems, Inc. All rights reserved.
11.8 - *
11.9 - * The contents of this file are subject to the terms of either the GNU
11.10 - * General Public License Version 2 only ("GPL") or the Common
11.11 - * Development and Distribution License("CDDL") (collectively, the
11.12 - * "License"). You may not use this file except in compliance with the
11.13 - * License. You can obtain a copy of the License at
11.14 - * http://www.netbeans.org/cddl-gplv2.html
11.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
11.16 - * specific language governing permissions and limitations under the
11.17 - * License. When distributing the software, include this License Header
11.18 - * Notice in each file and include the License file at
11.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
11.20 - * particular file as subject to the "Classpath" exception as provided
11.21 - * by Sun in the GPL Version 2 section of the License file that
11.22 - * accompanied this code. If applicable, add the following below the
11.23 - * License Header, with the fields enclosed by brackets [] replaced by
11.24 - * your own identifying information:
11.25 - * "Portions Copyrighted [year] [name of copyright owner]"
11.26 - *
11.27 - * If you wish your version of this file to be governed by only the CDDL
11.28 - * or only the GPL Version 2, indicate your decision by adding
11.29 - * "[Contributor] elects to include this software in this distribution
11.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
11.31 - * single choice of license, a recipient has the option to distribute
11.32 - * your version of this file under either the CDDL, the GPL Version 2 or
11.33 - * to extend the choice of license to its licensees as provided above.
11.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
11.35 - * Version 2 license, then the option applies only if the new code is
11.36 - * made subject to such option by the copyright holder.
11.37 - *
11.38 - * Contributor(s):
11.39 - *
11.40 - * Portions Copyrighted 2009-2011 Sun Microsystems, Inc.
11.41 - */
11.42 -
11.43 -package org.netbeans.modules.jackpot30.impl.batch;
11.44 -
11.45 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.Folder;
11.46 -import org.netbeans.modules.java.hints.jackpot.spi.Trigger.PatternDescription;
11.47 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.Resource;
11.48 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.Scope;
11.49 -import java.util.concurrent.Callable;
11.50 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.IndexEnquirer;
11.51 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.LocalIndexEnquirer;
11.52 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.MapIndices;
11.53 -import org.netbeans.modules.java.hints.jackpot.impl.MessageImpl;
11.54 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch;
11.55 -import org.netbeans.modules.java.hints.jackpot.impl.batch.ProgressHandleWrapper;
11.56 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch.BulkPattern;
11.57 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
11.58 -import org.netbeans.spi.editor.hints.Severity;
11.59 -import java.util.Iterator;
11.60 -import java.io.BufferedInputStream;
11.61 -import java.io.BufferedOutputStream;
11.62 -import java.io.File;
11.63 -import java.io.FileInputStream;
11.64 -import java.io.FileOutputStream;
11.65 -import java.io.IOException;
11.66 -import java.io.InputStream;
11.67 -import java.io.OutputStream;
11.68 -import java.net.URI;
11.69 -import java.net.URISyntaxException;
11.70 -import java.util.ArrayList;
11.71 -import java.util.Collection;
11.72 -import java.util.Collections;
11.73 -import java.util.HashMap;
11.74 -import java.util.HashSet;
11.75 -import java.util.LinkedList;
11.76 -import java.util.List;
11.77 -import java.util.Map;
11.78 -import java.util.Map.Entry;
11.79 -import java.util.Properties;
11.80 -import java.util.Set;
11.81 -import java.util.concurrent.atomic.AtomicBoolean;
11.82 -import java.util.logging.Level;
11.83 -import java.util.logging.Logger;
11.84 -import org.codeviation.pojson.Pojson;
11.85 -import org.netbeans.modules.jackpot30.remoting.api.WebUtilities;
11.86 -import org.netbeans.modules.jackpot30.impl.indexing.CustomIndexerImpl;
11.87 -import org.netbeans.modules.jackpot30.impl.indexing.FileBasedIndex;
11.88 -import org.netbeans.modules.jackpot30.impl.indexing.Index;
11.89 -import org.netbeans.modules.jackpot30.remoting.api.RemoteIndex;
11.90 -import org.netbeans.modules.java.hints.jackpot.impl.batch.Scopes;
11.91 -import org.netbeans.spi.editor.hints.ErrorDescription;
11.92 -import org.netbeans.spi.editor.hints.ErrorDescriptionFactory;
11.93 -import org.openide.filesystems.FileObject;
11.94 -import org.openide.filesystems.FileStateInvalidException;
11.95 -import org.openide.filesystems.FileUtil;
11.96 -import org.openide.filesystems.URLMapper;
11.97 -import org.openide.util.Exceptions;
11.98 -import static org.netbeans.modules.jackpot30.remoting.api.WebUtilities.escapeForQuery;
11.99 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.VerifiedSpansCallBack;
11.100 -
11.101 -/**
11.102 - *
11.103 - * @author lahvac
11.104 - */
11.105 -public class EnhancedScopes {
11.106 -
11.107 - private static final Logger LOG = Logger.getLogger(EnhancedScopes.class.getName());
11.108 -
11.109 - public static Scope allRemote() {
11.110 - return new RemoteIndexScope();
11.111 - }
11.112 -
11.113 - public static final class GivenFolderScope extends Scope {
11.114 -
11.115 - public final String folder;
11.116 - public final String indexURL;
11.117 - public final String subIndex;
11.118 - public final boolean update;
11.119 -
11.120 - public GivenFolderScope(String folder, String indexURL, String subIndex, boolean update) {
11.121 - this.folder = folder;
11.122 - this.indexURL = indexURL;
11.123 - this.subIndex = subIndex;
11.124 - this.update = update;
11.125 - }
11.126 -
11.127 - @Override
11.128 - public String getDisplayName() {
11.129 - return folder;
11.130 - }
11.131 -
11.132 - @Override
11.133 - public Collection<? extends Folder> getTodo() {
11.134 - return Collections.singletonList(new Folder(FileUtil.toFileObject(new File(folder))));
11.135 - }
11.136 -
11.137 - @Override
11.138 - public MapIndices getIndexMapper(Iterable<? extends HintDescription> patterns) {
11.139 - MapIndices mapper;
11.140 -
11.141 - if (indexURL != null) {
11.142 - if (subIndex == null) {
11.143 - mapper = new MapIndices() {
11.144 - public IndexEnquirer findIndex(FileObject root, ProgressHandleWrapper progress, boolean recursive) {
11.145 - return new SimpleIndexIndexEnquirer(root, createOrUpdateIndex(root, new File(indexURL), update, progress, recursive));
11.146 - }
11.147 - };
11.148 - } else {
11.149 - mapper = new MapIndices() {
11.150 - public IndexEnquirer findIndex(FileObject root, ProgressHandleWrapper progress, boolean recursive) {
11.151 - progress.startNextPart(1);
11.152 - try {
11.153 - return new SimpleIndexIndexEnquirer(root, Index.createWithRemoteIndex(root.getURL(), indexURL, subIndex));
11.154 - } catch (FileStateInvalidException ex) {
11.155 - Exceptions.printStackTrace(ex);
11.156 - return null;
11.157 - }
11.158 - }
11.159 - };
11.160 - }
11.161 - } else {
11.162 - mapper = Scopes.getDefaultIndicesMapper();
11.163 - }
11.164 -
11.165 - return mapper;
11.166 - }
11.167 -
11.168 - }
11.169 -
11.170 - private static final class RemoteIndexScope extends Scope {
11.171 - @Override
11.172 - public String getDisplayName() {
11.173 - return "All Remote Indices";
11.174 - }
11.175 -
11.176 - @Override
11.177 - public Collection<? extends Folder> getTodo() {
11.178 - Collection<Folder> todo = new HashSet<Folder>();
11.179 -
11.180 - for (RemoteIndex remoteIndex : RemoteIndex.loadIndices()) {
11.181 - FileObject localFolder = URLMapper.findFileObject(remoteIndex.getLocalFolder());
11.182 -
11.183 - if (localFolder == null) continue;
11.184 - todo.add(new Folder(localFolder));
11.185 - }
11.186 -
11.187 - return todo;
11.188 - }
11.189 -
11.190 - @Override
11.191 - public MapIndices getIndexMapper(final Iterable<? extends HintDescription> patterns) {
11.192 - return new MapIndices() {
11.193 - public IndexEnquirer findIndex(FileObject root, ProgressHandleWrapper progress, boolean recursive) {
11.194 - for (RemoteIndex remoteIndex : RemoteIndex.loadIndices()) {
11.195 - FileObject localFolder = URLMapper.findFileObject(remoteIndex.getLocalFolder());
11.196 -
11.197 - if (localFolder == null) continue;
11.198 - if (localFolder == root) {
11.199 - return enquirerForRemoteIndex(root, remoteIndex, patterns);
11.200 - }
11.201 - }
11.202 - throw new IllegalStateException();
11.203 - }
11.204 - };
11.205 - }
11.206 - }
11.207 -
11.208 - private static Index createOrUpdateIndex(FileObject src, File indexRoot, boolean update, ProgressHandleWrapper progress, boolean recursive) {
11.209 - Index index;
11.210 -
11.211 - try {
11.212 - index = FileBasedIndex.create(src.getURL(), indexRoot);
11.213 - } catch (FileStateInvalidException ex) {
11.214 - throw new IllegalStateException(ex);
11.215 - }
11.216 -
11.217 - File timeStampsFile = new File(indexRoot, "timestamps.properties");
11.218 - Properties timeStamps = new Properties();
11.219 -
11.220 - if (timeStampsFile.exists()) {
11.221 - if (!update) {
11.222 - progress.startNextPart(1);
11.223 - return index;
11.224 - }
11.225 -
11.226 - InputStream in = null;
11.227 -
11.228 - try {
11.229 - in = new BufferedInputStream(new FileInputStream(timeStampsFile));
11.230 - timeStamps.load(in);
11.231 - } catch (IOException ex) {
11.232 - Exceptions.printStackTrace(ex);
11.233 - } finally {
11.234 - try {
11.235 - if (in != null)
11.236 - in.close();
11.237 - } catch (IOException ex) {
11.238 - Exceptions.printStackTrace(ex);
11.239 - }
11.240 - }
11.241 - }
11.242 -
11.243 - Collection<FileObject> collected = new LinkedList<FileObject>();
11.244 - Set<String> removed = new HashSet<String>(timeStamps.stringPropertyNames());
11.245 -
11.246 - org.netbeans.modules.java.hints.jackpot.impl.batch.BatchUtilities.recursive(src, src, collected, progress, 0, timeStamps, removed, recursive);
11.247 -
11.248 - CustomIndexerImpl.doIndex(src, collected, removed, index);
11.249 -
11.250 - OutputStream out = null;
11.251 -
11.252 - try {
11.253 - out = new BufferedOutputStream(new FileOutputStream(timeStampsFile));
11.254 - timeStamps.store(out, null);
11.255 - } catch (IOException ex) {
11.256 - Exceptions.printStackTrace(ex);
11.257 - } finally {
11.258 - try {
11.259 - if (out != null) {
11.260 - out.close();
11.261 - }
11.262 - } catch (IOException ex) {
11.263 - Exceptions.printStackTrace(ex);
11.264 - }
11.265 - }
11.266 -
11.267 - return index;
11.268 - }
11.269 -
11.270 - private static boolean isAttributedIndexWithSpans(RemoteIndex remoteIndex) {
11.271 - try {
11.272 - URI capabilitiesURI = new URI(remoteIndex.remote.toExternalForm() + "/capabilities");
11.273 - String capabilitiesString = WebUtilities.requestStringResponse(capabilitiesURI);
11.274 -
11.275 - if (capabilitiesURI == null) return false;
11.276 -
11.277 - @SuppressWarnings("unchecked")
11.278 - Map<String, Object> capabilities = Pojson.load(HashMap.class, capabilitiesString);
11.279 -
11.280 - return capabilities.get("attributed") == Boolean.TRUE; //TODO: should also check "methods contains findWithSpans"
11.281 - } catch (URISyntaxException ex) {
11.282 - LOG.log(Level.FINE, null, ex);
11.283 - return false;
11.284 - }
11.285 - }
11.286 -
11.287 - private static IndexEnquirer enquirerForRemoteIndex(FileObject src, RemoteIndex remoteIndex, Iterable<? extends HintDescription> hints) {
11.288 - boolean fullySupported = isAttributedIndexWithSpans(remoteIndex);
11.289 - StringBuilder textualRepresentation = new StringBuilder();
11.290 -
11.291 - for (HintDescription hd : hints) {
11.292 - if (!(hd.getTrigger() instanceof PatternDescription)) {
11.293 - fullySupported = false;
11.294 - break;
11.295 - }
11.296 -
11.297 - if (((PatternDescription) hd.getTrigger()).getImports().iterator().hasNext()) {
11.298 - fullySupported = false;
11.299 - }
11.300 -
11.301 - if (!fullySupported) break;
11.302 -
11.303 - String hintText = hd.getHintText();
11.304 -
11.305 - if (hintText != null) {
11.306 - textualRepresentation.append(hintText);
11.307 - } else {
11.308 - textualRepresentation.append(defaultHintText(hd));
11.309 - fullySupported = false;
11.310 - }
11.311 -
11.312 - textualRepresentation.append("\n");
11.313 - }
11.314 -
11.315 - if (fullySupported) {
11.316 - return new RemoteFullyAttributedIndexEnquirer(src, remoteIndex, textualRepresentation.toString());
11.317 - } else {
11.318 - try {
11.319 - return new SimpleIndexIndexEnquirer(src, Index.createWithRemoteIndex(src.getURL(), remoteIndex.remote.toExternalForm(), remoteIndex.remoteSegment));
11.320 - } catch (FileStateInvalidException ex) {
11.321 - throw new IllegalStateException(ex);
11.322 - }
11.323 - }
11.324 - }
11.325 -
11.326 - private static final class SimpleIndexIndexEnquirer extends LocalIndexEnquirer {
11.327 - private final Index idx;
11.328 - public SimpleIndexIndexEnquirer(FileObject src, Index idx) {
11.329 - super(src);
11.330 - this.idx = idx;
11.331 - }
11.332 - public Collection<? extends Resource> findResources(final Iterable<? extends HintDescription> hints, ProgressHandleWrapper progress, final Callable<BulkPattern> bulkPattern, final Collection<? super MessageImpl> problems) {
11.333 - final Collection<Resource> result = new ArrayList<Resource>();
11.334 -
11.335 - progress.startNextPart(1);
11.336 -
11.337 - try {
11.338 - BulkPattern bp = bulkPattern.call();
11.339 -
11.340 - for (String candidate : idx.findCandidates(bp)) {
11.341 - result.add(new Resource(this, candidate, hints, bp));
11.342 - }
11.343 - } catch (Exception ex) {
11.344 - Exceptions.printStackTrace(ex);
11.345 - }
11.346 -
11.347 - return result;
11.348 - }
11.349 -
11.350 - }
11.351 -
11.352 - private static final class RemoteFullyAttributedIndexEnquirer extends IndexEnquirer {
11.353 - private final RemoteIndex remoteIndex;
11.354 - private final String textualHintRepresentation;
11.355 - public RemoteFullyAttributedIndexEnquirer(FileObject src, RemoteIndex remoteIndex, String textualHintRepresentation) {
11.356 - super(src);
11.357 - assert isAttributedIndexWithSpans(remoteIndex);
11.358 - this.remoteIndex = remoteIndex;
11.359 - this.textualHintRepresentation = textualHintRepresentation;
11.360 - }
11.361 - public Collection<? extends Resource> findResources(final Iterable<? extends HintDescription> hints, ProgressHandleWrapper progress, final Callable<BulkPattern> bulkPattern, final Collection<? super MessageImpl> problems) {
11.362 - final Collection<Resource> result = new ArrayList<Resource>();
11.363 -
11.364 - progress.startNextPart(1);
11.365 -
11.366 - try {
11.367 - URI u = new URI(remoteIndex.remote.toExternalForm() + "/find?path=" + escapeForQuery(remoteIndex.remoteSegment) + "&pattern=" + escapeForQuery(textualHintRepresentation));
11.368 -
11.369 - for (String occurrence : new ArrayList<String>(WebUtilities.requestStringArrayResponse(u))) {
11.370 - try {
11.371 - BulkPattern bp = bulkPattern.call();
11.372 - result.add(new Resource(this, occurrence, hints, bp));
11.373 - } catch (Exception ex) {
11.374 - //from bulkPattern.call()? should not happen.
11.375 - Exceptions.printStackTrace(ex);
11.376 - }
11.377 - }
11.378 -
11.379 - } catch (URISyntaxException ex) {
11.380 - Exceptions.printStackTrace(ex);
11.381 - }
11.382 -
11.383 - return result;
11.384 - }
11.385 -
11.386 - @Override
11.387 - public void validateResource(Collection<? extends Resource> resources, ProgressHandleWrapper progress, VerifiedSpansCallBack callback, boolean doNotRegisterClassPath, Collection<? super MessageImpl> problems, AtomicBoolean cancel) {
11.388 - for (Resource r : resources) {
11.389 - try {
11.390 - URI spanURI = new URI(remoteIndex.remote.toExternalForm() + "/findSpans?path=" + escapeForQuery(remoteIndex.remoteSegment) + "&relativePath=" + escapeForQuery(r.getRelativePath()) + "&pattern=" + escapeForQuery(textualHintRepresentation));
11.391 - FileObject fo = r.getResolvedFile();
11.392 -
11.393 - if (fo == null) {
11.394 - callback.cannotVerifySpan(r);
11.395 - } else {
11.396 - List<ErrorDescription> result = new ArrayList<ErrorDescription>();
11.397 -
11.398 - for (int[] span : parseSpans(WebUtilities.requestStringResponse(spanURI))) {
11.399 - result.add(ErrorDescriptionFactory.createErrorDescription(Severity.WARNING, "Occurrence", fo, span[0], span[1]));
11.400 - }
11.401 -
11.402 - callback.spansVerified(null, r, result);
11.403 - }
11.404 - } catch (Exception ex) {
11.405 - Exceptions.printStackTrace(ex);
11.406 - }
11.407 - }
11.408 - }
11.409 -
11.410 - }
11.411 -
11.412 - private static Iterable<int[]> parseSpans(String from) {
11.413 - if (from.isEmpty()) {
11.414 - return Collections.emptyList();
11.415 - }
11.416 - String[] split = from.split(":");
11.417 - List<int[]> result = new LinkedList<int[]>();
11.418 -
11.419 - for (int i = 0; i < split.length; i += 2) {
11.420 - result.add(new int[] {
11.421 - Integer.parseInt(split[i + 0].trim()),
11.422 - Integer.parseInt(split[i + 1].trim())
11.423 - });
11.424 - }
11.425 -
11.426 - return result;
11.427 - }
11.428 -
11.429 - private static String defaultHintText(HintDescription hd) {
11.430 - StringBuilder result = new StringBuilder();
11.431 -
11.432 - PatternDescription pd = (PatternDescription) hd.getTrigger();
11.433 -
11.434 - if (pd == null) return null;
11.435 -
11.436 - if (pd.getImports().iterator().hasNext()) {
11.437 - //cannot currently handle patterns with imports:
11.438 - return null;
11.439 - }
11.440 -
11.441 - result.append(pd.getPattern());
11.442 -
11.443 - if (!pd.getConstraints().isEmpty()) {
11.444 - result.append(" :: ");
11.445 -
11.446 - for (Iterator<Entry<String, String>> it = pd.getConstraints().entrySet().iterator(); it.hasNext(); ) {
11.447 - Entry<String, String> e = it.next();
11.448 -
11.449 - result.append(e.getKey()).append(" instanceof ").append(e.getValue());
11.450 -
11.451 - if (it.hasNext()) {
11.452 - result.append(" && ");
11.453 - }
11.454 - }
11.455 - }
11.456 -
11.457 - result.append(";;\n");
11.458 -
11.459 - return result.toString();
11.460 - }
11.461 -}
12.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/batch/OptionProcessorImpl.java Fri Jan 27 13:35:56 2012 +0100
12.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
12.3 @@ -1,276 +0,0 @@
12.4 -/*
12.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
12.6 - *
12.7 - * Copyright 2008-2010 Sun Microsystems, Inc. All rights reserved.
12.8 - *
12.9 - * The contents of this file are subject to the terms of either the GNU
12.10 - * General Public License Version 2 only ("GPL") or the Common
12.11 - * Development and Distribution License("CDDL") (collectively, the
12.12 - * "License"). You may not use this file except in compliance with the
12.13 - * License. You can obtain a copy of the License at
12.14 - * http://www.netbeans.org/cddl-gplv2.html
12.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
12.16 - * specific language governing permissions and limitations under the
12.17 - * License. When distributing the software, include this License Header
12.18 - * Notice in each file and include the License file at
12.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
12.20 - * particular file as subject to the "Classpath" exception as provided
12.21 - * by Sun in the GPL Version 2 section of the License file that
12.22 - * accompanied this code. If applicable, add the following below the
12.23 - * License Header, with the fields enclosed by brackets [] replaced by
12.24 - * your own identifying information:
12.25 - * "Portions Copyrighted [year] [name of copyright owner]"
12.26 - *
12.27 - * If you wish your version of this file to be governed by only the CDDL
12.28 - * or only the GPL Version 2, indicate your decision by adding
12.29 - * "[Contributor] elects to include this software in this distribution
12.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
12.31 - * single choice of license, a recipient has the option to distribute
12.32 - * your version of this file under either the CDDL, the GPL Version 2 or
12.33 - * to extend the choice of license to its licensees as provided above.
12.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
12.35 - * Version 2 license, then the option applies only if the new code is
12.36 - * made subject to such option by the copyright holder.
12.37 - *
12.38 - * Contributor(s):
12.39 - *
12.40 - * Portions Copyrighted 2008-2010 Sun Microsystems, Inc.
12.41 - */
12.42 -
12.43 -package org.netbeans.modules.jackpot30.impl.batch;
12.44 -
12.45 -import java.io.File;
12.46 -import java.io.IOException;
12.47 -import java.util.ArrayList;
12.48 -import java.util.Arrays;
12.49 -import java.util.Collection;
12.50 -import java.util.HashMap;
12.51 -import java.util.HashSet;
12.52 -import java.util.LinkedList;
12.53 -import java.util.List;
12.54 -import java.util.Map;
12.55 -import java.util.Set;
12.56 -import java.util.TreeMap;
12.57 -import java.util.logging.Logger;
12.58 -import org.netbeans.api.java.classpath.ClassPath;
12.59 -import org.netbeans.api.java.source.ModificationResult;
12.60 -import org.netbeans.api.project.Project;
12.61 -import org.netbeans.api.project.ProjectManager;
12.62 -import org.netbeans.api.project.ProjectUtils;
12.63 -import org.netbeans.api.project.SourceGroup;
12.64 -import org.netbeans.api.project.ui.OpenProjects;
12.65 -import org.netbeans.api.sendopts.CommandException;
12.66 -import org.netbeans.modules.java.hints.jackpot.impl.MessageImpl;
12.67 -import org.netbeans.modules.java.hints.jackpot.impl.Utilities;
12.68 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch;
12.69 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.BatchResult;
12.70 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.Folder;
12.71 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchUtilities;
12.72 -import org.netbeans.modules.java.hints.jackpot.impl.batch.ProgressHandleWrapper;
12.73 -import org.netbeans.modules.java.hints.jackpot.impl.batch.Scopes;
12.74 -import org.netbeans.modules.java.hints.jackpot.spi.HintContext.MessageKind;
12.75 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
12.76 -import org.netbeans.spi.java.classpath.support.ClassPathSupport;
12.77 -import org.netbeans.spi.sendopts.Env;
12.78 -import org.netbeans.spi.sendopts.Option;
12.79 -import org.netbeans.spi.sendopts.OptionProcessor;
12.80 -import org.openide.filesystems.FileObject;
12.81 -import org.openide.filesystems.FileUtil;
12.82 -import org.openide.util.lookup.ServiceProvider;
12.83 -
12.84 -/**
12.85 - *
12.86 - * @author Jan Lahoda
12.87 - */
12.88 -@ServiceProvider(service=OptionProcessor.class)
12.89 -public class OptionProcessorImpl extends OptionProcessor {
12.90 -
12.91 - private static final Logger LOG = Logger.getLogger(OptionProcessorImpl.class.getName());
12.92 -
12.93 - private static final String APPLY_TRANSFORMATIONS_PROJECT_OPTION = "apply-transformations-project";
12.94 -
12.95 - private static final Option LIST = Option.withoutArgument(Option.NO_SHORT_NAME, "list-hints-transformation");
12.96 - private static final Option APPLY_TRANSFORMATIONS = Option.shortDescription(
12.97 - Option.requiredArgument(Option.NO_SHORT_NAME, "apply-transformations"),
12.98 - "org.netbeans.modules.jackpot30.impl.batch.Bundle",
12.99 - "SD_ApplyTransformations");
12.100 - private static final Option APPLY_TRANSFORMATIONS_PROJECT = Option.shortDescription(
12.101 - Option.additionalArguments(Option.NO_SHORT_NAME, APPLY_TRANSFORMATIONS_PROJECT_OPTION),
12.102 - "org.netbeans.modules.jackpot30.impl.batch.Bundle",
12.103 - "SD_ApplyTransformationsProject");
12.104 -
12.105 - private static final Set<Option> OPTIONS = new HashSet<Option>(Arrays.asList(LIST, APPLY_TRANSFORMATIONS, APPLY_TRANSFORMATIONS_PROJECT));
12.106 -
12.107 - @Override
12.108 - protected Set<Option> getOptions() {
12.109 - return OPTIONS;
12.110 - }
12.111 -
12.112 - @Override
12.113 - protected void process(Env env, Map<Option, String[]> optionValues) throws CommandException {
12.114 - List<Project> projects = new LinkedList<Project>();
12.115 - Map<String, List<ClassPath>> classPaths = new HashMap<String, List<ClassPath>>();
12.116 -
12.117 - if (optionValues.containsKey(APPLY_TRANSFORMATIONS_PROJECT)) {
12.118 - String[] projectNames = optionValues.get(APPLY_TRANSFORMATIONS_PROJECT);
12.119 -
12.120 - if (projectNames.length == 0) {
12.121 - env.getErrorStream().println("At least one parameter needed for " + APPLY_TRANSFORMATIONS_PROJECT_OPTION);
12.122 - throw new CommandException(1);
12.123 - }
12.124 -
12.125 - FileObject currentDirectory = FileUtil.toFileObject(env.getCurrentDirectory());
12.126 -
12.127 - OUTER: for (String p : projectNames) {
12.128 - FileObject projectFile = currentDirectory.getFileObject(p);
12.129 -
12.130 - if (projectFile == null) {
12.131 - projectFile = FileUtil.toFileObject(new File(p));
12.132 - }
12.133 -
12.134 - if (projectFile == null) {
12.135 - env.getErrorStream().println("Ignoring file " + p + " - cannot be found.");
12.136 - continue;
12.137 - }
12.138 -
12.139 - if (!projectFile.isFolder()) {
12.140 - env.getErrorStream().println("Ignoring file " + p + " - not a folder.");
12.141 - continue;
12.142 - }
12.143 -
12.144 - Project project = null;
12.145 - String error = null;
12.146 -
12.147 - try {
12.148 - project = ProjectManager.getDefault().findProject(projectFile);
12.149 - } catch (IOException ex) {
12.150 - error = ex.getLocalizedMessage();
12.151 - } catch (IllegalArgumentException ex) {
12.152 - error = ex.getLocalizedMessage();
12.153 - }
12.154 -
12.155 - if (project == null) {
12.156 - if (error == null) {
12.157 - env.getErrorStream().println("Ignoring file " + p + " - not a project.");
12.158 - } else {
12.159 - env.getErrorStream().println("Ignoring file " + p + " - not a project (" + error + ").");
12.160 - }
12.161 -
12.162 - continue;
12.163 - }
12.164 -
12.165 - for (SourceGroup sg : ProjectUtils.getSources(project).getSourceGroups("java")) {
12.166 - FileObject root = sg.getRootFolder();
12.167 -
12.168 - for (String type : Arrays.asList(ClassPath.BOOT, ClassPath.COMPILE, ClassPath.SOURCE)) {
12.169 - if (!handleClassPath(root, type, env, p, classPaths)) {
12.170 - continue OUTER;
12.171 - }
12.172 - }
12.173 - }
12.174 -
12.175 - projects.add(project);
12.176 - }
12.177 - } else {
12.178 - projects.addAll(Arrays.asList(OpenProjects.getDefault().getOpenProjects()));
12.179 - }
12.180 -
12.181 - if (optionValues.containsKey(LIST)) {
12.182 - env.getOutputStream().println("Supported Hints:");
12.183 -
12.184 - Set<ClassPath> cps = new HashSet<ClassPath>();
12.185 -
12.186 - for (List<ClassPath> c : classPaths.values()) {
12.187 - cps.addAll(c);
12.188 - }
12.189 -
12.190 - Set<String> displayNames = Utilities.sortOutHints(Utilities.listAllHints(cps), new TreeMap<String, Collection<HintDescription>>()).keySet();
12.191 -
12.192 - for (String displayName : displayNames) {
12.193 - env.getOutputStream().println(displayName);
12.194 - }
12.195 - }
12.196 -
12.197 - if (optionValues.containsKey(APPLY_TRANSFORMATIONS)) {
12.198 - String hintsArg = optionValues.get(APPLY_TRANSFORMATIONS)[0];
12.199 - List<HintDescription> hintDescriptions = new LinkedList<HintDescription>();
12.200 - Set<ClassPath> cps = new HashSet<ClassPath>();
12.201 -
12.202 - for (List<ClassPath> c : classPaths.values()) {
12.203 - cps.addAll(c);
12.204 - }
12.205 -
12.206 - Map<String, Collection<HintDescription>> sorted = Utilities.sortOutHints(Utilities.listAllHints(cps), new TreeMap<String, Collection<HintDescription>>());
12.207 -
12.208 - for (String hint : hintsArg.split(":")) {
12.209 - Collection<HintDescription> descs = sorted.get(hint);
12.210 -
12.211 - if (descs == null) {
12.212 - env.getErrorStream().println("Unknown hint: " + hint);
12.213 - continue;
12.214 - }
12.215 -
12.216 - hintDescriptions.addAll(descs);
12.217 - }
12.218 -
12.219 - Collection<Folder> roots = new ArrayList<Folder>();
12.220 -
12.221 - for (FileObject f : BatchUtilities.getSourceGroups(projects)) {
12.222 - roots.add(new Folder(f));
12.223 - }
12.224 -
12.225 - BatchResult candidates = BatchSearch.findOccurrences(hintDescriptions, Scopes.specifiedFoldersScope(roots.toArray(new Folder[0])));
12.226 - List<MessageImpl> problems = new LinkedList<MessageImpl>(candidates.problems);
12.227 - Collection<? extends ModificationResult> res = BatchUtilities.applyFixes(candidates, new ProgressHandleWrapper(100), null, problems);
12.228 - Set<FileObject> modified = new HashSet<FileObject>();
12.229 -
12.230 - for (ModificationResult mr : res) {
12.231 - try {
12.232 - mr.commit();
12.233 - } catch (IOException ex) {
12.234 - ex.printStackTrace(env.getErrorStream());
12.235 - problems.add(new MessageImpl(MessageKind.ERROR, "Cannot apply changes: " + ex.getLocalizedMessage()));
12.236 - }
12.237 - modified.addAll(mr.getModifiedFileObjects());
12.238 - }
12.239 -
12.240 - try {
12.241 - BatchUtilities.removeUnusedImports(modified);
12.242 - } catch (IOException ex) {
12.243 - ex.printStackTrace(env.getErrorStream());
12.244 - problems.add(new MessageImpl(MessageKind.ERROR, "Cannot remove unused imports: " + ex.getLocalizedMessage()));
12.245 - }
12.246 -
12.247 - if (!problems.isEmpty()) {
12.248 - env.getErrorStream().println("Problem encountered while applying the transformations:");
12.249 -
12.250 - for (MessageImpl problem : problems) {
12.251 - env.getErrorStream().println(problem.text);
12.252 - }
12.253 - }
12.254 - }
12.255 -
12.256 - }
12.257 -
12.258 - private boolean handleClassPath(FileObject root, String type, Env env, String p, Map<String, List<ClassPath>> classPaths) {
12.259 - ClassPath cp = ClassPath.getClassPath(root, type);
12.260 -
12.261 - if (cp == null) {
12.262 - env.getErrorStream().println("Ignoring file " + p + " - no " + type + " classpath for source group: " + FileUtil.getFileDisplayName(root));
12.263 - return false;
12.264 - }
12.265 -
12.266 - List<ClassPath> cps = classPaths.get(type);
12.267 -
12.268 - if (cps == null) {
12.269 - classPaths.put(type, cps = new LinkedList<ClassPath>());
12.270 - }
12.271 -
12.272 - cp = ClassPathSupport.createProxyClassPath(cp);
12.273 -
12.274 - cps.add(cp);
12.275 -
12.276 - return true;
12.277 - }
12.278 -
12.279 -}
13.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/duplicates/Bundle.properties Fri Jan 27 13:35:56 2012 +0100
13.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
13.3 @@ -1,3 +0,0 @@
13.4 -CTL_GlobalFindDuplicates=Global Find Duplicates
13.5 -DuplicatesListPanel.findMore.text=<html><body><a href="">Look for More</a>
13.6 -DuplicatesListPanel.progressLabel.text=
14.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/duplicates/ComputeDuplicates.java Fri Jan 27 13:35:56 2012 +0100
14.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
14.3 @@ -1,449 +0,0 @@
14.4 -/*
14.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
14.6 - *
14.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
14.8 - *
14.9 - * The contents of this file are subject to the terms of either the GNU
14.10 - * General Public License Version 2 only ("GPL") or the Common
14.11 - * Development and Distribution License("CDDL") (collectively, the
14.12 - * "License"). You may not use this file except in compliance with the
14.13 - * License. You can obtain a copy of the License at
14.14 - * http://www.netbeans.org/cddl-gplv2.html
14.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
14.16 - * specific language governing permissions and limitations under the
14.17 - * License. When distributing the software, include this License Header
14.18 - * Notice in each file and include the License file at
14.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
14.20 - * particular file as subject to the "Classpath" exception as provided
14.21 - * by Sun in the GPL Version 2 section of the License file that
14.22 - * accompanied this code. If applicable, add the following below the
14.23 - * License Header, with the fields enclosed by brackets [] replaced by
14.24 - * your own identifying information:
14.25 - * "Portions Copyrighted [year] [name of copyright owner]"
14.26 - *
14.27 - * If you wish your version of this file to be governed by only the CDDL
14.28 - * or only the GPL Version 2, indicate your decision by adding
14.29 - * "[Contributor] elects to include this software in this distribution
14.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
14.31 - * single choice of license, a recipient has the option to distribute
14.32 - * your version of this file under either the CDDL, the GPL Version 2 or
14.33 - * to extend the choice of license to its licensees as provided above.
14.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
14.35 - * Version 2 license, then the option applies only if the new code is
14.36 - * made subject to such option by the copyright holder.
14.37 - *
14.38 - * Contributor(s):
14.39 - *
14.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
14.41 - */
14.42 -package org.netbeans.modules.jackpot30.impl.duplicates;
14.43 -
14.44 -import com.sun.source.tree.CompilationUnitTree;
14.45 -import com.sun.source.tree.Tree;
14.46 -import com.sun.source.util.SourcePositions;
14.47 -import com.sun.source.util.TreePath;
14.48 -import com.sun.source.util.TreePathScanner;
14.49 -import com.sun.source.util.Trees;
14.50 -import java.io.ByteArrayOutputStream;
14.51 -import java.io.File;
14.52 -import java.io.IOException;
14.53 -import java.net.URL;
14.54 -import java.security.DigestOutputStream;
14.55 -import java.security.MessageDigest;
14.56 -import java.security.NoSuchAlgorithmException;
14.57 -import java.util.ArrayList;
14.58 -import java.util.Arrays;
14.59 -import java.util.BitSet;
14.60 -import java.util.Collection;
14.61 -import java.util.Collections;
14.62 -import java.util.Comparator;
14.63 -import java.util.HashMap;
14.64 -import java.util.HashSet;
14.65 -import java.util.Iterator;
14.66 -import java.util.LinkedHashMap;
14.67 -import java.util.LinkedList;
14.68 -import java.util.List;
14.69 -import java.util.Map;
14.70 -import java.util.Map.Entry;
14.71 -import java.util.NoSuchElementException;
14.72 -import java.util.Set;
14.73 -import java.util.TreeMap;
14.74 -import java.util.concurrent.atomic.AtomicBoolean;
14.75 -import javax.tools.JavaCompiler.CompilationTask;
14.76 -import org.apache.lucene.document.Document;
14.77 -import org.apache.lucene.index.IndexReader;
14.78 -import org.apache.lucene.index.MultiReader;
14.79 -import org.apache.lucene.index.Term;
14.80 -import org.apache.lucene.index.TermEnum;
14.81 -import org.apache.lucene.search.Collector;
14.82 -import org.apache.lucene.search.IndexSearcher;
14.83 -import org.apache.lucene.search.Query;
14.84 -import org.apache.lucene.search.Searcher;
14.85 -import org.apache.lucene.search.TermQuery;
14.86 -import org.apache.lucene.store.FSDirectory;
14.87 -import org.netbeans.api.annotations.common.CheckForNull;
14.88 -import org.netbeans.api.java.classpath.ClassPath;
14.89 -import org.netbeans.api.java.classpath.GlobalPathRegistry;
14.90 -import org.netbeans.api.java.source.CompilationInfo;
14.91 -import org.netbeans.api.progress.ProgressHandle;
14.92 -import org.netbeans.modules.jackpot30.impl.duplicates.indexing.DuplicatesCustomIndexerImpl;
14.93 -import org.netbeans.modules.jackpot30.impl.duplicates.indexing.DuplicatesIndex;
14.94 -import org.netbeans.modules.jackpot30.impl.indexing.AbstractLuceneIndex.BitSetCollector;
14.95 -import org.netbeans.modules.jackpot30.impl.indexing.Cache;
14.96 -import org.netbeans.modules.java.hints.jackpot.impl.Utilities;
14.97 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch;
14.98 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch.EncodingContext;
14.99 -import org.netbeans.modules.java.source.JavaSourceAccessor;
14.100 -import org.openide.filesystems.FileObject;
14.101 -import org.openide.filesystems.URLMapper;
14.102 -import org.openide.util.Exceptions;
14.103 -
14.104 -
14.105 -/**
14.106 - *
14.107 - * @author lahvac
14.108 - */
14.109 -public class ComputeDuplicates {
14.110 -
14.111 - public Iterator<? extends DuplicateDescription> computeDuplicatesForAllOpenedProjects(ProgressHandle progress, AtomicBoolean cancel) throws IOException {
14.112 - Set<URL> urls = new HashSet<URL>();
14.113 -
14.114 - for (ClassPath cp : GlobalPathRegistry.getDefault().getPaths(ClassPath.SOURCE)) {
14.115 - for (ClassPath.Entry e : cp.entries()) {
14.116 - urls.add(e.getURL());
14.117 - }
14.118 - }
14.119 -
14.120 - long start = System.currentTimeMillis();
14.121 - try {
14.122 - return computeDuplicates(urls, progress, cancel);
14.123 - } finally {
14.124 - System.err.println("duplicates for all open projects: " + (System.currentTimeMillis() - start));
14.125 - }
14.126 - }
14.127 -
14.128 - public Iterator<? extends DuplicateDescription> computeDuplicates(Set<URL> forURLs, ProgressHandle progress, AtomicBoolean cancel) throws IOException {
14.129 - Map<IndexReader, FileObject> readers2Roots = new LinkedHashMap<IndexReader, FileObject>();
14.130 -
14.131 - progress.progress("Updating indices");
14.132 -
14.133 - for (URL u : forURLs) {
14.134 - try {
14.135 - //TODO: needs to be removed for server mode
14.136 - new DuplicatesCustomIndexerImpl.FactoryImpl().updateIndex(u, cancel); //TODO: show updating progress to the user
14.137 -
14.138 - File cacheRoot = Cache.findCache(DuplicatesIndex.NAME, DuplicatesIndex.VERSION).findCacheRoot(u);
14.139 -
14.140 - File dir = new File(cacheRoot, "fulltext");
14.141 -
14.142 - if (dir.listFiles() != null && dir.listFiles().length > 0) {
14.143 - IndexReader reader = IndexReader.open(FSDirectory.open(dir), true);
14.144 -
14.145 - readers2Roots.put(reader, URLMapper.findFileObject(u));
14.146 - }
14.147 - } catch (IOException ex) {
14.148 - Exceptions.printStackTrace(ex);
14.149 - }
14.150 - }
14.151 -
14.152 - progress.progress("Searching for duplicates");
14.153 -
14.154 - MultiReader r = new MultiReader(readers2Roots.keySet().toArray(new IndexReader[0]));
14.155 -
14.156 - List<String> dd = new ArrayList<String>(getDuplicatedValues(r, "generalized", cancel));
14.157 -
14.158 - sortHashes(dd);
14.159 -
14.160 - //TODO: only show valuable duplicates?:
14.161 -// dd = dd.subList(0, dd.size() / 10 + 1);
14.162 -
14.163 - return new DuplicatesIterator(readers2Roots, dd, 2);
14.164 - }
14.165 -
14.166 - public static Iterator<? extends DuplicateDescription> XXXduplicatesOf(Map<IndexReader, FileObject> readers2Roots, Collection<String> hashes) {
14.167 - List<String> hashesList = new ArrayList<String>(hashes);
14.168 - sortHashes(hashesList);
14.169 - return new DuplicatesIterator(readers2Roots, hashesList, 1);
14.170 - }
14.171 -
14.172 - private static final class DuplicatesIterator implements Iterator<DuplicateDescription> {
14.173 - private final Map<IndexReader, FileObject> readers2Roots;
14.174 - private final Iterator<String> duplicateCandidates;
14.175 - private final int minDuplicates;
14.176 - private final List<DuplicateDescription> result = new LinkedList<DuplicateDescription>();
14.177 -
14.178 - public DuplicatesIterator(Map<IndexReader, FileObject> readers2Roots, Iterable<String> duplicateCandidates, int minDuplicates) {
14.179 - this.readers2Roots = readers2Roots;
14.180 - this.duplicateCandidates = duplicateCandidates.iterator();
14.181 - this.minDuplicates = minDuplicates;
14.182 - }
14.183 -
14.184 - private DuplicateDescription nextDescription() throws IOException {
14.185 - while (duplicateCandidates.hasNext()) {
14.186 - String longest = duplicateCandidates.next();
14.187 - List<Span> foundDuplicates = new LinkedList<Span>();
14.188 -
14.189 - Query query = new TermQuery(new Term("generalized", longest));
14.190 -
14.191 - for (Entry<IndexReader, FileObject> e : readers2Roots.entrySet()) {
14.192 - Searcher s = new IndexSearcher(e.getKey());
14.193 - BitSet matchingDocuments = new BitSet(e.getKey().maxDoc());
14.194 - Collector c = new BitSetCollector(matchingDocuments);
14.195 -
14.196 - s.search(query, c);
14.197 -
14.198 - for (int docNum = matchingDocuments.nextSetBit(0); docNum >= 0; docNum = matchingDocuments.nextSetBit(docNum + 1)) {
14.199 - final Document doc = e.getKey().document(docNum);
14.200 - int pos = Arrays.binarySearch(doc.getValues("generalized"), longest);
14.201 -
14.202 - if (pos < 0) {
14.203 - System.err.println("FOOBAR=" + pos);
14.204 - continue;
14.205 - }
14.206 -
14.207 - String spanSpec = doc.getValues("positions")[pos];
14.208 - String relPath = doc.getField("path").stringValue();
14.209 -
14.210 - for (String spanPart : spanSpec.split(";")) {
14.211 - Span span = Span.of(e.getValue().getFileObject(relPath), spanPart);
14.212 -
14.213 - if (span != null) {
14.214 - foundDuplicates.add(span);
14.215 - }
14.216 - }
14.217 - }
14.218 - }
14.219 -
14.220 - if (foundDuplicates.size() >= minDuplicates) {
14.221 - DuplicateDescription current = DuplicateDescription.of(foundDuplicates, getValue(longest), longest);
14.222 - boolean add = true;
14.223 -
14.224 - for (Iterator<DuplicateDescription> it = result.iterator(); it.hasNext();) {
14.225 - DuplicateDescription existing = it.next();
14.226 -
14.227 - if (subsumes(existing, current)) {
14.228 - add = false;
14.229 - break;
14.230 - }
14.231 -
14.232 - if (subsumes(current, existing)) {
14.233 - //can happen? (note that the duplicates are sorted by value)
14.234 - it.remove();
14.235 - }
14.236 - }
14.237 -
14.238 - if (add) {
14.239 - result.add(current);
14.240 - return current;
14.241 - }
14.242 - }
14.243 -
14.244 - }
14.245 - return null;
14.246 - }
14.247 -
14.248 - private DuplicateDescription next;
14.249 -
14.250 - public boolean hasNext() {
14.251 - if (next == null) {
14.252 - try {
14.253 - next = nextDescription();
14.254 - } catch (IOException ex) {
14.255 - Exceptions.printStackTrace(ex);
14.256 - }
14.257 - }
14.258 -
14.259 - return next != null;
14.260 - }
14.261 -
14.262 - public DuplicateDescription next() {
14.263 - if (!hasNext()) {
14.264 - throw new NoSuchElementException();
14.265 - }
14.266 -
14.267 - DuplicateDescription r = next;
14.268 -
14.269 - next = null;
14.270 - return r;
14.271 - }
14.272 -
14.273 - public void remove() {
14.274 - throw new UnsupportedOperationException("Not supported.");
14.275 - }
14.276 -
14.277 - }
14.278 -
14.279 - private static List<String> getDuplicatedValues(IndexReader ir, String field, AtomicBoolean cancel) throws IOException {
14.280 - List<String> values = new ArrayList<String>();
14.281 - TermEnum terms = ir.terms( new Term(field));
14.282 - //while (terms.next()) {
14.283 - do {
14.284 - if (cancel.get()) return Collections.emptyList();
14.285 -
14.286 - final Term term = terms.term();
14.287 -
14.288 - if ( !field.equals( term.field() ) ) {
14.289 - break;
14.290 - }
14.291 -
14.292 - if (terms.docFreq() < 2) continue;
14.293 -
14.294 - values.add(term.text());
14.295 - }
14.296 - while (terms.next());
14.297 - return values;
14.298 - }
14.299 -
14.300 - private static long getValue(String encoded) {
14.301 - return Long.parseLong(encoded.substring(encoded.lastIndexOf(":") + 1));
14.302 - }
14.303 -
14.304 - private static void sortHashes(List<String> hashes) {
14.305 - Collections.sort(hashes, new Comparator<String>() {
14.306 - public int compare(String arg0, String arg1) {
14.307 - return (int) Math.signum(getValue(arg1) - getValue(arg0));
14.308 - }
14.309 - });
14.310 - }
14.311 -
14.312 - private static boolean subsumes(DuplicateDescription bigger, DuplicateDescription smaller) {
14.313 - Set<FileObject> bFiles = new HashSet<FileObject>();
14.314 -
14.315 - for (Span s : bigger.dupes) {
14.316 - bFiles.add(s.file);
14.317 - }
14.318 -
14.319 - Set<FileObject> sFiles = new HashSet<FileObject>();
14.320 -
14.321 - for (Span s : smaller.dupes) {
14.322 - sFiles.add(s.file);
14.323 - }
14.324 -
14.325 - if (!bFiles.equals(sFiles)) return false;
14.326 -
14.327 - Span testAgainst = bigger.dupes.get(0);
14.328 -
14.329 - for (Span s : smaller.dupes) {
14.330 - if (s.file == testAgainst.file) {
14.331 - if ( (testAgainst.startOff <= s.startOff && testAgainst.endOff > s.endOff)
14.332 - || (testAgainst.startOff < s.startOff && testAgainst.endOff >= s.endOff)) {
14.333 - return true;
14.334 - }
14.335 - }
14.336 - }
14.337 -
14.338 - return false;
14.339 - }
14.340 -
14.341 - public static Map<String, long[]> encodeGeneralized(CompilationInfo info) {
14.342 - return encodeGeneralized(JavaSourceAccessor.getINSTANCE().getJavacTask(info), info.getCompilationUnit());
14.343 - }
14.344 -
14.345 - public static Map<String, long[]> encodeGeneralized(final CompilationTask task, final CompilationUnitTree cut) {
14.346 - final SourcePositions sp = Trees.instance(task).getSourcePositions();
14.347 - final Map<String, Collection<Long>> positions = new HashMap<String, Collection<Long>>();
14.348 -
14.349 - new TreePathScanner<Void, Void>() {
14.350 - @Override
14.351 - public Void scan(Tree tree, Void p) {
14.352 - if (tree == null) return null;
14.353 - if (getCurrentPath() != null) {
14.354 - Tree generalizedPattern = Utilities.generalizePattern(task, new TreePath(getCurrentPath(), tree));
14.355 - long value = Utilities.patternValue(generalizedPattern);
14.356 - if (value >= MINIMAL_VALUE) {
14.357 - {
14.358 - DigestOutputStream baos = null;
14.359 - try {
14.360 - baos = new DigestOutputStream(new ByteArrayOutputStream(), MessageDigest.getInstance("MD5"));
14.361 - final EncodingContext ec = new BulkSearch.EncodingContext(baos, true);
14.362 - BulkSearch.getDefault().encode( generalizedPattern, ec);
14.363 - StringBuilder text = new StringBuilder();
14.364 - byte[] bytes = baos.getMessageDigest().digest();
14.365 - for (int cntr = 0; cntr < 4; cntr++) {
14.366 - text.append(String.format("%02X", bytes[cntr]));
14.367 - }
14.368 - text.append(':').append(value);
14.369 - String enc = text.toString();
14.370 - Collection<Long> spanSpecs = positions.get(enc);
14.371 - if (spanSpecs == null) {
14.372 - positions.put(enc, spanSpecs = new LinkedList<Long>());
14.373 -// } else {
14.374 -// spanSpecs.append(";");
14.375 - }
14.376 - long start = sp.getStartPosition(cut, tree);
14.377 -// spanSpecs.append(start).append(":").append(sp.getEndPosition(cut, tree) - start);
14.378 - spanSpecs.add(start);
14.379 - spanSpecs.add(sp.getEndPosition(cut, tree));
14.380 - } catch (NoSuchAlgorithmException ex) {
14.381 - Exceptions.printStackTrace(ex);
14.382 - } finally {
14.383 - try {
14.384 - baos.close();
14.385 - } catch (IOException ex) {
14.386 - Exceptions.printStackTrace(ex);
14.387 - }
14.388 - }
14.389 - }
14.390 - }
14.391 - }
14.392 - return super.scan(tree, p);
14.393 - }
14.394 - }.scan(cut, null);
14.395 -
14.396 - Map<String, long[]> result = new TreeMap<String, long[]>();
14.397 -
14.398 - for (Entry<String, Collection<Long>> e : positions.entrySet()) {
14.399 - long[] spans = new long[e.getValue().size()];
14.400 - int idx = 0;
14.401 -
14.402 - for (Long l : e.getValue()) {
14.403 - spans[idx++] = l;
14.404 - }
14.405 -
14.406 - result.put(e.getKey(), spans);
14.407 - }
14.408 -
14.409 - return result;
14.410 - }
14.411 -
14.412 - private static final int MINIMAL_VALUE = 10;
14.413 -
14.414 - public static final class DuplicateDescription {
14.415 -
14.416 - public final List<Span> dupes;
14.417 - public final long value;
14.418 - public final String hash;
14.419 -
14.420 - private DuplicateDescription(List<Span> dupes, long value, String hash) {
14.421 - this.dupes = dupes;
14.422 - this.value = value;
14.423 - this.hash = hash;
14.424 - }
14.425 -
14.426 - public static DuplicateDescription of(List<Span> dupes, long value, String hash) {
14.427 - return new DuplicateDescription(dupes, value, hash);
14.428 - }
14.429 - }
14.430 -
14.431 - public static final class Span {
14.432 - public final FileObject file;
14.433 - public final int startOff;
14.434 - public final int endOff;
14.435 -
14.436 - public Span(FileObject file, int startOff, int endOff) {
14.437 - this.file = file;
14.438 - this.startOff = startOff;
14.439 - this.endOff = endOff;
14.440 - }
14.441 -
14.442 - public static @CheckForNull Span of(FileObject file, String spanSpec) {
14.443 - String[] split = spanSpec.split(":");
14.444 - int start = Integer.valueOf(split[0]);
14.445 - int end = start + Integer.valueOf(split[1]);
14.446 - if (start < 0 || end < 0) return null; //XXX
14.447 -
14.448 - return new Span(file, start, end);
14.449 - }
14.450 -
14.451 - }
14.452 -}
15.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/duplicates/DuplicatesListPanel.form Fri Jan 27 13:35:56 2012 +0100
15.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
15.3 @@ -1,189 +0,0 @@
15.4 -<?xml version="1.1" encoding="UTF-8" ?>
15.5 -
15.6 -<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
15.7 - <AuxValues>
15.8 - <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
15.9 - <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
15.10 - <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
15.11 - <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
15.12 - <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
15.13 - <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
15.14 - <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
15.15 - <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
15.16 - <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
15.17 - </AuxValues>
15.18 -
15.19 - <Layout>
15.20 - <DimensionLayout dim="0">
15.21 - <Group type="103" groupAlignment="0" attributes="0">
15.22 - <Group type="102" alignment="1" attributes="0">
15.23 - <EmptySpace max="-2" attributes="0"/>
15.24 - <Group type="103" groupAlignment="1" attributes="0">
15.25 - <Component id="mainSplit2" alignment="0" pref="906" max="32767" attributes="0"/>
15.26 - <Component id="jScrollPane1" alignment="0" pref="906" max="32767" attributes="0"/>
15.27 - <Component id="jPanel1" alignment="1" min="-2" max="-2" attributes="0"/>
15.28 - </Group>
15.29 - <EmptySpace max="-2" attributes="0"/>
15.30 - </Group>
15.31 - </Group>
15.32 - </DimensionLayout>
15.33 - <DimensionLayout dim="1">
15.34 - <Group type="103" groupAlignment="0" attributes="0">
15.35 - <Group type="102" attributes="0">
15.36 - <EmptySpace min="-2" max="-2" attributes="0"/>
15.37 - <Component id="jScrollPane1" min="-2" pref="67" max="-2" attributes="0"/>
15.38 - <EmptySpace min="-2" max="-2" attributes="0"/>
15.39 - <Component id="mainSplit2" pref="467" max="32767" attributes="0"/>
15.40 - <EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
15.41 - <Component id="jPanel1" min="-2" max="-2" attributes="0"/>
15.42 - <EmptySpace min="-2" max="-2" attributes="0"/>
15.43 - </Group>
15.44 - </Group>
15.45 - </DimensionLayout>
15.46 - </Layout>
15.47 - <SubComponents>
15.48 - <Container class="javax.swing.JScrollPane" name="jScrollPane1">
15.49 -
15.50 - <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
15.51 - <SubComponents>
15.52 - <Component class="javax.swing.JList" name="duplicatesList">
15.53 - <Properties>
15.54 - <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
15.55 - <StringArray count="0"/>
15.56 - </Property>
15.57 - <Property name="prototypeCellValue" type="java.lang.Object" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
15.58 - <Connection code=""9999999999999999999999999999999999999999999999999999999999999999999999"" type="code"/>
15.59 - </Property>
15.60 - <Property name="visibleRowCount" type="int" value="4"/>
15.61 - </Properties>
15.62 - </Component>
15.63 - </SubComponents>
15.64 - </Container>
15.65 - <Container class="javax.swing.JSplitPane" name="mainSplit2">
15.66 - <Properties>
15.67 - <Property name="dividerLocation" type="int" value="400"/>
15.68 - </Properties>
15.69 - <AuxValues>
15.70 - <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new BalancedSplitPane()"/>
15.71 - </AuxValues>
15.72 -
15.73 - <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
15.74 - <SubComponents>
15.75 - <Container class="javax.swing.JPanel" name="rightPanel">
15.76 - <Constraints>
15.77 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
15.78 - <JSplitPaneConstraints position="right"/>
15.79 - </Constraint>
15.80 - </Constraints>
15.81 -
15.82 - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
15.83 - <SubComponents>
15.84 - <Component class="javax.swing.JComboBox" name="rightFileList">
15.85 - <Properties>
15.86 - <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
15.87 - <StringArray count="0"/>
15.88 - </Property>
15.89 - </Properties>
15.90 - <Constraints>
15.91 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
15.92 - <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="2" ipadX="324" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="0.0"/>
15.93 - </Constraint>
15.94 - </Constraints>
15.95 - </Component>
15.96 - <Container class="javax.swing.JScrollPane" name="jScrollPane3">
15.97 - <AuxValues>
15.98 - <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
15.99 - </AuxValues>
15.100 - <Constraints>
15.101 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
15.102 - <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="1.0"/>
15.103 - </Constraint>
15.104 - </Constraints>
15.105 -
15.106 - <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
15.107 - <SubComponents>
15.108 - <Component class="javax.swing.JEditorPane" name="right">
15.109 - </Component>
15.110 - </SubComponents>
15.111 - </Container>
15.112 - </SubComponents>
15.113 - </Container>
15.114 - <Container class="javax.swing.JPanel" name="leftPanel">
15.115 - <Constraints>
15.116 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
15.117 - <JSplitPaneConstraints position="left"/>
15.118 - </Constraint>
15.119 - </Constraints>
15.120 -
15.121 - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
15.122 - <SubComponents>
15.123 - <Container class="javax.swing.JScrollPane" name="jScrollPane2">
15.124 - <AuxValues>
15.125 - <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
15.126 - </AuxValues>
15.127 - <Constraints>
15.128 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
15.129 - <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="1.0"/>
15.130 - </Constraint>
15.131 - </Constraints>
15.132 -
15.133 - <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
15.134 - <SubComponents>
15.135 - <Component class="javax.swing.JEditorPane" name="left">
15.136 - </Component>
15.137 - </SubComponents>
15.138 - </Container>
15.139 - <Component class="javax.swing.JComboBox" name="leftFileList">
15.140 - <Properties>
15.141 - <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
15.142 - <StringArray count="0"/>
15.143 - </Property>
15.144 - </Properties>
15.145 - <Constraints>
15.146 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
15.147 - <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="0.0"/>
15.148 - </Constraint>
15.149 - </Constraints>
15.150 - </Component>
15.151 - </SubComponents>
15.152 - </Container>
15.153 - </SubComponents>
15.154 - </Container>
15.155 - <Container class="javax.swing.JPanel" name="jPanel1">
15.156 -
15.157 - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
15.158 - <SubComponents>
15.159 - <Component class="javax.swing.JLabel" name="progressLabel">
15.160 - <Properties>
15.161 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
15.162 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/duplicates/Bundle.properties" key="DuplicatesListPanel.progressLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
15.163 - </Property>
15.164 - </Properties>
15.165 - <Constraints>
15.166 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
15.167 - <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="0.0"/>
15.168 - </Constraint>
15.169 - </Constraints>
15.170 - </Component>
15.171 - <Component class="javax.swing.JLabel" name="findMore">
15.172 - <Properties>
15.173 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
15.174 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/duplicates/Bundle.properties" key="DuplicatesListPanel.findMore.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
15.175 - </Property>
15.176 - <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
15.177 - <Color id="Hand Cursor"/>
15.178 - </Property>
15.179 - </Properties>
15.180 - <Events>
15.181 - <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="findMoreMouseClicked"/>
15.182 - </Events>
15.183 - <Constraints>
15.184 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
15.185 - <GridBagConstraints gridX="1" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="6" insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
15.186 - </Constraint>
15.187 - </Constraints>
15.188 - </Component>
15.189 - </SubComponents>
15.190 - </Container>
15.191 - </SubComponents>
15.192 -</Form>
16.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/duplicates/DuplicatesListPanel.java Fri Jan 27 13:35:56 2012 +0100
16.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
16.3 @@ -1,464 +0,0 @@
16.4 -/*
16.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
16.6 - *
16.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
16.8 - *
16.9 - * The contents of this file are subject to the terms of either the GNU
16.10 - * General Public License Version 2 only ("GPL") or the Common
16.11 - * Development and Distribution License("CDDL") (collectively, the
16.12 - * "License"). You may not use this file except in compliance with the
16.13 - * License. You can obtain a copy of the License at
16.14 - * http://www.netbeans.org/cddl-gplv2.html
16.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16.16 - * specific language governing permissions and limitations under the
16.17 - * License. When distributing the software, include this License Header
16.18 - * Notice in each file and include the License file at
16.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
16.20 - * particular file as subject to the "Classpath" exception as provided
16.21 - * by Sun in the GPL Version 2 section of the License file that
16.22 - * accompanied this code. If applicable, add the following below the
16.23 - * License Header, with the fields enclosed by brackets [] replaced by
16.24 - * your own identifying information:
16.25 - * "Portions Copyrighted [year] [name of copyright owner]"
16.26 - *
16.27 - * If you wish your version of this file to be governed by only the CDDL
16.28 - * or only the GPL Version 2, indicate your decision by adding
16.29 - * "[Contributor] elects to include this software in this distribution
16.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
16.31 - * single choice of license, a recipient has the option to distribute
16.32 - * your version of this file under either the CDDL, the GPL Version 2 or
16.33 - * to extend the choice of license to its licensees as provided above.
16.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
16.35 - * Version 2 license, then the option applies only if the new code is
16.36 - * made subject to such option by the copyright holder.
16.37 - *
16.38 - * Contributor(s):
16.39 - *
16.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
16.41 - */
16.42 -package org.netbeans.modules.jackpot30.impl.duplicates;
16.43 -
16.44 -import java.awt.Color;
16.45 -import java.awt.Component;
16.46 -import java.awt.Rectangle;
16.47 -import java.awt.event.ActionEvent;
16.48 -import java.awt.event.ActionListener;
16.49 -import java.io.IOException;
16.50 -import java.util.Collection;
16.51 -import java.util.Iterator;
16.52 -import java.util.LinkedHashSet;
16.53 -import java.util.Set;
16.54 -import javax.swing.DefaultComboBoxModel;
16.55 -import javax.swing.DefaultListCellRenderer;
16.56 -import javax.swing.DefaultListModel;
16.57 -import javax.swing.JEditorPane;
16.58 -import javax.swing.JList;
16.59 -import javax.swing.JSplitPane;
16.60 -import javax.swing.SwingUtilities;
16.61 -import javax.swing.event.ListSelectionEvent;
16.62 -import javax.swing.event.ListSelectionListener;
16.63 -import javax.swing.text.AttributeSet;
16.64 -import javax.swing.text.BadLocationException;
16.65 -import javax.swing.text.StyleConstants;
16.66 -import org.netbeans.api.editor.mimelookup.MimePath;
16.67 -import org.netbeans.api.editor.settings.AttributesUtilities;
16.68 -import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.DuplicateDescription;
16.69 -import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.Span;
16.70 -import org.netbeans.spi.editor.highlighting.HighlightsLayer;
16.71 -import org.netbeans.spi.editor.highlighting.HighlightsLayerFactory;
16.72 -import org.netbeans.spi.editor.highlighting.ZOrder;
16.73 -import org.netbeans.spi.editor.highlighting.support.OffsetsBag;
16.74 -import org.netbeans.spi.editor.mimelookup.MimeDataProvider;
16.75 -import org.openide.filesystems.FileObject;
16.76 -import org.openide.filesystems.FileUtil;
16.77 -import org.openide.util.Exceptions;
16.78 -import org.openide.util.Lookup;
16.79 -import org.openide.util.RequestProcessor;
16.80 -import org.openide.util.RequestProcessor.Task;
16.81 -import org.openide.util.lookup.Lookups;
16.82 -import org.openide.util.lookup.ServiceProvider;
16.83 -
16.84 -/**
16.85 - *
16.86 - * @author lahvac
16.87 - */
16.88 -public class DuplicatesListPanel extends javax.swing.JPanel {
16.89 - private final Collection<String> sourceRoots;
16.90 - private final Iterator<? extends DuplicateDescription> dupes;
16.91 -
16.92 - private int targetCount;
16.93 -
16.94 - public DuplicatesListPanel(Collection<String> sourceRoots, final Iterator<? extends DuplicateDescription> dupes) {
16.95 - this.sourceRoots = sourceRoots;
16.96 - this.dupes = dupes;
16.97 -
16.98 - initComponents();
16.99 -
16.100 - left.setContentType("text/x-java");
16.101 - left.putClientProperty(DuplicatesListPanel.class, new OffsetsBag(left.getDocument()));
16.102 -
16.103 - right.setContentType("text/x-java");
16.104 - right.putClientProperty(DuplicatesListPanel.class, new OffsetsBag(right.getDocument()));
16.105 -
16.106 - duplicatesList.setModel(new DefaultListModel());
16.107 - duplicatesList.setCellRenderer(new DuplicatesRendererImpl());
16.108 - duplicatesList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
16.109 - public void valueChanged(ListSelectionEvent arg0) {
16.110 - DuplicateDescription dd = (DuplicateDescription) duplicatesList.getSelectedValue();
16.111 - DefaultComboBoxModel l = new DefaultComboBoxModel();
16.112 - DefaultComboBoxModel r = new DefaultComboBoxModel();
16.113 -
16.114 - for (Span s : dd.dupes) {
16.115 - l.addElement(s);
16.116 - r.addElement(s);
16.117 - }
16.118 -
16.119 - leftFileList.setModel(l);
16.120 - rightFileList.setModel(r);
16.121 -
16.122 - leftFileList.setSelectedIndex(0);
16.123 - rightFileList.setSelectedIndex(1);
16.124 - }
16.125 - });
16.126 -
16.127 - leftFileList.setRenderer(new SpanRendererImpl());
16.128 - leftFileList.addActionListener(new ActionListener() {
16.129 -
16.130 - public void actionPerformed(ActionEvent e) {
16.131 - setSpan(left, (Span) leftFileList.getSelectedItem());
16.132 - }
16.133 - });
16.134 - rightFileList.setRenderer(new SpanRendererImpl());
16.135 - rightFileList.addActionListener(new ActionListener() {
16.136 - public void actionPerformed(ActionEvent e) {
16.137 - setSpan(right, (Span) rightFileList.getSelectedItem());
16.138 - }
16.139 - });
16.140 -
16.141 - progressLabel.setText("Looking for duplicates...");
16.142 -
16.143 - findMore();
16.144 - }
16.145 -
16.146 - /** This method is called from within the constructor to
16.147 - * initialize the form.
16.148 - * WARNING: Do NOT modify this code. The content of this method is
16.149 - * always regenerated by the Form Editor.
16.150 - */
16.151 - @SuppressWarnings("unchecked")
16.152 - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
16.153 - private void initComponents() {
16.154 - java.awt.GridBagConstraints gridBagConstraints;
16.155 -
16.156 - jScrollPane1 = new javax.swing.JScrollPane();
16.157 - duplicatesList = new javax.swing.JList();
16.158 - mainSplit2 = new BalancedSplitPane();
16.159 - rightPanel = new javax.swing.JPanel();
16.160 - rightFileList = new javax.swing.JComboBox();
16.161 - jScrollPane3 = new javax.swing.JScrollPane();
16.162 - right = new javax.swing.JEditorPane();
16.163 - leftPanel = new javax.swing.JPanel();
16.164 - jScrollPane2 = new javax.swing.JScrollPane();
16.165 - left = new javax.swing.JEditorPane();
16.166 - leftFileList = new javax.swing.JComboBox();
16.167 - jPanel1 = new javax.swing.JPanel();
16.168 - progressLabel = new javax.swing.JLabel();
16.169 - findMore = new javax.swing.JLabel();
16.170 -
16.171 - duplicatesList.setPrototypeCellValue("9999999999999999999999999999999999999999999999999999999999999999999999");
16.172 - duplicatesList.setVisibleRowCount(4);
16.173 - jScrollPane1.setViewportView(duplicatesList);
16.174 -
16.175 - mainSplit2.setDividerLocation(400);
16.176 -
16.177 - rightPanel.setLayout(new java.awt.GridBagLayout());
16.178 -
16.179 - gridBagConstraints = new java.awt.GridBagConstraints();
16.180 - gridBagConstraints.gridx = 0;
16.181 - gridBagConstraints.gridy = 0;
16.182 - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
16.183 - gridBagConstraints.ipadx = 324;
16.184 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
16.185 - gridBagConstraints.weightx = 1.0;
16.186 - rightPanel.add(rightFileList, gridBagConstraints);
16.187 -
16.188 - jScrollPane3.setViewportView(right);
16.189 -
16.190 - gridBagConstraints = new java.awt.GridBagConstraints();
16.191 - gridBagConstraints.gridx = 0;
16.192 - gridBagConstraints.gridy = 1;
16.193 - gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
16.194 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
16.195 - gridBagConstraints.weightx = 1.0;
16.196 - gridBagConstraints.weighty = 1.0;
16.197 - gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
16.198 - rightPanel.add(jScrollPane3, gridBagConstraints);
16.199 -
16.200 - mainSplit2.setRightComponent(rightPanel);
16.201 -
16.202 - leftPanel.setLayout(new java.awt.GridBagLayout());
16.203 -
16.204 - jScrollPane2.setViewportView(left);
16.205 -
16.206 - gridBagConstraints = new java.awt.GridBagConstraints();
16.207 - gridBagConstraints.gridx = 0;
16.208 - gridBagConstraints.gridy = 1;
16.209 - gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
16.210 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
16.211 - gridBagConstraints.weightx = 1.0;
16.212 - gridBagConstraints.weighty = 1.0;
16.213 - gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
16.214 - leftPanel.add(jScrollPane2, gridBagConstraints);
16.215 -
16.216 - gridBagConstraints = new java.awt.GridBagConstraints();
16.217 - gridBagConstraints.gridx = 0;
16.218 - gridBagConstraints.gridy = 0;
16.219 - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
16.220 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
16.221 - gridBagConstraints.weightx = 1.0;
16.222 - leftPanel.add(leftFileList, gridBagConstraints);
16.223 -
16.224 - mainSplit2.setLeftComponent(leftPanel);
16.225 -
16.226 - jPanel1.setLayout(new java.awt.GridBagLayout());
16.227 -
16.228 - progressLabel.setText(org.openide.util.NbBundle.getMessage(DuplicatesListPanel.class, "DuplicatesListPanel.progressLabel.text")); // NOI18N
16.229 - gridBagConstraints = new java.awt.GridBagConstraints();
16.230 - gridBagConstraints.gridx = 0;
16.231 - gridBagConstraints.gridy = 0;
16.232 - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
16.233 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
16.234 - gridBagConstraints.weightx = 1.0;
16.235 - jPanel1.add(progressLabel, gridBagConstraints);
16.236 -
16.237 - findMore.setText(org.openide.util.NbBundle.getMessage(DuplicatesListPanel.class, "DuplicatesListPanel.findMore.text")); // NOI18N
16.238 - findMore.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
16.239 - findMore.addMouseListener(new java.awt.event.MouseAdapter() {
16.240 - public void mouseClicked(java.awt.event.MouseEvent evt) {
16.241 - findMoreMouseClicked(evt);
16.242 - }
16.243 - });
16.244 - gridBagConstraints = new java.awt.GridBagConstraints();
16.245 - gridBagConstraints.gridx = 1;
16.246 - gridBagConstraints.gridy = 0;
16.247 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
16.248 - gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0);
16.249 - jPanel1.add(findMore, gridBagConstraints);
16.250 -
16.251 - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
16.252 - this.setLayout(layout);
16.253 - layout.setHorizontalGroup(
16.254 - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
16.255 - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
16.256 - .addContainerGap()
16.257 - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
16.258 - .addComponent(mainSplit2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 906, Short.MAX_VALUE)
16.259 - .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 906, Short.MAX_VALUE)
16.260 - .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
16.261 - .addContainerGap())
16.262 - );
16.263 - layout.setVerticalGroup(
16.264 - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
16.265 - .addGroup(layout.createSequentialGroup()
16.266 - .addContainerGap()
16.267 - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
16.268 - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
16.269 - .addComponent(mainSplit2, javax.swing.GroupLayout.DEFAULT_SIZE, 467, Short.MAX_VALUE)
16.270 - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
16.271 - .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
16.272 - .addContainerGap())
16.273 - );
16.274 - }// </editor-fold>//GEN-END:initComponents
16.275 -
16.276 - private void findMoreMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_findMoreMouseClicked
16.277 - findMore();
16.278 - }//GEN-LAST:event_findMoreMouseClicked
16.279 -
16.280 - private void findMore() {
16.281 - targetCount = duplicatesList.getModel().getSize() + 100;
16.282 - findMore.setVisible(false);
16.283 - WORKER.schedule(0);
16.284 - }
16.285 -
16.286 - private static String computeCommonPrefix(String origCommonPrefix, FileObject file) {
16.287 - String name = FileUtil.getFileDisplayName(file);
16.288 -
16.289 - if (origCommonPrefix == null) return name;
16.290 -
16.291 - int len = Math.min(origCommonPrefix.length(), name.length());
16.292 -
16.293 - for (int cntr = 0; cntr < len; cntr++) {
16.294 - if (origCommonPrefix.charAt(cntr) != name.charAt(cntr)) {
16.295 - return origCommonPrefix.substring(0, cntr);
16.296 - }
16.297 - }
16.298 -
16.299 - return origCommonPrefix;
16.300 - }
16.301 -
16.302 - private static void setSpan(JEditorPane pane, Span s) {
16.303 - try {
16.304 - pane.setText(s.file.asText());
16.305 -
16.306 - Rectangle top = pane.modelToView(0);
16.307 - Rectangle start = pane.modelToView(s.startOff);
16.308 - Rectangle end = pane.modelToView(s.endOff);
16.309 -
16.310 - if (top != null && start != null && end != null) {
16.311 - Rectangle toScroll = start.union(end);
16.312 -
16.313 - pane.scrollRectToVisible(top);
16.314 - pane.scrollRectToVisible(toScroll);
16.315 - }
16.316 -
16.317 - OffsetsBag bag = (OffsetsBag) pane.getClientProperty(DuplicatesListPanel.class);
16.318 -
16.319 - bag.clear();
16.320 - bag.addHighlight(s.startOff, s.endOff, HIGHLIGHT);
16.321 - } catch (IOException ex) {
16.322 - Exceptions.printStackTrace(ex);
16.323 - } catch (BadLocationException ex) {
16.324 - Exceptions.printStackTrace(ex);
16.325 - }
16.326 - }
16.327 -
16.328 - private static final AttributeSet HIGHLIGHT = AttributesUtilities.createImmutable(StyleConstants.Background, new Color(0xDF, 0xDF, 0xDF, 0xff));
16.329 -
16.330 - private final class DuplicatesRendererImpl extends DefaultListCellRenderer {
16.331 - @Override
16.332 - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
16.333 - if (!(value instanceof DuplicateDescription)) return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
16.334 - DuplicateDescription dd = (DuplicateDescription) value;
16.335 - Set<FileObject> files = new LinkedHashSet<FileObject>();
16.336 - String commonPrefix = null;
16.337 -
16.338 - for (Span s : dd.dupes) {
16.339 - commonPrefix = computeCommonPrefix(commonPrefix, s.file);
16.340 - files.add(s.file);
16.341 - }
16.342 -
16.343 - StringBuilder cap = new StringBuilder();
16.344 -
16.345 - OUTER: for (FileObject file : files) {
16.346 - String name = FileUtil.getFileDisplayName(file);
16.347 -
16.348 - if (cap.length() > 0) {
16.349 - cap.append(" ");
16.350 - }
16.351 -
16.352 - for (String sr : sourceRoots) {
16.353 - if (name.startsWith(sr)) {
16.354 - cap.append(name.substring(Math.max(0, sr.lastIndexOf('/') + 1)));
16.355 - continue OUTER;
16.356 - }
16.357 - }
16.358 - }
16.359 -
16.360 - return super.getListCellRendererComponent(list, cap.toString(), index, isSelected, cellHasFocus);
16.361 - }
16.362 - }
16.363 -
16.364 - private final class SpanRendererImpl extends DefaultListCellRenderer {
16.365 - @Override
16.366 - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
16.367 - if (!(value instanceof Span)) {
16.368 - return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
16.369 - }
16.370 - Span span = (Span) value;
16.371 -
16.372 - return super.getListCellRendererComponent(list, FileUtil.getFileDisplayName(span.file), index, isSelected, cellHasFocus);
16.373 - }
16.374 - }
16.375 -
16.376 - public static final class HighlightLayerFactoryImpl implements HighlightsLayerFactory {
16.377 - public HighlightsLayer[] createLayers(Context cntxt) {
16.378 - OffsetsBag bag = (OffsetsBag) cntxt.getComponent().getClientProperty(DuplicatesListPanel.class);
16.379 -
16.380 - if (bag != null) {
16.381 - return new HighlightsLayer[] {
16.382 - HighlightsLayer.create(DuplicatesListPanel.class.getName(), ZOrder.CARET_RACK, true, bag)
16.383 - };
16.384 - }
16.385 -
16.386 - return new HighlightsLayer[0];
16.387 - }
16.388 - }
16.389 -
16.390 - @ServiceProvider(service=MimeDataProvider.class)
16.391 - public static final class MDPI implements MimeDataProvider {
16.392 -
16.393 - private static final Lookup L = Lookups.singleton(new HighlightLayerFactoryImpl());
16.394 -
16.395 - public Lookup getLookup(MimePath mp) {
16.396 - if (mp.getPath().startsWith("text/x-java")) {
16.397 - return L;
16.398 - }
16.399 -
16.400 - return null;
16.401 - }
16.402 -
16.403 - }
16.404 -
16.405 - private static final class BalancedSplitPane extends JSplitPane {
16.406 -
16.407 - @Override
16.408 - @SuppressWarnings("deprecation")
16.409 - public void reshape(int x, int y, int w, int h) {
16.410 - super.reshape(x, y, w, h);
16.411 - SwingUtilities.invokeLater(new Runnable() {
16.412 - public void run() {
16.413 - setDividerLocation(0.5);
16.414 - }
16.415 - });
16.416 - }
16.417 -
16.418 - }
16.419 -
16.420 - // Variables declaration - do not modify//GEN-BEGIN:variables
16.421 - private javax.swing.JList duplicatesList;
16.422 - private javax.swing.JLabel findMore;
16.423 - private javax.swing.JPanel jPanel1;
16.424 - private javax.swing.JScrollPane jScrollPane1;
16.425 - private javax.swing.JScrollPane jScrollPane2;
16.426 - private javax.swing.JScrollPane jScrollPane3;
16.427 - private javax.swing.JEditorPane left;
16.428 - private javax.swing.JComboBox leftFileList;
16.429 - private javax.swing.JPanel leftPanel;
16.430 - private javax.swing.JSplitPane mainSplit2;
16.431 - private javax.swing.JLabel progressLabel;
16.432 - private javax.swing.JEditorPane right;
16.433 - private javax.swing.JComboBox rightFileList;
16.434 - private javax.swing.JPanel rightPanel;
16.435 - // End of variables declaration//GEN-END:variables
16.436 -
16.437 - private static final RequestProcessor DEFAULT_WORKER = new RequestProcessor(DuplicatesListPanel.class.getName(), 1, false, false);
16.438 - private final Task WORKER = DEFAULT_WORKER.create(new Runnable() {
16.439 - public void run() {
16.440 - if (dupes.hasNext()) {
16.441 - final DuplicateDescription dd = dupes.next();
16.442 -
16.443 - SwingUtilities.invokeLater(new Runnable() {
16.444 -
16.445 - public void run() {
16.446 - ((DefaultListModel)duplicatesList.getModel()).addElement(dd);
16.447 -
16.448 - int size = duplicatesList.getModel().getSize();
16.449 -
16.450 - if (size == 1) {
16.451 - duplicatesList.setSelectedIndex(0);
16.452 - }
16.453 -
16.454 - if (size >= targetCount) {
16.455 - findMore.setVisible(true);
16.456 - progressLabel.setText("Found " + size + " duplicated snippets.");
16.457 - } else {
16.458 - progressLabel.setText("Found " + size + " duplicated snippets and searching...");
16.459 - WORKER.schedule(0);
16.460 - }
16.461 - }
16.462 - });
16.463 - }
16.464 - }
16.465 - });
16.466 -
16.467 -}
17.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/duplicates/GlobalFindDuplicates.java Fri Jan 27 13:35:56 2012 +0100
17.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
17.3 @@ -1,179 +0,0 @@
17.4 -/*
17.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
17.6 - *
17.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
17.8 - *
17.9 - * The contents of this file are subject to the terms of either the GNU
17.10 - * General Public License Version 2 only ("GPL") or the Common
17.11 - * Development and Distribution License("CDDL") (collectively, the
17.12 - * "License"). You may not use this file except in compliance with the
17.13 - * License. You can obtain a copy of the License at
17.14 - * http://www.netbeans.org/cddl-gplv2.html
17.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
17.16 - * specific language governing permissions and limitations under the
17.17 - * License. When distributing the software, include this License Header
17.18 - * Notice in each file and include the License file at
17.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17.20 - * particular file as subject to the "Classpath" exception as provided
17.21 - * by Sun in the GPL Version 2 section of the License file that
17.22 - * accompanied this code. If applicable, add the following below the
17.23 - * License Header, with the fields enclosed by brackets [] replaced by
17.24 - * your own identifying information:
17.25 - * "Portions Copyrighted [year] [name of copyright owner]"
17.26 - *
17.27 - * If you wish your version of this file to be governed by only the CDDL
17.28 - * or only the GPL Version 2, indicate your decision by adding
17.29 - * "[Contributor] elects to include this software in this distribution
17.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
17.31 - * single choice of license, a recipient has the option to distribute
17.32 - * your version of this file under either the CDDL, the GPL Version 2 or
17.33 - * to extend the choice of license to its licensees as provided above.
17.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
17.35 - * Version 2 license, then the option applies only if the new code is
17.36 - * made subject to such option by the copyright holder.
17.37 - *
17.38 - * Contributor(s):
17.39 - *
17.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
17.41 - */
17.42 -package org.netbeans.modules.jackpot30.impl.duplicates;
17.43 -
17.44 -import java.awt.Dialog;
17.45 -import java.awt.GridBagConstraints;
17.46 -import java.awt.GridBagLayout;
17.47 -import java.awt.Insets;
17.48 -import java.awt.event.ActionEvent;
17.49 -import java.awt.event.ActionListener;
17.50 -import java.io.IOException;
17.51 -import java.util.Collection;
17.52 -import java.util.Iterator;
17.53 -import java.util.LinkedList;
17.54 -import java.util.concurrent.atomic.AtomicBoolean;
17.55 -import javax.swing.JLabel;
17.56 -import javax.swing.JPanel;
17.57 -import javax.swing.SwingUtilities;
17.58 -import org.netbeans.api.java.classpath.ClassPath;
17.59 -import org.netbeans.api.java.classpath.GlobalPathRegistry;
17.60 -import org.netbeans.api.progress.ProgressHandle;
17.61 -import org.netbeans.api.progress.ProgressHandleFactory;
17.62 -import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.DuplicateDescription;
17.63 -import org.openide.DialogDescriptor;
17.64 -import org.openide.DialogDisplayer;
17.65 -import org.openide.NotifyDescriptor;
17.66 -import org.openide.filesystems.FileObject;
17.67 -import org.openide.filesystems.FileUtil;
17.68 -import org.openide.util.Exceptions;
17.69 -import org.openide.util.HelpCtx;
17.70 -import org.openide.util.RequestProcessor;
17.71 -
17.72 -public final class GlobalFindDuplicates implements ActionListener {
17.73 -
17.74 - public void actionPerformed(ActionEvent e) {
17.75 - final Iterator<? extends DuplicateDescription>[] dupes = new Iterator[1];
17.76 - final ProgressHandle handle = ProgressHandleFactory.createHandle("Compute Duplicates");
17.77 - JPanel panel = createPanel(handle);
17.78 - final AtomicBoolean cancel = new AtomicBoolean();
17.79 - DialogDescriptor w = new DialogDescriptor(panel, "Computing Duplicates", true, new Object[] {DialogDescriptor.CANCEL_OPTION}, DialogDescriptor.CANCEL_OPTION, DialogDescriptor.DEFAULT_ALIGN, HelpCtx.DEFAULT_HELP, new ActionListener() {
17.80 - public void actionPerformed(ActionEvent e) {
17.81 - cancel.set(true);
17.82 - }
17.83 - });
17.84 -
17.85 - w.setClosingOptions(null);
17.86 -
17.87 - final Dialog d = DialogDisplayer.getDefault().createDialog(w);
17.88 - final AtomicBoolean done = new AtomicBoolean();
17.89 - final Collection<String> sourceRoots = new LinkedList<String>();
17.90 -
17.91 - WORKER.post(new Runnable() {
17.92 - public void run() {
17.93 - try {
17.94 - for (ClassPath cp : GlobalPathRegistry.getDefault().getPaths(ClassPath.SOURCE)) {
17.95 - for (ClassPath.Entry e : cp.entries()) {
17.96 - FileObject root = e.getRoot();
17.97 -
17.98 - if (root == null) continue;
17.99 -
17.100 - sourceRoots.add(FileUtil.getFileDisplayName(root));
17.101 - }
17.102 - }
17.103 -
17.104 - dupes[0] = new ComputeDuplicates().computeDuplicatesForAllOpenedProjects(handle, cancel);
17.105 - done.set(true);
17.106 - } catch (IOException ex) {
17.107 - Exceptions.printStackTrace(ex);
17.108 - } finally {
17.109 - handle.finish();
17.110 -
17.111 - SwingUtilities.invokeLater(new Runnable() {
17.112 - public void run() {
17.113 - d.setVisible(false);
17.114 - }
17.115 - });
17.116 - }
17.117 - }
17.118 - });
17.119 -
17.120 - handle.start();
17.121 - handle.progress(" ");
17.122 -
17.123 - d.setVisible(true);
17.124 -
17.125 - if (!done.get()) {
17.126 - cancel.set(true);
17.127 - return;
17.128 - }
17.129 -
17.130 - if (cancel.get()) return;
17.131 -
17.132 - NotifyDescriptor nd = new NotifyDescriptor.Message(new DuplicatesListPanel(sourceRoots, dupes[0]));
17.133 -
17.134 - DialogDisplayer.getDefault().notifyLater(nd);
17.135 - }
17.136 -
17.137 - private JPanel createPanel(ProgressHandle handle) {
17.138 - JPanel panel = new JPanel(new GridBagLayout());
17.139 - GridBagConstraints gridBagConstraints;
17.140 -
17.141 - gridBagConstraints = new GridBagConstraints();
17.142 - gridBagConstraints.gridx = 0;
17.143 - gridBagConstraints.gridy = 0;
17.144 - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
17.145 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
17.146 - gridBagConstraints.weightx = 1.0;
17.147 - gridBagConstraints.insets = new Insets(6, 6, 0, 6);
17.148 - panel.add(new JLabel("Computing Duplicates - Please Wait"), gridBagConstraints);
17.149 -
17.150 - gridBagConstraints = new GridBagConstraints();
17.151 - gridBagConstraints.gridx = 0;
17.152 - gridBagConstraints.gridy = 1;
17.153 - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
17.154 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
17.155 - gridBagConstraints.weightx = 1.0;
17.156 - gridBagConstraints.insets = new Insets(6, 6, 0, 6);
17.157 - panel.add(ProgressHandleFactory.createProgressComponent(handle), gridBagConstraints);
17.158 -
17.159 - gridBagConstraints = new GridBagConstraints();
17.160 - gridBagConstraints.gridx = 0;
17.161 - gridBagConstraints.gridy = 2;
17.162 - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
17.163 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
17.164 - gridBagConstraints.weightx = 1.0;
17.165 - gridBagConstraints.insets = new Insets(6, 6, 6, 6);
17.166 - panel.add(ProgressHandleFactory.createDetailLabelComponent(handle), gridBagConstraints);
17.167 -
17.168 - gridBagConstraints = new GridBagConstraints();
17.169 - gridBagConstraints.gridx = 0;
17.170 - gridBagConstraints.gridy = 3;
17.171 - gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
17.172 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
17.173 - gridBagConstraints.weightx = 1.0;
17.174 - gridBagConstraints.weighty = 1.0;
17.175 - panel.add(new JPanel(), gridBagConstraints);
17.176 -
17.177 - return panel;
17.178 - }
17.179 -
17.180 - private static final RequestProcessor WORKER = new RequestProcessor(GlobalFindDuplicates.class.getName(), 1);
17.181 -
17.182 -}
18.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/duplicates/indexing/DeferredCustomIndexer.java Fri Jan 27 13:35:56 2012 +0100
18.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
18.3 @@ -1,494 +0,0 @@
18.4 -/*
18.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
18.6 - *
18.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
18.8 - *
18.9 - * The contents of this file are subject to the terms of either the GNU
18.10 - * General Public License Version 2 only ("GPL") or the Common
18.11 - * Development and Distribution License("CDDL") (collectively, the
18.12 - * "License"). You may not use this file except in compliance with the
18.13 - * License. You can obtain a copy of the License at
18.14 - * http://www.netbeans.org/cddl-gplv2.html
18.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
18.16 - * specific language governing permissions and limitations under the
18.17 - * License. When distributing the software, include this License Header
18.18 - * Notice in each file and include the License file at
18.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
18.20 - * particular file as subject to the "Classpath" exception as provided
18.21 - * by Sun in the GPL Version 2 section of the License file that
18.22 - * accompanied this code. If applicable, add the following below the
18.23 - * License Header, with the fields enclosed by brackets [] replaced by
18.24 - * your own identifying information:
18.25 - * "Portions Copyrighted [year] [name of copyright owner]"
18.26 - *
18.27 - * If you wish your version of this file to be governed by only the CDDL
18.28 - * or only the GPL Version 2, indicate your decision by adding
18.29 - * "[Contributor] elects to include this software in this distribution
18.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
18.31 - * single choice of license, a recipient has the option to distribute
18.32 - * your version of this file under either the CDDL, the GPL Version 2 or
18.33 - * to extend the choice of license to its licensees as provided above.
18.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
18.35 - * Version 2 license, then the option applies only if the new code is
18.36 - * made subject to such option by the copyright holder.
18.37 - *
18.38 - * Contributor(s):
18.39 - *
18.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
18.41 - */
18.42 -
18.43 -package org.netbeans.modules.jackpot30.impl.duplicates.indexing;
18.44 -
18.45 -import java.io.BufferedWriter;
18.46 -import java.io.File;
18.47 -import java.io.IOException;
18.48 -import java.io.OutputStreamWriter;
18.49 -import java.io.Writer;
18.50 -import java.net.URL;
18.51 -import java.util.Collection;
18.52 -import java.util.Collections;
18.53 -import java.util.HashMap;
18.54 -import java.util.HashSet;
18.55 -import java.util.Iterator;
18.56 -import java.util.Map;
18.57 -import java.util.Map.Entry;
18.58 -import java.util.Set;
18.59 -import java.util.concurrent.atomic.AtomicBoolean;
18.60 -import java.util.logging.Level;
18.61 -import java.util.logging.Logger;
18.62 -import javax.swing.JButton;
18.63 -import javax.swing.SwingUtilities;
18.64 -import org.netbeans.api.annotations.common.NonNull;
18.65 -import org.netbeans.api.java.classpath.ClassPath;
18.66 -import org.netbeans.api.java.source.CancellableTask;
18.67 -import org.netbeans.api.java.source.ClasspathInfo;
18.68 -import org.netbeans.api.java.source.CompilationController;
18.69 -import org.netbeans.api.java.source.CompilationInfo;
18.70 -import org.netbeans.api.java.source.JavaSource;
18.71 -import org.netbeans.api.java.source.JavaSource.Phase;
18.72 -import org.netbeans.api.java.source.JavaSource.Priority;
18.73 -import org.netbeans.api.java.source.JavaSourceTaskFactory;
18.74 -import org.netbeans.api.java.source.Task;
18.75 -import org.netbeans.api.progress.ProgressHandle;
18.76 -import org.netbeans.api.progress.ProgressHandleFactory;
18.77 -import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
18.78 -import org.netbeans.modules.parsing.impl.indexing.SPIAccessor;
18.79 -import org.netbeans.modules.parsing.spi.indexing.Context;
18.80 -import org.netbeans.modules.parsing.spi.indexing.CustomIndexer;
18.81 -import org.netbeans.modules.parsing.spi.indexing.CustomIndexerFactory;
18.82 -import org.netbeans.modules.parsing.spi.indexing.Indexable;
18.83 -import org.openide.DialogDescriptor;
18.84 -import org.openide.DialogDisplayer;
18.85 -import org.openide.filesystems.FileAlreadyLockedException;
18.86 -import org.openide.filesystems.FileObject;
18.87 -import org.openide.filesystems.FileUtil;
18.88 -import org.openide.filesystems.URLMapper;
18.89 -import org.openide.util.Cancellable;
18.90 -import org.openide.util.Exceptions;
18.91 -import org.openide.util.Lookup;
18.92 -import org.openide.util.lookup.ServiceProvider;
18.93 -
18.94 -/**
18.95 - *
18.96 - * @author lahvac
18.97 - */
18.98 -public abstract class DeferredCustomIndexer extends CustomIndexer {
18.99 -
18.100 - private static final Logger LOG = Logger.getLogger(DeferredCustomIndexer.class.getName());
18.101 -
18.102 - private final DeferredCustomIndexerFactory factory;
18.103 -
18.104 - protected DeferredCustomIndexer(DeferredCustomIndexerFactory factory) {
18.105 - this.factory = factory;
18.106 - }
18.107 -
18.108 - protected abstract void doIndex(DeferredContext ctx, Collection<? extends FileObject> modifiedAndAdded, Collection<? extends String> removed) throws IOException;
18.109 -
18.110 - @Override
18.111 - protected final void index(Iterable<? extends Indexable> files, Context context) {
18.112 - update(factory, context.getRootURI(), files, Collections.<Indexable>emptyList());
18.113 - }
18.114 -
18.115 - private static void dump(File where, Iterable<? extends String> lines) {
18.116 - Writer out = null;
18.117 -
18.118 - try {
18.119 - out = new BufferedWriter(new OutputStreamWriter(FileUtil.createData(where).getOutputStream(), "UTF-8"));
18.120 -
18.121 - for (String line : lines) {
18.122 - out.write(line);
18.123 - out.write("\n");
18.124 - }
18.125 - } catch (FileAlreadyLockedException ex) {
18.126 - Exceptions.printStackTrace(ex);
18.127 - } catch (IOException ex) {
18.128 - Exceptions.printStackTrace(ex);
18.129 - } finally {
18.130 - if (out != null) {
18.131 - try {
18.132 - out.close();
18.133 - } catch (IOException ex) {
18.134 - Exceptions.printStackTrace(ex);
18.135 - }
18.136 - }
18.137 - }
18.138 - }
18.139 -
18.140 - private static Set<String> gatherRelativePaths(Iterable<? extends Indexable> it) {
18.141 - Set<String> result = new HashSet<String>();
18.142 -
18.143 - for (Indexable i : it) {
18.144 - result.add(i.getRelativePath());
18.145 - }
18.146 -
18.147 - return result;
18.148 - }
18.149 -
18.150 - private static void update(DeferredCustomIndexerFactory factory, URL root, Iterable<? extends Indexable> modified, Iterable<? extends Indexable> deleted) {
18.151 - try {
18.152 - Set<String> mod = gatherRelativePaths(modified);
18.153 - Set<String> del = gatherRelativePaths(deleted);
18.154 -
18.155 - File cacheRoot = factory.cacheRoot(root);
18.156 -
18.157 - File modifiedFile = new File(cacheRoot, "modified");
18.158 - FileObject modifiedFileFO = FileUtil.toFileObject(modifiedFile);
18.159 - Set<String> modifiedFiles = modifiedFileFO != null ? new HashSet<String>(modifiedFileFO.asLines("UTF-8")) : new HashSet<String>();
18.160 - boolean modifiedFilesChanged = modifiedFiles.removeAll(del);
18.161 -
18.162 - modifiedFilesChanged |= modifiedFiles.addAll(mod);
18.163 -
18.164 - if (modifiedFilesChanged) {
18.165 - dump(modifiedFile, modifiedFiles);
18.166 - }
18.167 -
18.168 - File deletedFile = new File(cacheRoot, "deleted");
18.169 - FileObject deletedFileFO = FileUtil.toFileObject(deletedFile);
18.170 - Set<String> deletedFiles = deletedFileFO != null ? new HashSet<String>(deletedFileFO.asLines("UTF-8")) : new HashSet<String>();
18.171 -
18.172 - boolean deletedFilesChanged = deletedFiles.removeAll(mod);
18.173 -
18.174 - deletedFilesChanged |= deletedFiles.addAll(del);
18.175 -
18.176 - if (deletedFilesChanged) {
18.177 - dump(deletedFile, deletedFiles);
18.178 - }
18.179 -
18.180 - if (!modifiedFiles.isEmpty() || !deletedFiles.isEmpty()) {
18.181 - add2TODO(root, factory);
18.182 - }
18.183 - } catch (IOException ex) {
18.184 - Exceptions.printStackTrace(ex);
18.185 - }
18.186 - }
18.187 -
18.188 - public static abstract class DeferredCustomIndexerFactory extends CustomIndexerFactory {
18.189 -
18.190 - public abstract DeferredCustomIndexer createIndexer();
18.191 -
18.192 - @Override
18.193 - public final void filesDeleted(Iterable<? extends Indexable> deleted, Context context) {
18.194 - update(this, context.getRootURI(), Collections.<Indexable>emptyList(), deleted);
18.195 - }
18.196 -
18.197 - @Override
18.198 - public final void filesDirty(Iterable<? extends Indexable> dirty, Context context) {}
18.199 -
18.200 - @Override
18.201 - public final boolean supportsEmbeddedIndexers() {
18.202 - return false;
18.203 - }
18.204 -
18.205 - @Override
18.206 - public final void rootsRemoved(Iterable<? extends URL> removedRoots) {
18.207 - super.rootsRemoved(removedRoots);
18.208 - }
18.209 -
18.210 - @Override
18.211 - public final void scanFinished(Context context) {
18.212 - super.scanFinished(context);
18.213 - }
18.214 -
18.215 - @Override
18.216 - public final boolean scanStarted(Context context) {
18.217 - return super.scanStarted(context);
18.218 - }
18.219 -
18.220 - protected File cacheRoot(URL root) throws IOException {
18.221 - FileObject indexBaseFolder = CacheFolder.getDataFolder(root);
18.222 - String path = SPIAccessor.getInstance().getIndexerPath(getIndexerName(), getIndexVersion());
18.223 - FileObject indexFolder = FileUtil.createFolder(indexBaseFolder, path);
18.224 - return FileUtil.toFile(indexFolder);
18.225 - }
18.226 -
18.227 - public void updateIndex(final URL root, final AtomicBoolean cancel) throws IOException {
18.228 - final FileObject rootFO = URLMapper.findFileObject(root);
18.229 - final ClasspathInfo cpInfo = ClasspathInfo.create(ClassPath.EMPTY, ClassPath.EMPTY, ClassPath.EMPTY);
18.230 -
18.231 - JavaSource.create(cpInfo).runUserActionTask(new Task<CompilationController>() {
18.232 - public void run(CompilationController parameter) throws Exception {
18.233 - if (cancel.get()) return ;
18.234 - updateRoot(DeferredCustomIndexerFactory.this, root, rootFO, cancel);
18.235 - }
18.236 - }, true);
18.237 - }
18.238 -
18.239 - }
18.240 -
18.241 - public static final class DeferredContext {
18.242 - private final @NonNull URL root;
18.243 - private final @NonNull FileObject rootFileObject;
18.244 - private final @NonNull Set<? extends FileObject> modifiedAndAdded;
18.245 - private final @NonNull Set<? extends String> removed;
18.246 - private final @NonNull AtomicBoolean cancel;
18.247 -
18.248 - public DeferredContext(@NonNull URL root, @NonNull FileObject rootFileObject, @NonNull Set<? extends FileObject> modifiedAndAdded, @NonNull Set<? extends String> removed, @NonNull AtomicBoolean cancel) {
18.249 - this.root = root;
18.250 - this.rootFileObject = rootFileObject;
18.251 - this.modifiedAndAdded = modifiedAndAdded;
18.252 - this.removed = removed;
18.253 - this.cancel = cancel;
18.254 - }
18.255 -
18.256 - public @NonNull URL getRoot() {
18.257 - return root;
18.258 - }
18.259 -
18.260 - public @NonNull FileObject getRootFileObject() {
18.261 - return rootFileObject;
18.262 - }
18.263 -
18.264 - public boolean isCancelled() {
18.265 - return cancel.get();
18.266 - }
18.267 -
18.268 - public void handledModifiedFile(FileObject file) {
18.269 - modifiedAndAdded.remove(file);
18.270 - }
18.271 -
18.272 - public void handledRemovedFile(String relative) {
18.273 - removed.remove(relative);
18.274 - }
18.275 - }
18.276 -
18.277 - /*return: true == done*/
18.278 - private static boolean updateRoot(DeferredCustomIndexerFactory factory, URL root, FileObject rootFO, AtomicBoolean cancel) throws IOException {
18.279 - LOG.log(Level.FINE, "updating: {0}, for indexer: {1}", new Object[] {root.toExternalForm(), factory.getIndexerName()});
18.280 - File cacheRoot = factory.cacheRoot(root);
18.281 - FileObject deletedFile = FileUtil.toFileObject(new File(cacheRoot, "deleted"));
18.282 - Set<String> deletedFiles = deletedFile != null ? new HashSet<String>(deletedFile.asLines("UTF-8")) : Collections.<String>emptySet();
18.283 -
18.284 - FileObject modifiedFile = FileUtil.toFileObject(new File(cacheRoot, "modified"));
18.285 - Set<String> modifiedFiles = modifiedFile != null ? new HashSet<String>(modifiedFile.asLines("UTF-8")) : Collections.<String>emptySet();
18.286 -
18.287 - Set<FileObject> toIndex = new HashSet<FileObject>();
18.288 -
18.289 - for (String r : modifiedFiles) {
18.290 - FileObject f = rootFO.getFileObject(r);
18.291 -
18.292 - if (f != null) {
18.293 - toIndex.add(f);
18.294 - }
18.295 - }
18.296 -
18.297 - if (!toIndex.isEmpty() || !modifiedFiles.isEmpty()) {
18.298 - factory.createIndexer().doIndex(new DeferredContext(root, rootFO, toIndex, deletedFiles, cancel), new HashSet<FileObject>(toIndex), new HashSet<String>(deletedFiles));
18.299 - }
18.300 -
18.301 - boolean done = true;
18.302 -
18.303 - if (deletedFile != null) {
18.304 - if (deletedFiles.isEmpty()) {
18.305 - deletedFile.delete();
18.306 - } else {
18.307 - dump(new File(cacheRoot, "deleted"), deletedFiles);
18.308 - done = false;
18.309 - }
18.310 - }
18.311 - if (modifiedFile != null) {
18.312 - if (toIndex.isEmpty()) {
18.313 - modifiedFile.delete();
18.314 - } else {
18.315 - modifiedFiles.clear();
18.316 -
18.317 - for (FileObject f : toIndex) {
18.318 - modifiedFiles.add(FileUtil.getRelativePath(rootFO, f));
18.319 - }
18.320 -
18.321 - dump(new File(cacheRoot, "modified"), modifiedFiles);
18.322 - done = false;
18.323 - }
18.324 - }
18.325 -
18.326 - return done;
18.327 - }
18.328 -
18.329 - private static final Map<String, TODO> todo = new HashMap<String, TODO>(); //XXX: synchronization!!!
18.330 -
18.331 - private static void add2TODO(URL root, DeferredCustomIndexerFactory factory) {
18.332 - if (DISABLED_INDEXERS.contains(factory.getIndexerName())) return;
18.333 -
18.334 - boolean wasEmpty = todo.isEmpty();
18.335 - TODO roots = todo.get(factory.getIndexerName());
18.336 -
18.337 - if (roots == null) {
18.338 - todo.put(factory.getIndexerName(), roots = new TODO(factory));
18.339 - }
18.340 -
18.341 - roots.roots.add(root);
18.342 -
18.343 - LOG.log(Level.FINE, "add2TODO, root: {0}, for factory: {1}, wasEmpty: {2}, todo: {3}", new Object[] {root.toExternalForm(), factory.getIndexerName(), wasEmpty, todo.toString()});
18.344 -
18.345 - if (wasEmpty) RunAsNeededFactory.fileChanged();
18.346 - else RunAsNeededFactory.refresh();
18.347 - }
18.348 -
18.349 - private static final Set<String> DISABLED_INDEXERS = Collections.synchronizedSet(new HashSet<String>());
18.350 -
18.351 - private static class UpdateWorker implements CancellableTask<CompilationInfo> {
18.352 -
18.353 - private static ProgressHandle progressForCurrentFactory;
18.354 - private static DeferredCustomIndexerFactory currentFactory;
18.355 -
18.356 - private final AtomicBoolean cancel = new AtomicBoolean();
18.357 -
18.358 - public void run(CompilationInfo parameter) throws Exception {
18.359 - cancel.set(false);
18.360 -
18.361 - for (Iterator<Entry<String, TODO>> it = todo.entrySet().iterator(); it.hasNext();) {
18.362 - if (cancel.get()) return;
18.363 -
18.364 - final Entry<String, TODO> e = it.next();
18.365 -
18.366 - if (DISABLED_INDEXERS.contains(e.getKey())) {
18.367 - it.remove();
18.368 - continue;
18.369 - }
18.370 -
18.371 - if (currentFactory != e.getValue().factory) {
18.372 - if (progressForCurrentFactory != null) {
18.373 - progressForCurrentFactory.finish();
18.374 - }
18.375 -
18.376 - currentFactory = e.getValue().factory;
18.377 - progressForCurrentFactory = ProgressHandleFactory.createSystemHandle("Background indexing for: " + currentFactory.getIndexerName(), new Cancellable() {
18.378 - public boolean cancel() {
18.379 - assert SwingUtilities.isEventDispatchThread();
18.380 -
18.381 - JButton disableInThisSession = new JButton("Disable in This Session");
18.382 - JButton disablePermanently = new JButton("Disable Permanently");
18.383 -
18.384 - disablePermanently.setEnabled(false);
18.385 -
18.386 - Object[] buttons = new Object[]{disableInThisSession, disablePermanently, DialogDescriptor.CANCEL_OPTION};
18.387 - DialogDescriptor dd = new DialogDescriptor("Disable background indexing for: " + e.getValue().factory.getIndexerName(), "Disable Background Indexing", true, buttons, disableInThisSession, DialogDescriptor.DEFAULT_ALIGN, null, null);
18.388 -
18.389 - dd.setClosingOptions(buttons);
18.390 -
18.391 - Object result = DialogDisplayer.getDefault().notify(dd);
18.392 -
18.393 - if (result == disableInThisSession) {
18.394 - DISABLED_INDEXERS.add(e.getKey());
18.395 - return true;
18.396 - } else if (result == disablePermanently) {
18.397 - throw new UnsupportedOperationException();
18.398 - } else {
18.399 - return false;
18.400 - }
18.401 - }
18.402 - });
18.403 -
18.404 - progressForCurrentFactory.start();
18.405 - }
18.406 -
18.407 - for (Iterator<URL> factIt = e.getValue().roots.iterator(); factIt.hasNext();) {
18.408 - if (cancel.get()) return;
18.409 -
18.410 - URL root = factIt.next();
18.411 - FileObject rootFO = URLMapper.findFileObject(root);
18.412 -
18.413 - if (rootFO == null) {
18.414 - //already deleted
18.415 - it.remove();
18.416 - continue;
18.417 - }
18.418 -
18.419 - if (updateRoot(e.getValue().factory, root, rootFO, cancel)) {
18.420 - factIt.remove();
18.421 - } else {
18.422 - if (!cancel.get()) {
18.423 - LOG.log(Level.WARNING, "indexer: {0} did not update all files even if the process was not cancelled", currentFactory.getIndexerName());
18.424 - }
18.425 - }
18.426 - }
18.427 -
18.428 - if (e.getValue().roots.isEmpty())
18.429 - it.remove();
18.430 -
18.431 - progressForCurrentFactory.finish();
18.432 - progressForCurrentFactory = null;
18.433 - currentFactory = null;
18.434 - }
18.435 -
18.436 - if (todo.isEmpty()) RunAsNeededFactory.fileChanged();
18.437 - }
18.438 -
18.439 - public void cancel() {
18.440 - cancel.set(true);
18.441 - }
18.442 - }
18.443 -
18.444 - private static final class TODO {
18.445 - final DeferredCustomIndexerFactory factory;
18.446 - final Collection<URL> roots = new HashSet<URL>();
18.447 - TODO(DeferredCustomIndexerFactory factory) {
18.448 - this.factory = factory;
18.449 - }
18.450 - }
18.451 -
18.452 - private static final boolean DEFERRED_INDEXER_ENABLED = Boolean.getBoolean(DeferredCustomIndexerFactory.class.getName() + ".enable");
18.453 -
18.454 - private static final FileObject EMPTY_FILE;
18.455 -
18.456 - static {
18.457 - try {
18.458 - EMPTY_FILE = FileUtil.createMemoryFileSystem().getRoot().createData("empty.java");
18.459 - } catch (IOException ex) {
18.460 - throw new IllegalStateException(ex);
18.461 - }
18.462 - }
18.463 -
18.464 - @ServiceProvider(service=JavaSourceTaskFactory.class)
18.465 - public static final class RunAsNeededFactory extends JavaSourceTaskFactory {
18.466 -
18.467 - public RunAsNeededFactory() {
18.468 - super(Phase.PARSED, Priority.MIN);
18.469 - }
18.470 -
18.471 - @Override
18.472 - protected CancellableTask<CompilationInfo> createTask(FileObject file) {
18.473 - return new UpdateWorker();
18.474 - }
18.475 -
18.476 - @Override
18.477 - protected Collection<FileObject> getFileObjects() {
18.478 - return DEFERRED_INDEXER_ENABLED && !todo.isEmpty() ? Collections.singletonList(EMPTY_FILE) : Collections.<FileObject>emptyList();
18.479 - }
18.480 -
18.481 - public static void fileChanged() {
18.482 - for (JavaSourceTaskFactory f : Lookup.getDefault().lookupAll(JavaSourceTaskFactory.class)) {
18.483 - if (f instanceof RunAsNeededFactory) {
18.484 - ((RunAsNeededFactory) f).fileObjectsChanged();
18.485 - }
18.486 - }
18.487 - }
18.488 -
18.489 - public static void refresh() {
18.490 - for (JavaSourceTaskFactory f : Lookup.getDefault().lookupAll(JavaSourceTaskFactory.class)) {
18.491 - if (f instanceof RunAsNeededFactory) {
18.492 - ((RunAsNeededFactory) f).reschedule(EMPTY_FILE);
18.493 - }
18.494 - }
18.495 - }
18.496 - }
18.497 -}
19.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/duplicates/indexing/DuplicatesCustomIndexerImpl.java Fri Jan 27 13:35:56 2012 +0100
19.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
19.3 @@ -1,126 +0,0 @@
19.4 -/*
19.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
19.6 - *
19.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
19.8 - *
19.9 - * The contents of this file are subject to the terms of either the GNU
19.10 - * General Public License Version 2 only ("GPL") or the Common
19.11 - * Development and Distribution License("CDDL") (collectively, the
19.12 - * "License"). You may not use this file except in compliance with the
19.13 - * License. You can obtain a copy of the License at
19.14 - * http://www.netbeans.org/cddl-gplv2.html
19.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
19.16 - * specific language governing permissions and limitations under the
19.17 - * License. When distributing the software, include this License Header
19.18 - * Notice in each file and include the License file at
19.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
19.20 - * particular file as subject to the "Classpath" exception as provided
19.21 - * by Sun in the GPL Version 2 section of the License file that
19.22 - * accompanied this code. If applicable, add the following below the
19.23 - * License Header, with the fields enclosed by brackets [] replaced by
19.24 - * your own identifying information:
19.25 - * "Portions Copyrighted [year] [name of copyright owner]"
19.26 - *
19.27 - * If you wish your version of this file to be governed by only the CDDL
19.28 - * or only the GPL Version 2, indicate your decision by adding
19.29 - * "[Contributor] elects to include this software in this distribution
19.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
19.31 - * single choice of license, a recipient has the option to distribute
19.32 - * your version of this file under either the CDDL, the GPL Version 2 or
19.33 - * to extend the choice of license to its licensees as provided above.
19.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
19.35 - * Version 2 license, then the option applies only if the new code is
19.36 - * made subject to such option by the copyright holder.
19.37 - *
19.38 - * Contributor(s):
19.39 - *
19.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
19.41 - */
19.42 -
19.43 -package org.netbeans.modules.jackpot30.impl.duplicates.indexing;
19.44 -
19.45 -import java.io.File;
19.46 -import java.io.IOException;
19.47 -import java.net.URL;
19.48 -import java.util.Collection;
19.49 -import org.netbeans.api.java.source.ClasspathInfo;
19.50 -import org.netbeans.api.java.source.CompilationController;
19.51 -import org.netbeans.api.java.source.JavaSource;
19.52 -import org.netbeans.api.java.source.JavaSource.Phase;
19.53 -import org.netbeans.api.java.source.Task;
19.54 -import org.netbeans.modules.jackpot30.impl.duplicates.indexing.DuplicatesIndex.IndexWriter;
19.55 -import org.netbeans.modules.jackpot30.impl.indexing.Cache;
19.56 -import org.openide.filesystems.FileObject;
19.57 -import org.openide.util.Exceptions;
19.58 -
19.59 -/**
19.60 - *
19.61 - * @author lahvac
19.62 - */
19.63 -public class DuplicatesCustomIndexerImpl extends DeferredCustomIndexer {
19.64 -
19.65 - private static final String NAME = "";
19.66 - private static final int VERSION = 1;
19.67 - public DuplicatesCustomIndexerImpl(DeferredCustomIndexerFactory factory) {
19.68 - super(factory);
19.69 - }
19.70 -
19.71 - protected void doIndex(final DeferredContext ctx, Collection<? extends FileObject> modifiedAndAdded, Collection<? extends String> removed) throws IOException {
19.72 - final IndexWriter[] w = new IndexWriter[1];
19.73 -
19.74 - try {
19.75 - w[0] = DuplicatesIndex.get(ctx.getRoot()).openForWriting();
19.76 -
19.77 - for (String r : removed) {
19.78 - w[0].remove(r);
19.79 - ctx.handledRemovedFile(r);
19.80 - }
19.81 -
19.82 - final ClasspathInfo cpInfo = ClasspathInfo.create(ctx.getRootFileObject());
19.83 -
19.84 - JavaSource.create(cpInfo, modifiedAndAdded).runUserActionTask(new Task<CompilationController>() {
19.85 - public void run(final CompilationController cc) throws Exception {
19.86 - if (cc.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0)
19.87 - return ;
19.88 -
19.89 - w[0].record(cc, cc.getFileObject().getURL(), cc.getCompilationUnit());
19.90 -
19.91 - ctx.handledModifiedFile(cc.getFileObject());
19.92 - }
19.93 - }, true);
19.94 - } finally {
19.95 - if (w[0] != null) {
19.96 - try {
19.97 - w[0].close();
19.98 - } catch (IOException ex) {
19.99 - Exceptions.printStackTrace(ex);
19.100 - }
19.101 - }
19.102 - }
19.103 - }
19.104 -
19.105 - public static final class FactoryImpl extends DeferredCustomIndexerFactory {
19.106 -
19.107 - @Override
19.108 - public DeferredCustomIndexer createIndexer() {
19.109 - return new DuplicatesCustomIndexerImpl(this);
19.110 - }
19.111 -
19.112 - @Override
19.113 - public String getIndexerName() {
19.114 - return DuplicatesIndex.NAME;
19.115 - }
19.116 -
19.117 - @Override
19.118 - public int getIndexVersion() {
19.119 - return DuplicatesIndex.VERSION;
19.120 - }
19.121 -
19.122 - @Override
19.123 - protected File cacheRoot(URL root) throws IOException {
19.124 - return Cache.findCache(DuplicatesIndex.NAME, DuplicatesIndex.VERSION).findCacheRoot(root);
19.125 - }
19.126 -
19.127 - }
19.128 -
19.129 -}
20.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/duplicates/indexing/DuplicatesIndex.java Fri Jan 27 13:35:56 2012 +0100
20.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
20.3 @@ -1,144 +0,0 @@
20.4 -/*
20.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
20.6 - *
20.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
20.8 - *
20.9 - * The contents of this file are subject to the terms of either the GNU
20.10 - * General Public License Version 2 only ("GPL") or the Common
20.11 - * Development and Distribution License("CDDL") (collectively, the
20.12 - * "License"). You may not use this file except in compliance with the
20.13 - * License. You can obtain a copy of the License at
20.14 - * http://www.netbeans.org/cddl-gplv2.html
20.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
20.16 - * specific language governing permissions and limitations under the
20.17 - * License. When distributing the software, include this License Header
20.18 - * Notice in each file and include the License file at
20.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
20.20 - * particular file as subject to the "Classpath" exception as provided
20.21 - * by Sun in the GPL Version 2 section of the License file that
20.22 - * accompanied this code. If applicable, add the following below the
20.23 - * License Header, with the fields enclosed by brackets [] replaced by
20.24 - * your own identifying information:
20.25 - * "Portions Copyrighted [year] [name of copyright owner]"
20.26 - *
20.27 - * If you wish your version of this file to be governed by only the CDDL
20.28 - * or only the GPL Version 2, indicate your decision by adding
20.29 - * "[Contributor] elects to include this software in this distribution
20.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
20.31 - * single choice of license, a recipient has the option to distribute
20.32 - * your version of this file under either the CDDL, the GPL Version 2 or
20.33 - * to extend the choice of license to its licensees as provided above.
20.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
20.35 - * Version 2 license, then the option applies only if the new code is
20.36 - * made subject to such option by the copyright holder.
20.37 - *
20.38 - * Contributor(s):
20.39 - *
20.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
20.41 - */
20.42 -
20.43 -package org.netbeans.modules.jackpot30.impl.duplicates.indexing;
20.44 -
20.45 -import com.sun.source.tree.CompilationUnitTree;
20.46 -import java.io.File;
20.47 -import java.io.IOException;
20.48 -import java.net.URL;
20.49 -import java.util.Map;
20.50 -import java.util.Map.Entry;
20.51 -import java.util.logging.Level;
20.52 -import java.util.logging.Logger;
20.53 -import javax.tools.JavaCompiler.CompilationTask;
20.54 -import org.apache.lucene.document.Document;
20.55 -import org.apache.lucene.document.Field;
20.56 -import org.apache.lucene.document.Field.Index;
20.57 -import org.apache.lucene.document.Field.Store;
20.58 -import org.apache.lucene.index.IndexWriter.MaxFieldLength;
20.59 -import org.apache.lucene.index.Term;
20.60 -import org.apache.lucene.store.FSDirectory;
20.61 -import org.netbeans.api.annotations.common.CheckForNull;
20.62 -import org.netbeans.api.java.source.CompilationInfo;
20.63 -import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates;
20.64 -import org.netbeans.modules.jackpot30.impl.indexing.Cache;
20.65 -import org.netbeans.modules.jackpot30.impl.indexing.FileBasedIndex.NoAnalyzer;
20.66 -import org.netbeans.modules.java.source.JavaSourceAccessor;
20.67 -
20.68 -/**
20.69 - *
20.70 - * @author lahvac
20.71 - */
20.72 -public class DuplicatesIndex {
20.73 -
20.74 - private final URL sourceRoot;
20.75 - private final int stripLength;
20.76 - private final File cacheRoot;
20.77 -
20.78 - private DuplicatesIndex(URL sourceRoot, File cacheRoot) {
20.79 - this.sourceRoot = sourceRoot;
20.80 - this.stripLength = sourceRoot.getPath().length();
20.81 - this.cacheRoot = cacheRoot;
20.82 - }
20.83 -
20.84 - public static @CheckForNull DuplicatesIndex get(URL sourceRoot) throws IOException {
20.85 - return new DuplicatesIndex(sourceRoot, Cache.findCache(NAME, VERSION).findCacheRoot(sourceRoot)); //XXX: new!
20.86 - }
20.87 -
20.88 - public IndexWriter openForWriting() throws IOException {
20.89 - return new IndexWriter();
20.90 - }
20.91 -
20.92 - public class IndexWriter {
20.93 -
20.94 - private final org.apache.lucene.index.IndexWriter luceneWriter;
20.95 -
20.96 - public IndexWriter() throws IOException {
20.97 - luceneWriter = new org.apache.lucene.index.IndexWriter(FSDirectory.open(new File(cacheRoot, "fulltext")), new NoAnalyzer(), MaxFieldLength.UNLIMITED);
20.98 - }
20.99 -
20.100 - public void record(final CompilationInfo info, URL source, final CompilationUnitTree cut) throws IOException {
20.101 - record(JavaSourceAccessor.getINSTANCE().getJavacTask(info), source, cut);
20.102 - }
20.103 -
20.104 - public void record(final CompilationTask task, URL source, final CompilationUnitTree cut) throws IOException {
20.105 - String relative = source.getPath().substring(stripLength);
20.106 -
20.107 - try {
20.108 - final Document doc = new Document();
20.109 -
20.110 - doc.add(new Field("path", relative, Field.Store.YES, Field.Index.NOT_ANALYZED));
20.111 -
20.112 - final Map<String, long[]> positions = ComputeDuplicates.encodeGeneralized(task, cut);
20.113 -
20.114 - for (Entry<String, long[]> e : positions.entrySet()) {
20.115 - doc.add(new Field("generalized", e.getKey(), Store.YES, Index.NOT_ANALYZED));
20.116 -
20.117 - StringBuilder positionsSpec = new StringBuilder();
20.118 -
20.119 - for (int i = 0; i < e.getValue().length; i += 2) {
20.120 - if (positionsSpec.length() > 0) positionsSpec.append(';');
20.121 - positionsSpec.append(e.getValue()[i]).append(':').append(e.getValue()[i + 1] - e.getValue()[i]);
20.122 - }
20.123 -
20.124 - doc.add(new Field("positions", positionsSpec.toString(), Store.YES, Index.NO));
20.125 - }
20.126 -
20.127 - luceneWriter.addDocument(doc);
20.128 - } catch (ThreadDeath td) {
20.129 - throw td;
20.130 - } catch (Throwable t) {
20.131 - Logger.getLogger(DuplicatesIndex.class.getName()).log(Level.WARNING, null, t);
20.132 - }
20.133 - }
20.134 -
20.135 - public void remove(String relativePath) throws IOException {
20.136 - luceneWriter.deleteDocuments(new Term("path", relativePath));
20.137 - }
20.138 -
20.139 - public void close() throws IOException {
20.140 - luceneWriter.optimize();
20.141 - luceneWriter.close();
20.142 - }
20.143 - }
20.144 -
20.145 - public static final String NAME = "duplicates"; //NOI18N
20.146 - public static final int VERSION = 1; //NOI18N
20.147 -}
21.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/duplicates/indexing/RemoteDuplicatesIndex.java Fri Jan 27 13:35:56 2012 +0100
21.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
21.3 @@ -1,413 +0,0 @@
21.4 -/*
21.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
21.6 - *
21.7 - * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
21.8 - *
21.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
21.10 - * Other names may be trademarks of their respective owners.
21.11 - *
21.12 - * The contents of this file are subject to the terms of either the GNU
21.13 - * General Public License Version 2 only ("GPL") or the Common
21.14 - * Development and Distribution License("CDDL") (collectively, the
21.15 - * "License"). You may not use this file except in compliance with the
21.16 - * License. You can obtain a copy of the License at
21.17 - * http://www.netbeans.org/cddl-gplv2.html
21.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
21.19 - * specific language governing permissions and limitations under the
21.20 - * License. When distributing the software, include this License Header
21.21 - * Notice in each file and include the License file at
21.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
21.23 - * particular file as subject to the "Classpath" exception as provided
21.24 - * by Oracle in the GPL Version 2 section of the License file that
21.25 - * accompanied this code. If applicable, add the following below the
21.26 - * License Header, with the fields enclosed by brackets [] replaced by
21.27 - * your own identifying information:
21.28 - * "Portions Copyrighted [year] [name of copyright owner]"
21.29 - *
21.30 - * If you wish your version of this file to be governed by only the CDDL
21.31 - * or only the GPL Version 2, indicate your decision by adding
21.32 - * "[Contributor] elects to include this software in this distribution
21.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
21.34 - * single choice of license, a recipient has the option to distribute
21.35 - * your version of this file under either the CDDL, the GPL Version 2 or
21.36 - * to extend the choice of license to its licensees as provided above.
21.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
21.38 - * Version 2 license, then the option applies only if the new code is
21.39 - * made subject to such option by the copyright holder.
21.40 - *
21.41 - * Contributor(s):
21.42 - *
21.43 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
21.44 - */
21.45 -
21.46 -package org.netbeans.modules.jackpot30.impl.duplicates.indexing;
21.47 -
21.48 -import java.io.File;
21.49 -import java.io.IOException;
21.50 -import java.net.URI;
21.51 -import java.net.URISyntaxException;
21.52 -import java.util.ArrayList;
21.53 -import java.util.Arrays;
21.54 -import java.util.BitSet;
21.55 -import java.util.Collection;
21.56 -import java.util.Collections;
21.57 -import java.util.Comparator;
21.58 -import java.util.HashSet;
21.59 -import java.util.Iterator;
21.60 -import java.util.LinkedHashMap;
21.61 -import java.util.LinkedHashSet;
21.62 -import java.util.LinkedList;
21.63 -import java.util.List;
21.64 -import java.util.Map;
21.65 -import java.util.Map.Entry;
21.66 -import java.util.Set;
21.67 -import java.util.TreeMap;
21.68 -import java.util.logging.Level;
21.69 -import java.util.logging.Logger;
21.70 -import org.apache.lucene.document.Document;
21.71 -import org.apache.lucene.document.Field;
21.72 -import org.apache.lucene.document.Field.Index;
21.73 -import org.apache.lucene.document.Field.Store;
21.74 -import org.apache.lucene.index.IndexReader;
21.75 -import org.apache.lucene.index.IndexWriter;
21.76 -import org.apache.lucene.index.IndexWriter.MaxFieldLength;
21.77 -import org.apache.lucene.index.Term;
21.78 -import org.apache.lucene.search.Collector;
21.79 -import org.apache.lucene.search.IndexSearcher;
21.80 -import org.apache.lucene.search.Query;
21.81 -import org.apache.lucene.search.Searcher;
21.82 -import org.apache.lucene.search.TermQuery;
21.83 -import org.apache.lucene.store.FSDirectory;
21.84 -import org.codeviation.pojson.Pojson;
21.85 -import org.netbeans.modules.jackpot30.remoting.api.WebUtilities;
21.86 -import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.DuplicateDescription;
21.87 -import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.Span;
21.88 -import org.netbeans.modules.jackpot30.impl.indexing.AbstractLuceneIndex.BitSetCollector;
21.89 -import org.netbeans.modules.jackpot30.impl.indexing.Cache;
21.90 -import org.netbeans.modules.jackpot30.impl.indexing.FileBasedIndex.NoAnalyzer;
21.91 -import org.netbeans.modules.jackpot30.remoting.api.RemoteIndex;
21.92 -import org.openide.filesystems.FileObject;
21.93 -import org.openide.filesystems.FileUtil;
21.94 -import org.openide.filesystems.URLMapper;
21.95 -import org.openide.util.Exceptions;
21.96 -
21.97 -/**
21.98 - *
21.99 - * @author lahvac
21.100 - */
21.101 -public class RemoteDuplicatesIndex {
21.102 -
21.103 - private static final Logger TIMER = Logger.getLogger("TIMER");
21.104 -
21.105 - public static List<DuplicateDescription> findDuplicates(Map<String, long[]> hashes, FileObject currentFile) throws IOException {
21.106 - return translate(hashes, findHashOccurrences(hashes.keySet(), currentFile), currentFile);
21.107 - }
21.108 -
21.109 - private static Map<String, Map<RemoteIndex, Collection<String>>> findHashOccurrences(Collection<? extends String> hashes, FileObject currentFile) throws IOException {
21.110 - Map<URI, Collection<RemoteIndex>> indices = new LinkedHashMap<URI, Collection<RemoteIndex>>();
21.111 -
21.112 - for (RemoteIndex ri : RemoteIndex.loadIndices()) {
21.113 - try {
21.114 - URI uri = ri.remote.toURI();
21.115 - Collection<RemoteIndex> list = indices.get(uri);
21.116 -
21.117 - if (list == null) {
21.118 - indices.put(uri, list = new ArrayList<RemoteIndex>());
21.119 - }
21.120 -
21.121 - list.add(ri);
21.122 - } catch (URISyntaxException ex) {
21.123 - Exceptions.printStackTrace(ex);
21.124 - }
21.125 - }
21.126 -
21.127 - Map<String, Map<RemoteIndex, Collection<String>>> result = new LinkedHashMap<String, Map<RemoteIndex, Collection<String>>>();
21.128 - long localTime = 0;
21.129 - long remoteTime = 0;
21.130 -
21.131 - for (URI ri : indices.keySet()) {
21.132 - Set<String> toProcess = new LinkedHashSet<String>(hashes);
21.133 - Map<String, Map<String, Collection<? extends String>>> indexResult = new LinkedHashMap<String, Map<String, Collection<? extends String>>>();
21.134 -
21.135 - long locS = System.currentTimeMillis();
21.136 - indexResult.putAll(findHashOccurrencesInLocalCache(ri, toProcess));
21.137 - localTime += System.currentTimeMillis() - locS;
21.138 -
21.139 - toProcess.removeAll(result.keySet());
21.140 -
21.141 - if (!toProcess.isEmpty()) {
21.142 - long remS = System.currentTimeMillis();
21.143 - Map<String, Map<String, Collection<? extends String>>> remoteResults = findHashOccurrencesRemote(ri, toProcess);
21.144 - remoteTime += System.currentTimeMillis() - remS;
21.145 -
21.146 - Map<String, Map<String, Collection<? extends String>>> toSave = new LinkedHashMap<String, Map<String, Collection<? extends String>>>(remoteResults);
21.147 -
21.148 - for (String hash : toProcess) {
21.149 - if (!toSave.containsKey(hash)) {
21.150 - toSave.put(hash, Collections.<String, Collection<? extends String>>emptyMap());
21.151 - }
21.152 - }
21.153 -
21.154 - saveToLocalCache(ri, toSave);
21.155 -
21.156 - indexResult.putAll(remoteResults);
21.157 - }
21.158 -
21.159 - for (Entry<String, Map<String, Collection<? extends String>>> e : indexResult.entrySet()) {
21.160 - Map<RemoteIndex, Collection<String>> hashResult = result.get(e.getKey());
21.161 -
21.162 - if (hashResult == null) {
21.163 - result.put(e.getKey(), hashResult = new LinkedHashMap<RemoteIndex, Collection<String>>());
21.164 - }
21.165 -
21.166 - for (Entry<String, Collection<? extends String>> insideHash : e.getValue().entrySet()) {
21.167 - RemoteIndex current = null;
21.168 -
21.169 - for (RemoteIndex r : indices.get(ri)) {
21.170 - if (r.remoteSegment.equals(insideHash.getKey())) {
21.171 - current = r;
21.172 - break;
21.173 - }
21.174 - }
21.175 -
21.176 - if (current == null) {
21.177 - continue;
21.178 - }
21.179 -
21.180 - Collection<String> dupes = hashResult.get(current);
21.181 -
21.182 - if (dupes == null) {
21.183 - hashResult.put(current, dupes = new HashSet<String>());
21.184 - }
21.185 -
21.186 - dupes.addAll(insideHash.getValue());
21.187 - }
21.188 - }
21.189 - }
21.190 -
21.191 - TIMER.log(Level.FINE, "local hash duplicates", new Object[] {currentFile, localTime});
21.192 - TIMER.log(Level.FINE, "remote hash duplicates", new Object[] {currentFile, remoteTime});
21.193 - return result;
21.194 - }
21.195 -
21.196 - private static Map<String, Map<String, Collection<? extends String>>> findHashOccurrencesRemote(URI remoteIndex, Iterable<? extends String> hashes) {
21.197 - try {
21.198 - String indexURL = remoteIndex.toASCIIString();
21.199 - URI u = new URI(indexURL + "/findDuplicates?hashes=" + WebUtilities.escapeForQuery(Pojson.save(hashes)));
21.200 - String hashesMap = WebUtilities.requestStringResponse(u);
21.201 -
21.202 - if (hashesMap == null) {
21.203 - //some kind of error while getting the duplicates (cannot access remote server)?
21.204 - //ignore:
21.205 - return Collections.emptyMap();
21.206 - }
21.207 - return Pojson.load(LinkedHashMap.class, hashesMap);
21.208 - } catch (URISyntaxException ex) {
21.209 - //XXX: better handling?
21.210 - Exceptions.printStackTrace(ex);
21.211 - return Collections.emptyMap();
21.212 - }
21.213 - }
21.214 -
21.215 - private static volatile IndexReader readerCache;
21.216 -
21.217 - private static File findLocalCacheDir(URI uri) throws IOException {
21.218 - return Cache.findCache("remote-duplicates", 0).findCacheRoot(uri.toURL());
21.219 - }
21.220 -
21.221 - private static Map<String, Map<String, Collection<? extends String>>> findHashOccurrencesInLocalCache(URI uri, Iterable<? extends String> hashes) throws IOException {
21.222 - IndexReader reader = readerCache;
21.223 -
21.224 - if (reader == null) {
21.225 - File dir = findLocalCacheDir(uri);
21.226 -
21.227 - if (dir.listFiles() != null && dir.listFiles().length > 0) {
21.228 - readerCache = reader = IndexReader.open(FSDirectory.open(dir), true);
21.229 - }
21.230 - }
21.231 -
21.232 - if (reader == null) {
21.233 - return Collections.emptyMap();
21.234 - }
21.235 -
21.236 - Map<String, Map<String, Collection<String>>> result = new LinkedHashMap<String, Map<String, Collection<String>>>();
21.237 -
21.238 - for (Entry<String, Collection<? extends String>> e : containsHash(reader, hashes).entrySet()) {
21.239 - Map<String, Collection<String>> forHash = result.get(e.getKey());
21.240 -
21.241 - if (forHash == null) {
21.242 - result.put(e.getKey(), forHash = new LinkedHashMap<String, Collection<String>>());
21.243 - }
21.244 -
21.245 - for (String path : e.getValue()) {
21.246 - String segment = path.substring(0, path.indexOf('/'));
21.247 -
21.248 - path = path.substring(path.indexOf('/') + 1);
21.249 -
21.250 - Collection<String> list = forHash.get(segment);
21.251 -
21.252 - if (list == null) {
21.253 - forHash.put(segment, list = new LinkedList<String>());
21.254 - }
21.255 -
21.256 - list.add(path);
21.257 - }
21.258 - }
21.259 -
21.260 - return (Map)result; //XXX
21.261 - }
21.262 -
21.263 - private static void saveToLocalCache(URI uri, Map<String, Map<String, Collection<? extends String>>> what) throws IOException {
21.264 - IndexReader r = readerCache;
21.265 -
21.266 - if (r != null) {
21.267 - r.close();
21.268 - readerCache = null;
21.269 - }
21.270 -
21.271 - IndexWriter w = new IndexWriter(FSDirectory.open(findLocalCacheDir(uri)), new NoAnalyzer(), MaxFieldLength.UNLIMITED);
21.272 -
21.273 - for (Entry<String, Map<String, Collection<? extends String>>> e : what.entrySet()) {
21.274 - Document doc = new Document();
21.275 -
21.276 - doc.add(new Field("hash", e.getKey(), Store.YES, Index.NOT_ANALYZED));
21.277 -
21.278 - for (Entry<String, Collection<? extends String>> pe : e.getValue().entrySet()) {
21.279 - for (String path : pe.getValue()) {
21.280 - doc.add(new Field("path", pe.getKey() + "/" + path, Store.YES, Index.NO));
21.281 - }
21.282 - }
21.283 -
21.284 - w.addDocument(doc);
21.285 - }
21.286 -
21.287 - w.optimize();
21.288 - w.close();
21.289 - }
21.290 -
21.291 - private static List<DuplicateDescription> translate(Map<String, long[]> hashes, Map<String, Map<RemoteIndex, Collection<String>>> occ, FileObject currentFile) {
21.292 - Map<String, Map<RemoteIndex, Collection<String>>> sorted = hashMap();
21.293 - Map<long[], DuplicateDescription> result = new LinkedHashMap<long[], DuplicateDescription>();
21.294 - List<long[]> seen = new LinkedList<long[]>();
21.295 -
21.296 - sorted.putAll(occ);
21.297 -
21.298 - OUTER: for (Entry<String, Map<RemoteIndex, Collection<String>>> e : occ.entrySet()) {
21.299 - long[] currentSpan = hashes.get(e.getKey());
21.300 -
21.301 - for (Iterator<Entry<long[], DuplicateDescription>> it = result.entrySet().iterator(); it.hasNext();) {
21.302 - Entry<long[], DuplicateDescription> span = it.next();
21.303 -
21.304 - if (span.getKey()[0] <= currentSpan[0] && span.getKey()[1] >= currentSpan[1]) {
21.305 - continue OUTER;
21.306 - }
21.307 -
21.308 - if (currentSpan[0] <= span.getKey()[0] && currentSpan[1] >= span.getKey()[1]) {
21.309 - it.remove();
21.310 - }
21.311 - }
21.312 -
21.313 - if (currentSpan[0] == (-1) || currentSpan[1] == (-1)) continue;
21.314 -
21.315 - seen.add(currentSpan);
21.316 -
21.317 - String longest = e.getKey();
21.318 - List<Span> foundDuplicates = new LinkedList<Span>();
21.319 -
21.320 - for (Entry<RemoteIndex, Collection<String>> root2Occurrences : e.getValue().entrySet()) {
21.321 - FileObject localRoot = URLMapper.findFileObject(root2Occurrences.getKey().getLocalFolder());
21.322 -
21.323 - for (String cand : root2Occurrences.getValue()) {
21.324 - FileObject o = localRoot.getFileObject(cand);
21.325 -
21.326 - if (o == null) continue; //XXX log!
21.327 - if (areEquivalent(currentFile, o)) continue;
21.328 -
21.329 - foundDuplicates.add(new Span(o, -1, -1));
21.330 - }
21.331 - }
21.332 -
21.333 - if (foundDuplicates.isEmpty()) continue;
21.334 -
21.335 - DuplicateDescription current = DuplicateDescription.of(foundDuplicates, getValue(longest), longest);
21.336 -
21.337 - result.put(currentSpan, current);
21.338 - }
21.339 -
21.340 - return new LinkedList<DuplicateDescription>(result.values());
21.341 - }
21.342 -
21.343 - private static boolean areEquivalent(FileObject f1, FileObject f2) {
21.344 - return f1.equals(f2);
21.345 - }
21.346 -
21.347 - private static long getValue(String encoded) {
21.348 - return Long.parseLong(encoded.substring(encoded.lastIndexOf(":") + 1));
21.349 - }
21.350 -
21.351 - private static <T> TreeMap<String, T> hashMap() {
21.352 - return new TreeMap<String, T>(new Comparator<String>() {
21.353 - public int compare(String arg0, String arg1) {
21.354 - return (int) Math.signum(getValue(arg1) - getValue(arg0));
21.355 - }
21.356 - });
21.357 - }
21.358 -
21.359 - private static boolean subsumes(DuplicateDescription bigger, DuplicateDescription smaller) {
21.360 - Set<FileObject> bFiles = new HashSet<FileObject>();
21.361 -
21.362 - for (Span s : bigger.dupes) {
21.363 - bFiles.add(s.file);
21.364 - }
21.365 -
21.366 - Set<FileObject> sFiles = new HashSet<FileObject>();
21.367 -
21.368 - for (Span s : smaller.dupes) {
21.369 - sFiles.add(s.file);
21.370 - }
21.371 -
21.372 - if (!bFiles.equals(sFiles)) return false;
21.373 -
21.374 - Span testAgainst = bigger.dupes.get(0);
21.375 -
21.376 - for (Span s : smaller.dupes) {
21.377 - if (s.file == testAgainst.file) {
21.378 - if ( (testAgainst.startOff <= s.startOff && testAgainst.endOff > s.endOff)
21.379 - || (testAgainst.startOff < s.startOff && testAgainst.endOff >= s.endOff)) {
21.380 - return true;
21.381 - }
21.382 - }
21.383 - }
21.384 -
21.385 - return false;
21.386 - }
21.387 -
21.388 - public static Map<String, Collection<? extends String>> containsHash(IndexReader reader, Iterable<? extends String> hashes) throws IOException {
21.389 - Map<String, Collection<? extends String>> result = new LinkedHashMap<String, Collection<? extends String>>();
21.390 -
21.391 - for (String hash : hashes) {
21.392 - Collection<String> found = new LinkedList<String>();
21.393 - Query query = new TermQuery(new Term("hash", hash));
21.394 - Searcher s = new IndexSearcher(reader);
21.395 - BitSet matchingDocuments = new BitSet(reader.maxDoc());
21.396 - Collector c = new BitSetCollector(matchingDocuments);
21.397 -
21.398 - s.search(query, c);
21.399 -
21.400 - boolean wasFound = false;
21.401 -
21.402 - for (int docNum = matchingDocuments.nextSetBit(0); docNum >= 0; docNum = matchingDocuments.nextSetBit(docNum + 1)) {
21.403 - final Document doc = reader.document(docNum);
21.404 -
21.405 - found.addAll(Arrays.asList(doc.getValues("path")));
21.406 - wasFound = true;
21.407 - }
21.408 -
21.409 - if (wasFound) {
21.410 - result.put(hash, found);
21.411 - }
21.412 - }
21.413 -
21.414 - return result;
21.415 - }
21.416 -}
22.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/examples/Bundle.properties Fri Jan 27 13:35:56 2012 +0100
22.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
22.3 @@ -1,45 +0,0 @@
22.4 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
22.5 -#
22.6 -# Copyright 2010 Oracle and/or its affiliates. All rights reserved.
22.7 -#
22.8 -# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
22.9 -# Other names may be trademarks of their respective owners.
22.10 -#
22.11 -# The contents of this file are subject to the terms of either the GNU
22.12 -# General Public License Version 2 only ("GPL") or the Common
22.13 -# Development and Distribution License("CDDL") (collectively, the
22.14 -# "License"). You may not use this file except in compliance with the
22.15 -# License. You can obtain a copy of the License at
22.16 -# http://www.netbeans.org/cddl-gplv2.html
22.17 -# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
22.18 -# specific language governing permissions and limitations under the
22.19 -# License. When distributing the software, include this License Header
22.20 -# Notice in each file and include the License file at
22.21 -# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
22.22 -# particular file as subject to the "Classpath" exception as provided
22.23 -# by Oracle in the GPL Version 2 section of the License file that
22.24 -# accompanied this code. If applicable, add the following below the
22.25 -# License Header, with the fields enclosed by brackets [] replaced by
22.26 -# your own identifying information:
22.27 -# "Portions Copyrighted [year] [name of copyright owner]"
22.28 -#
22.29 -# If you wish your version of this file to be governed by only the CDDL
22.30 -# or only the GPL Version 2, indicate your decision by adding
22.31 -# "[Contributor] elects to include this software in this distribution
22.32 -# under the [CDDL or GPL Version 2] license." If you do not indicate a
22.33 -# single choice of license, a recipient has the option to distribute
22.34 -# your version of this file under either the CDDL, the GPL Version 2 or
22.35 -# to extend the choice of license to its licensees as provided above.
22.36 -# However, if you add GPL Version 2 code and therefore, elected the GPL
22.37 -# Version 2 license, then the option applies only if the new code is
22.38 -# made subject to such option by the copyright holder.
22.39 -#
22.40 -# Contributor(s):
22.41 -#
22.42 -# Portions Copyrighted 2010 Sun Microsystems, Inc.
22.43 -
22.44 -double-checked-locking=Double Checked Locking
22.45 -double-checked-locking-verify=Double Checked Locking Strict
22.46 -double-checked-locking-fix=Double Checked Locking
22.47 -new-string=New String Creation
22.48 -lambda-candidate=Find candidates for Lambda expression
23.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/examples/Example.java Fri Jan 27 13:35:56 2012 +0100
23.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
23.3 @@ -1,83 +0,0 @@
23.4 -/*
23.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
23.6 - *
23.7 - * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
23.8 - *
23.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
23.10 - * Other names may be trademarks of their respective owners.
23.11 - *
23.12 - * The contents of this file are subject to the terms of either the GNU
23.13 - * General Public License Version 2 only ("GPL") or the Common
23.14 - * Development and Distribution License("CDDL") (collectively, the
23.15 - * "License"). You may not use this file except in compliance with the
23.16 - * License. You can obtain a copy of the License at
23.17 - * http://www.netbeans.org/cddl-gplv2.html
23.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
23.19 - * specific language governing permissions and limitations under the
23.20 - * License. When distributing the software, include this License Header
23.21 - * Notice in each file and include the License file at
23.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
23.23 - * particular file as subject to the "Classpath" exception as provided
23.24 - * by Oracle in the GPL Version 2 section of the License file that
23.25 - * accompanied this code. If applicable, add the following below the
23.26 - * License Header, with the fields enclosed by brackets [] replaced by
23.27 - * your own identifying information:
23.28 - * "Portions Copyrighted [year] [name of copyright owner]"
23.29 - *
23.30 - * If you wish your version of this file to be governed by only the CDDL
23.31 - * or only the GPL Version 2, indicate your decision by adding
23.32 - * "[Contributor] elects to include this software in this distribution
23.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
23.34 - * single choice of license, a recipient has the option to distribute
23.35 - * your version of this file under either the CDDL, the GPL Version 2 or
23.36 - * to extend the choice of license to its licensees as provided above.
23.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
23.38 - * Version 2 license, then the option applies only if the new code is
23.39 - * made subject to such option by the copyright holder.
23.40 - *
23.41 - * Contributor(s):
23.42 - *
23.43 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
23.44 - */
23.45 -
23.46 -package org.netbeans.modules.jackpot30.impl.examples;
23.47 -
23.48 -import java.util.Set;
23.49 -import org.openide.util.NbBundle;
23.50 -
23.51 -/**
23.52 - *
23.53 - * @author lahvac
23.54 - */
23.55 -public class Example {
23.56 -
23.57 - private final String key;
23.58 - private final String code;
23.59 - private final Set<Option> options;
23.60 -
23.61 - Example(String key, String code, Set<Option> options) {
23.62 - this.key = key;
23.63 - this.code = code;
23.64 - this.options = options;
23.65 - }
23.66 -
23.67 - String getKey() {
23.68 - return key;
23.69 - }
23.70 -
23.71 - public String getDisplayName() {
23.72 - return NbBundle.getMessage(LoadExamples.class, key);
23.73 - }
23.74 -
23.75 - public String getCode() {
23.76 - return code;
23.77 - }
23.78 -
23.79 - public Set<Option> getOptions() {
23.80 - return options;
23.81 - }
23.82 -
23.83 - public enum Option {
23.84 - VERIFY, FIX;
23.85 - }
23.86 -}
24.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/examples/LoadExamples.java Fri Jan 27 13:35:56 2012 +0100
24.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
24.3 @@ -1,135 +0,0 @@
24.4 -/*
24.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
24.6 - *
24.7 - * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
24.8 - *
24.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
24.10 - * Other names may be trademarks of their respective owners.
24.11 - *
24.12 - * The contents of this file are subject to the terms of either the GNU
24.13 - * General Public License Version 2 only ("GPL") or the Common
24.14 - * Development and Distribution License("CDDL") (collectively, the
24.15 - * "License"). You may not use this file except in compliance with the
24.16 - * License. You can obtain a copy of the License at
24.17 - * http://www.netbeans.org/cddl-gplv2.html
24.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
24.19 - * specific language governing permissions and limitations under the
24.20 - * License. When distributing the software, include this License Header
24.21 - * Notice in each file and include the License file at
24.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
24.23 - * particular file as subject to the "Classpath" exception as provided
24.24 - * by Oracle in the GPL Version 2 section of the License file that
24.25 - * accompanied this code. If applicable, add the following below the
24.26 - * License Header, with the fields enclosed by brackets [] replaced by
24.27 - * your own identifying information:
24.28 - * "Portions Copyrighted [year] [name of copyright owner]"
24.29 - *
24.30 - * If you wish your version of this file to be governed by only the CDDL
24.31 - * or only the GPL Version 2, indicate your decision by adding
24.32 - * "[Contributor] elects to include this software in this distribution
24.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
24.34 - * single choice of license, a recipient has the option to distribute
24.35 - * your version of this file under either the CDDL, the GPL Version 2 or
24.36 - * to extend the choice of license to its licensees as provided above.
24.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
24.38 - * Version 2 license, then the option applies only if the new code is
24.39 - * made subject to such option by the copyright holder.
24.40 - *
24.41 - * Contributor(s):
24.42 - *
24.43 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
24.44 - */
24.45 -
24.46 -package org.netbeans.modules.jackpot30.impl.examples;
24.47 -
24.48 -import java.io.File;
24.49 -import java.io.IOException;
24.50 -import java.io.InputStream;
24.51 -import java.util.Collections;
24.52 -import java.util.EnumSet;
24.53 -import java.util.LinkedList;
24.54 -import java.util.List;
24.55 -import java.util.Set;
24.56 -import java.util.regex.Pattern;
24.57 -import org.netbeans.modules.jackpot30.impl.examples.Example.Option;
24.58 -import org.openide.filesystems.FileUtil;
24.59 -import org.openide.modules.InstalledFileLocator;
24.60 -import org.openide.util.Exceptions;
24.61 -
24.62 -/**
24.63 - *
24.64 - * @author lahvac
24.65 - */
24.66 -public class LoadExamples {
24.67 -
24.68 - public static Iterable<? extends Example> loadExamples() {
24.69 - return loadExamples("examples.list");
24.70 - }
24.71 -
24.72 - private static final Pattern EXAMPLE_SPLIT = Pattern.compile("^%%", Pattern.MULTILINE);
24.73 -
24.74 - static Iterable<? extends Example> loadExamples(String examplesListName) {
24.75 - String examplesList = loadToString(examplesListName);
24.76 -
24.77 - if (examplesList == null) return Collections.emptyList();
24.78 -
24.79 - List<Example> examples = new LinkedList<Example>();
24.80 -
24.81 - for (String exampleName : examplesList.split("\n")) {
24.82 - if (exampleName.isEmpty()) continue;
24.83 -
24.84 - String exampleCode = loadToString(exampleName);
24.85 -
24.86 - for (String oneExample : EXAMPLE_SPLIT.split(exampleCode)) {
24.87 - if (oneExample.isEmpty()) continue;
24.88 -
24.89 - String[] parts = oneExample.split("\n", 2);
24.90 - String key = null;
24.91 - Set<Option> options = EnumSet.noneOf(Option.class);
24.92 -
24.93 - for (String option : parts[0].split(",")) {
24.94 - if (option.startsWith("example=")) {
24.95 - key = option.substring("example=".length());
24.96 - continue;
24.97 - }
24.98 -
24.99 - options.add(Option.valueOf(option.toUpperCase()));
24.100 - }
24.101 -
24.102 - examples.add(new Example(key, parts[1], options));
24.103 - }
24.104 - }
24.105 -
24.106 - return examples;
24.107 - }
24.108 -
24.109 - private static String loadToString(String name) {
24.110 - InputStream examplesList = null;
24.111 -
24.112 - try {
24.113 - examplesList = LoadExamples.class.getResourceAsStream(name);
24.114 -
24.115 - if (examplesList == null) return null;
24.116 -
24.117 - StringBuilder result = new StringBuilder();
24.118 - int read;
24.119 -
24.120 - while ((read = examplesList.read()) != (-1)) {
24.121 - result.append((char) read);
24.122 - }
24.123 -
24.124 - return result.toString();
24.125 - } catch (IOException ex) {
24.126 - Exceptions.printStackTrace(ex);
24.127 - return null;
24.128 - } finally {
24.129 - if (examplesList != null) {
24.130 - try {
24.131 - examplesList.close();
24.132 - } catch (IOException ex) {
24.133 - Exceptions.printStackTrace(ex);
24.134 - }
24.135 - }
24.136 - }
24.137 - }
24.138 -}
25.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/examples/double-checked-locking.example Fri Jan 27 13:35:56 2012 +0100
25.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
25.3 @@ -1,33 +0,0 @@
25.4 -%%example=double-checked-locking
25.5 -if ($var == null) {
25.6 - $preinit$;
25.7 - synchronized ($lock) {
25.8 - if ($var == null) {
25.9 - $s2$;
25.10 - }
25.11 - }
25.12 -}
25.13 -%%example=double-checked-locking-verify,verify
25.14 -if ($var == null) {
25.15 - $preinit$;
25.16 - synchronized ($lock) {
25.17 - if ($var == null) {
25.18 - $s2$;
25.19 - }
25.20 - }
25.21 -} :: !hasModifier($var, Modifier.VOLATILE);;
25.22 -%%example=double-checked-locking-fix,verify,fix
25.23 -if ($var == null) {
25.24 - $preinit$;
25.25 - synchronized ($lock) {
25.26 - if ($var == null) {
25.27 - $s2$;
25.28 - }
25.29 - }
25.30 -} :: !hasModifier($var, Modifier.VOLATILE)
25.31 -=>
25.32 -synchronized ($lock) {
25.33 - if ($var == null) {
25.34 - $s2$;
25.35 - }
25.36 -};;
26.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/examples/examples.list Fri Jan 27 13:35:56 2012 +0100
26.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
26.3 @@ -1,3 +0,0 @@
26.4 -double-checked-locking.example
26.5 -new-string.example
26.6 -lambda-candidate.example
27.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/examples/lambda-candidate.example Fri Jan 27 13:35:56 2012 +0100
27.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
27.3 @@ -1,6 +0,0 @@
27.4 -%%example=lambda-candidate
27.5 -new $type() {
27.6 - $mods$ $resultType $methodName($args$) {
27.7 - $statements$;
27.8 - }
27.9 -}
28.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/examples/new-string.example Fri Jan 27 13:35:56 2012 +0100
28.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
28.3 @@ -1,5 +0,0 @@
28.4 -%%example=new-string,verify
28.5 -new String($orig) :: $orig instanceof String && !matchesAny($orig, "$o.substring($s)", "$o.substring($s, $e)");;
28.6 -%%example=new-string,verify,fix
28.7 -new String($orig) :: $orig instanceof String && !matchesAny($orig, "$o.substring($s)", "$o.substring($s, $e)")
28.8 -=> $orig;;
29.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/hints/ExplicitFindDuplicates.java Fri Jan 27 13:35:56 2012 +0100
29.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
29.3 @@ -1,379 +0,0 @@
29.4 -/*
29.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
29.6 - *
29.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
29.8 - *
29.9 - * The contents of this file are subject to the terms of either the GNU
29.10 - * General Public License Version 2 only ("GPL") or the Common
29.11 - * Development and Distribution License("CDDL") (collectively, the
29.12 - * "License"). You may not use this file except in compliance with the
29.13 - * License. You can obtain a copy of the License at
29.14 - * http://www.netbeans.org/cddl-gplv2.html
29.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
29.16 - * specific language governing permissions and limitations under the
29.17 - * License. When distributing the software, include this License Header
29.18 - * Notice in each file and include the License file at
29.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
29.20 - * particular file as subject to the "Classpath" exception as provided
29.21 - * by Sun in the GPL Version 2 section of the License file that
29.22 - * accompanied this code. If applicable, add the following below the
29.23 - * License Header, with the fields enclosed by brackets [] replaced by
29.24 - * your own identifying information:
29.25 - * "Portions Copyrighted [year] [name of copyright owner]"
29.26 - *
29.27 - * If you wish your version of this file to be governed by only the CDDL
29.28 - * or only the GPL Version 2, indicate your decision by adding
29.29 - * "[Contributor] elects to include this software in this distribution
29.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
29.31 - * single choice of license, a recipient has the option to distribute
29.32 - * your version of this file under either the CDDL, the GPL Version 2 or
29.33 - * to extend the choice of license to its licensees as provided above.
29.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
29.35 - * Version 2 license, then the option applies only if the new code is
29.36 - * made subject to such option by the copyright holder.
29.37 - *
29.38 - * Contributor(s):
29.39 - *
29.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
29.41 - */
29.42 -
29.43 -package org.netbeans.modules.jackpot30.impl.hints;
29.44 -
29.45 -import com.sun.source.tree.BlockTree;
29.46 -import com.sun.source.tree.ExpressionTree;
29.47 -import com.sun.source.tree.NewClassTree;
29.48 -import com.sun.source.tree.StatementTree;
29.49 -import com.sun.source.tree.Tree;
29.50 -import com.sun.source.tree.Tree.Kind;
29.51 -import com.sun.source.tree.VariableTree;
29.52 -import com.sun.source.util.TreePath;
29.53 -import java.util.Collection;
29.54 -import java.util.Collections;
29.55 -import java.util.EnumSet;
29.56 -import java.util.Set;
29.57 -import javax.lang.model.type.ErrorType;
29.58 -import javax.lang.model.type.TypeKind;
29.59 -import javax.lang.model.type.TypeMirror;
29.60 -import javax.swing.SwingUtilities;
29.61 -import org.netbeans.api.java.lexer.JavaTokenId;
29.62 -import org.netbeans.api.java.source.CancellableTask;
29.63 -import org.netbeans.api.java.source.CompilationController;
29.64 -import org.netbeans.api.java.source.CompilationInfo;
29.65 -import org.netbeans.api.java.source.JavaSource;
29.66 -import org.netbeans.api.java.source.JavaSource.Phase;
29.67 -import org.netbeans.api.java.source.JavaSource.Priority;
29.68 -import org.netbeans.api.java.source.JavaSourceTaskFactory;
29.69 -import org.netbeans.api.java.source.Task;
29.70 -import org.netbeans.api.java.source.TreePathHandle;
29.71 -import org.netbeans.api.java.source.support.CaretAwareJavaSourceTaskFactory;
29.72 -import org.netbeans.api.java.source.support.SelectionAwareJavaSourceTaskFactory;
29.73 -import org.netbeans.api.lexer.TokenSequence;
29.74 -import org.netbeans.modules.jackpot30.impl.refactoring.FindDuplicatesRefactoringUI;
29.75 -import org.netbeans.modules.java.hints.jackpot.impl.Utilities;
29.76 -import org.netbeans.modules.java.hints.jackpot.impl.batch.Scopes;
29.77 -import org.netbeans.modules.refactoring.spi.ui.UI;
29.78 -import org.netbeans.spi.editor.hints.ChangeInfo;
29.79 -import org.netbeans.spi.editor.hints.ErrorDescription;
29.80 -import org.netbeans.spi.editor.hints.ErrorDescriptionFactory;
29.81 -import org.netbeans.spi.editor.hints.Fix;
29.82 -import org.netbeans.spi.editor.hints.HintsController;
29.83 -import org.netbeans.spi.editor.hints.Severity;
29.84 -import org.openide.filesystems.FileObject;
29.85 -import org.openide.util.lookup.ServiceProvider;
29.86 -
29.87 -/**
29.88 - *
29.89 - * @author lahvac
29.90 - */
29.91 -public class ExplicitFindDuplicates implements CancellableTask<CompilationInfo> {
29.92 -
29.93 - public void run(CompilationInfo info) throws Exception {
29.94 - Collection<? extends ErrorDescription> eds = computeErrorDescription(info);
29.95 -
29.96 - if (eds == null) {
29.97 - eds = Collections.emptyList();
29.98 - }
29.99 -
29.100 - HintsController.setErrors(info.getFileObject(), ExplicitFindDuplicates.class.getName(), eds);
29.101 - }
29.102 -
29.103 - private Collection<? extends ErrorDescription> computeErrorDescription(CompilationInfo info) throws Exception {
29.104 - int[] span = SelectionAwareJavaSourceTaskFactory.getLastSelection(info.getFileObject());
29.105 -
29.106 - if (span == null) {
29.107 - return null;
29.108 - }
29.109 -
29.110 - TreePath selection = selectionForExpressionHack(info, span[0], span[1]);
29.111 -
29.112 - if (selection == null) {
29.113 - if (selectionForStatementsHack(info, span[0], span[1], new int[2]) == null) {
29.114 - return null;
29.115 - }
29.116 - }
29.117 -
29.118 - Fix f = new FixImpl(info.getFileObject(), span[0], span[1]);
29.119 - int caret = CaretAwareJavaSourceTaskFactory.getLastPosition(info.getFileObject());
29.120 - ErrorDescription ed = ErrorDescriptionFactory.createErrorDescription(Severity.HINT, "Look for Duplicates", Collections.singletonList(f), info.getFileObject(), caret, caret);
29.121 -
29.122 - return Collections.singletonList(ed);
29.123 - }
29.124 -
29.125 - public void cancel() {
29.126 - //XXX
29.127 - }
29.128 -
29.129 - static Tree resolveAndGeneralizePattern(CompilationInfo info, int start, int end) {
29.130 - TreePath selection = selectionForExpressionHack(info, start, end);
29.131 -
29.132 - if (selection == null) {
29.133 - int[] statementSpan = new int[2];
29.134 - TreePathHandle statementSelection = selectionForStatementsHack(info, start, end, statementSpan);
29.135 -
29.136 - if (statementSelection == null) {
29.137 - return null;
29.138 - }
29.139 -
29.140 - selection = statementSelection.resolve(info);
29.141 -
29.142 - if (selection == null) {
29.143 - return null; //XXX
29.144 - }
29.145 -
29.146 - return Utilities.generalizePattern(info, selection, statementSpan[0], statementSpan[1]);
29.147 - } else {
29.148 - return Utilities.generalizePattern(info, selection);
29.149 - }
29.150 - }
29.151 -
29.152 - private static final class FixImpl implements Fix {
29.153 -
29.154 - private final FileObject file;
29.155 - private final int start;
29.156 - private final int end;
29.157 -
29.158 - public FixImpl(FileObject file, int start, int end) {
29.159 - this.file = file;
29.160 - this.start = start;
29.161 - this.end = end;
29.162 - }
29.163 -
29.164 - public String getText() {
29.165 - return "Look for Duplicates in Opened Projects";
29.166 - }
29.167 -
29.168 - public ChangeInfo implement() throws Exception {
29.169 - JavaSource.forFileObject(file).runUserActionTask(new Task<CompilationController>() {
29.170 - public void run(CompilationController cc) throws Exception {
29.171 - cc.toPhase(Phase.RESOLVED);
29.172 -
29.173 - Tree generalized = resolveAndGeneralizePattern(cc, start, end);
29.174 -
29.175 - if (generalized == null) {
29.176 - return ;
29.177 - }
29.178 -
29.179 - final String pattern = generalized.toString(); //XXX
29.180 -
29.181 - SwingUtilities.invokeLater(new Runnable() {
29.182 - public void run() {
29.183 - UI.openRefactoringUI(new FindDuplicatesRefactoringUI(pattern, Scopes.allOpenedProjectsScope()));
29.184 - }
29.185 - });
29.186 - }
29.187 - }, true);
29.188 -
29.189 - return null;
29.190 - }
29.191 -
29.192 - }
29.193 -
29.194 - private static final Set<TypeKind> NOT_ACCEPTED_TYPES = EnumSet.of(TypeKind.NONE, TypeKind.OTHER);
29.195 -
29.196 - static TreePath selectionForExpressionHack(CompilationInfo info, int start, int end) {
29.197 - return validateSelection(info, start, end, NOT_ACCEPTED_TYPES);
29.198 - }
29.199 -
29.200 - static TreePathHandle selectionForStatementsHack(CompilationInfo info, int start, int end, int[] outSpan) {
29.201 - return validateSelectionForIntroduceMethod(info, start, end, outSpan);
29.202 - }
29.203 -
29.204 - private static final Set<JavaTokenId> WHITESPACES = EnumSet.of(JavaTokenId.WHITESPACE, JavaTokenId.BLOCK_COMMENT, JavaTokenId.LINE_COMMENT, JavaTokenId.JAVADOC_COMMENT);
29.205 - static int[] ignoreWhitespaces(CompilationInfo ci, int start, int end) {
29.206 - TokenSequence<JavaTokenId> ts = ci.getTokenHierarchy().tokenSequence(JavaTokenId.language());
29.207 -
29.208 - if (ts == null) {
29.209 - return new int[] {start, end};
29.210 - }
29.211 -
29.212 - ts.move(start);
29.213 -
29.214 - if (ts.moveNext()) {
29.215 - boolean wasMoveNext = true;
29.216 -
29.217 - while (WHITESPACES.contains(ts.token().id()) && (wasMoveNext = ts.moveNext()))
29.218 - ;
29.219 -
29.220 - if (wasMoveNext && ts.offset() > start)
29.221 - start = ts.offset();
29.222 - }
29.223 -
29.224 - ts.move(end);
29.225 -
29.226 - while (ts.movePrevious() && WHITESPACES.contains(ts.token().id()) && ts.offset() < end)
29.227 - end = ts.offset();
29.228 -
29.229 - return new int[] {start, end};
29.230 - }
29.231 -
29.232 - private static boolean isInsideClass(TreePath tp) {
29.233 - while (tp != null) {
29.234 - if (tp.getLeaf().getKind() == Kind.CLASS)
29.235 - return true;
29.236 -
29.237 - tp = tp.getParentPath();
29.238 - }
29.239 -
29.240 - return false;
29.241 - }
29.242 -
29.243 - private static TreePath validateSelection(CompilationInfo ci, int start, int end, Set<TypeKind> ignoredTypes) {
29.244 - TreePath tp = ci.getTreeUtilities().pathFor((start + end) / 2 + 1);
29.245 -
29.246 - for ( ; tp != null; tp = tp.getParentPath()) {
29.247 - Tree leaf = tp.getLeaf();
29.248 -
29.249 - if (!ExpressionTree.class.isAssignableFrom(leaf.getKind().asInterface()))
29.250 - continue;
29.251 -
29.252 - long treeStart = ci.getTrees().getSourcePositions().getStartPosition(ci.getCompilationUnit(), leaf);
29.253 - long treeEnd = ci.getTrees().getSourcePositions().getEndPosition(ci.getCompilationUnit(), leaf);
29.254 -
29.255 - if (treeStart != start || treeEnd != end) {
29.256 - continue;
29.257 - }
29.258 -
29.259 - TypeMirror type = ci.getTrees().getTypeMirror(tp);
29.260 -
29.261 - if (type != null && type.getKind() == TypeKind.ERROR) {
29.262 - type = ci.getTrees().getOriginalType((ErrorType) type);
29.263 - }
29.264 -
29.265 - if (type == null || ignoredTypes.contains(type.getKind()))
29.266 - continue;
29.267 -
29.268 - if(tp.getLeaf().getKind() == Kind.ASSIGNMENT)
29.269 - continue;
29.270 -
29.271 - if (tp.getLeaf().getKind() == Kind.ANNOTATION)
29.272 - continue;
29.273 -
29.274 - if (!isInsideClass(tp))
29.275 - return null;
29.276 -
29.277 - TreePath candidate = tp;
29.278 -
29.279 - tp = tp.getParentPath();
29.280 -
29.281 - while (tp != null) {
29.282 - switch (tp.getLeaf().getKind()) {
29.283 - case VARIABLE:
29.284 - VariableTree vt = (VariableTree) tp.getLeaf();
29.285 - if (vt.getInitializer() == leaf) {
29.286 - return candidate;
29.287 - } else {
29.288 - return null;
29.289 - }
29.290 - case NEW_CLASS:
29.291 - NewClassTree nct = (NewClassTree) tp.getLeaf();
29.292 -
29.293 - if (nct.getIdentifier().equals(candidate.getLeaf())) { //avoid disabling hint ie inside of anonymous class higher in treepath
29.294 - for (Tree p : nct.getArguments()) {
29.295 - if (p == leaf) {
29.296 - return candidate;
29.297 - }
29.298 - }
29.299 -
29.300 - return null;
29.301 - }
29.302 - }
29.303 -
29.304 - leaf = tp.getLeaf();
29.305 - tp = tp.getParentPath();
29.306 - }
29.307 -
29.308 - return candidate;
29.309 - }
29.310 -
29.311 - return null;
29.312 - }
29.313 -
29.314 - private static TreePathHandle validateSelectionForIntroduceMethod(CompilationInfo ci, int start, int end, int[] statementsSpan) {
29.315 - int[] span = ignoreWhitespaces(ci, Math.min(start, end), Math.max(start, end));
29.316 -
29.317 - start = span[0];
29.318 - end = span[1];
29.319 -
29.320 - if (start >= end)
29.321 - return null;
29.322 -
29.323 - TreePath tpStart = ci.getTreeUtilities().pathFor(start);
29.324 - TreePath tpEnd = ci.getTreeUtilities().pathFor(end);
29.325 -
29.326 - if (tpStart.getLeaf() != tpEnd.getLeaf() || tpStart.getLeaf().getKind() != Kind.BLOCK) {
29.327 - //??? not in the same block:
29.328 - return null;
29.329 - }
29.330 -
29.331 - int from = -1;
29.332 - int to = -1;
29.333 -
29.334 - BlockTree block = (BlockTree) tpStart.getLeaf();
29.335 - int index = 0;
29.336 -
29.337 - for (StatementTree s : block.getStatements()) {
29.338 - long sStart = ci.getTrees().getSourcePositions().getStartPosition(ci.getCompilationUnit(), s);
29.339 -
29.340 - if (sStart == start) {
29.341 - from = index;
29.342 - }
29.343 -
29.344 - if (end < sStart && to == (-1)) {
29.345 - to = index - 1;
29.346 - }
29.347 -
29.348 - index++;
29.349 - }
29.350 -
29.351 - if (from == (-1)) {
29.352 - return null;
29.353 - }
29.354 -
29.355 - if (to == (-1))
29.356 - to = block.getStatements().size() - 1;
29.357 -
29.358 - if (to < from) {
29.359 - return null;
29.360 - }
29.361 -
29.362 - statementsSpan[0] = from;
29.363 - statementsSpan[1] = to;
29.364 -
29.365 - return TreePathHandle.create(tpStart, ci);
29.366 - }
29.367 -
29.368 - @ServiceProvider(service=JavaSourceTaskFactory.class)
29.369 - public static final class FactoryImpl extends SelectionAwareJavaSourceTaskFactory {
29.370 -
29.371 - public FactoryImpl() {
29.372 - super(Phase.RESOLVED, Priority.LOW);
29.373 - }
29.374 -
29.375 - @Override
29.376 - protected CancellableTask<CompilationInfo> createTask(FileObject file) {
29.377 - return new ExplicitFindDuplicates();
29.378 - }
29.379 -
29.380 - }
29.381 -
29.382 -}
30.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/hints/FindDuplicates.java Fri Jan 27 13:35:56 2012 +0100
30.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
30.3 @@ -1,133 +0,0 @@
30.4 -/*
30.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
30.6 - *
30.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
30.8 - *
30.9 - * The contents of this file are subject to the terms of either the GNU
30.10 - * General Public License Version 2 only ("GPL") or the Common
30.11 - * Development and Distribution License("CDDL") (collectively, the
30.12 - * "License"). You may not use this file except in compliance with the
30.13 - * License. You can obtain a copy of the License at
30.14 - * http://www.netbeans.org/cddl-gplv2.html
30.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
30.16 - * specific language governing permissions and limitations under the
30.17 - * License. When distributing the software, include this License Header
30.18 - * Notice in each file and include the License file at
30.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
30.20 - * particular file as subject to the "Classpath" exception as provided
30.21 - * by Sun in the GPL Version 2 section of the License file that
30.22 - * accompanied this code. If applicable, add the following below the
30.23 - * License Header, with the fields enclosed by brackets [] replaced by
30.24 - * your own identifying information:
30.25 - * "Portions Copyrighted [year] [name of copyright owner]"
30.26 - *
30.27 - * If you wish your version of this file to be governed by only the CDDL
30.28 - * or only the GPL Version 2, indicate your decision by adding
30.29 - * "[Contributor] elects to include this software in this distribution
30.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
30.31 - * single choice of license, a recipient has the option to distribute
30.32 - * your version of this file under either the CDDL, the GPL Version 2 or
30.33 - * to extend the choice of license to its licensees as provided above.
30.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
30.35 - * Version 2 license, then the option applies only if the new code is
30.36 - * made subject to such option by the copyright holder.
30.37 - *
30.38 - * Contributor(s):
30.39 - *
30.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
30.41 - */
30.42 -
30.43 -package org.netbeans.modules.jackpot30.impl.hints;
30.44 -
30.45 -import java.util.Collection;
30.46 -import java.util.Collections;
30.47 -import java.util.Iterator;
30.48 -import java.util.LinkedList;
30.49 -import java.util.List;
30.50 -import java.util.Map;
30.51 -import java.util.concurrent.atomic.AtomicBoolean;
30.52 -import java.util.logging.Level;
30.53 -import java.util.logging.Logger;
30.54 -import org.netbeans.api.java.source.CancellableTask;
30.55 -import org.netbeans.api.java.source.CompilationInfo;
30.56 -import org.netbeans.api.java.source.JavaSource.Phase;
30.57 -import org.netbeans.api.java.source.JavaSource.Priority;
30.58 -import org.netbeans.api.java.source.JavaSourceTaskFactory;
30.59 -import org.netbeans.api.java.source.support.EditorAwareJavaSourceTaskFactory;
30.60 -import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates;
30.61 -import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.DuplicateDescription;
30.62 -import org.netbeans.modules.jackpot30.impl.duplicates.indexing.RemoteDuplicatesIndex;
30.63 -import org.netbeans.spi.editor.hints.ErrorDescription;
30.64 -import org.netbeans.spi.editor.hints.ErrorDescriptionFactory;
30.65 -import org.netbeans.spi.editor.hints.HintsController;
30.66 -import org.netbeans.spi.editor.hints.Severity;
30.67 -import org.openide.filesystems.FileObject;
30.68 -import org.openide.util.NbCollections;
30.69 -import org.openide.util.lookup.ServiceProvider;
30.70 -
30.71 -/**
30.72 - *
30.73 - * @author lahvac
30.74 - */
30.75 -public class FindDuplicates implements CancellableTask<CompilationInfo> {
30.76 -
30.77 - private final AtomicBoolean cancel = new AtomicBoolean();
30.78 -
30.79 - public void run(CompilationInfo info) throws Exception {
30.80 - cancel.set(false);
30.81 -
30.82 - long start = System.currentTimeMillis();
30.83 - try {
30.84 - Collection<? extends ErrorDescription> eds = computeErrorDescription(info);
30.85 -
30.86 - if (cancel.get()) return;
30.87 -
30.88 - if (eds == null) {
30.89 - eds = Collections.emptyList();
30.90 - }
30.91 -
30.92 - HintsController.setErrors(info.getFileObject(), FindDuplicates.class.getName(), eds);
30.93 - } finally {
30.94 - long end = System.currentTimeMillis();
30.95 -
30.96 - Logger.getLogger("TIMER").log(Level.FINE, "Duplicates in editor", new Object[] {info.getFileObject(), end - start});
30.97 - }
30.98 - }
30.99 -
30.100 - private Collection<? extends ErrorDescription> computeErrorDescription(CompilationInfo info) throws Exception {
30.101 - List<ErrorDescription> result = new LinkedList<ErrorDescription>();
30.102 -
30.103 - Map<String, long[]> encoded = ComputeDuplicates.encodeGeneralized(info);
30.104 - Iterator<? extends DuplicateDescription> duplicates = RemoteDuplicatesIndex.findDuplicates(encoded, info.getFileObject()).iterator();
30.105 -
30.106 - for (DuplicateDescription dd : NbCollections.iterable(duplicates)) {
30.107 - long[] spans = encoded.get(dd.hash);
30.108 -
30.109 - for (int c = 0; c < spans.length; c += 2) {
30.110 - if (cancel.get()) return null;
30.111 - result.add(ErrorDescriptionFactory.createErrorDescription(Severity.WARNING, "Duplicate of code from " + dd.dupes.get(0).file, info.getFileObject(), (int) spans[c], (int) spans[c + 1]));
30.112 - }
30.113 - }
30.114 -
30.115 - return result;
30.116 - }
30.117 -
30.118 - public void cancel() {
30.119 - cancel.set(true);
30.120 - }
30.121 -
30.122 - @ServiceProvider(service=JavaSourceTaskFactory.class)
30.123 - public static final class FactoryImpl extends EditorAwareJavaSourceTaskFactory {
30.124 -
30.125 - public FactoryImpl() {
30.126 - super(Phase.RESOLVED, Priority.LOW);
30.127 - }
30.128 -
30.129 - @Override
30.130 - protected CancellableTask<CompilationInfo> createTask(FileObject file) {
30.131 - return new FindDuplicates();
30.132 - }
30.133 -
30.134 - }
30.135 -
30.136 -}
31.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/indexing/AbstractLuceneIndex.java Fri Jan 27 13:35:56 2012 +0100
31.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
31.3 @@ -1,430 +0,0 @@
31.4 -/*
31.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
31.6 - *
31.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
31.8 - *
31.9 - * The contents of this file are subject to the terms of either the GNU
31.10 - * General Public License Version 2 only ("GPL") or the Common
31.11 - * Development and Distribution License("CDDL") (collectively, the
31.12 - * "License"). You may not use this file except in compliance with the
31.13 - * License. You can obtain a copy of the License at
31.14 - * http://www.netbeans.org/cddl-gplv2.html
31.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
31.16 - * specific language governing permissions and limitations under the
31.17 - * License. When distributing the software, include this License Header
31.18 - * Notice in each file and include the License file at
31.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
31.20 - * particular file as subject to the "Classpath" exception as provided
31.21 - * by Sun in the GPL Version 2 section of the License file that
31.22 - * accompanied this code. If applicable, add the following below the
31.23 - * License Header, with the fields enclosed by brackets [] replaced by
31.24 - * your own identifying information:
31.25 - * "Portions Copyrighted [year] [name of copyright owner]"
31.26 - *
31.27 - * If you wish your version of this file to be governed by only the CDDL
31.28 - * or only the GPL Version 2, indicate your decision by adding
31.29 - * "[Contributor] elects to include this software in this distribution
31.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
31.31 - * single choice of license, a recipient has the option to distribute
31.32 - * your version of this file under either the CDDL, the GPL Version 2 or
31.33 - * to extend the choice of license to its licensees as provided above.
31.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
31.35 - * Version 2 license, then the option applies only if the new code is
31.36 - * made subject to such option by the copyright holder.
31.37 - *
31.38 - * Contributor(s):
31.39 - *
31.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
31.41 - */
31.42 -
31.43 -package org.netbeans.modules.jackpot30.impl.indexing;
31.44 -
31.45 -import com.sun.source.tree.CompilationUnitTree;
31.46 -import com.sun.source.tree.Tree;
31.47 -import com.sun.source.util.TreePath;
31.48 -import com.sun.source.util.TreePathScanner;
31.49 -import java.io.ByteArrayInputStream;
31.50 -import java.io.ByteArrayOutputStream;
31.51 -import java.io.IOException;
31.52 -import java.net.URL;
31.53 -import java.util.BitSet;
31.54 -import java.util.Collection;
31.55 -import java.util.Collections;
31.56 -import java.util.HashMap;
31.57 -import java.util.HashSet;
31.58 -import java.util.Iterator;
31.59 -import java.util.List;
31.60 -import java.util.Map;
31.61 -import java.util.Set;
31.62 -import java.util.logging.Level;
31.63 -import java.util.logging.Logger;
31.64 -import java.util.zip.DataFormatException;
31.65 -import javax.lang.model.type.ArrayType;
31.66 -import javax.lang.model.type.TypeKind;
31.67 -import javax.lang.model.type.TypeMirror;
31.68 -import org.apache.lucene.analysis.TokenStream;
31.69 -import org.apache.lucene.analysis.tokenattributes.TermAttribute;
31.70 -import org.apache.lucene.document.CompressionTools;
31.71 -import org.apache.lucene.document.Document;
31.72 -import org.apache.lucene.document.Field;
31.73 -import org.apache.lucene.document.FieldSelector;
31.74 -import org.apache.lucene.document.FieldSelectorResult;
31.75 -import org.apache.lucene.index.IndexReader;
31.76 -import org.apache.lucene.index.Term;
31.77 -import org.apache.lucene.queryParser.ParseException;
31.78 -import org.apache.lucene.search.BooleanClause;
31.79 -import org.apache.lucene.search.BooleanQuery;
31.80 -import org.apache.lucene.search.Collector;
31.81 -import org.apache.lucene.search.IndexSearcher;
31.82 -import org.apache.lucene.search.PhraseQuery;
31.83 -import org.apache.lucene.search.Query;
31.84 -import org.apache.lucene.search.Scorer;
31.85 -import org.apache.lucene.search.Searcher;
31.86 -import org.apache.lucene.search.TermQuery;
31.87 -import org.apache.lucene.search.TopDocs;
31.88 -import org.netbeans.api.annotations.common.NonNull;
31.89 -import org.netbeans.api.annotations.common.NullAllowed;
31.90 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch;
31.91 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch.BulkPattern;
31.92 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch.EncodingContext;
31.93 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription.AdditionalQueryConstraints;
31.94 -import org.openide.util.Exceptions;
31.95 -
31.96 -/**
31.97 - *
31.98 - * @author lahvac
31.99 - */
31.100 -public abstract class AbstractLuceneIndex extends Index {
31.101 -
31.102 - public static final int MAJOR_VERSION = 1;
31.103 - //2: partial attribution added (erased types that occur in the file)
31.104 - public static final int MINOR_VERSION = 2;
31.105 -
31.106 - private final int stripLength;
31.107 - private final boolean readOnly;
31.108 - private final boolean storeFullSourceCode;
31.109 -
31.110 - protected AbstractLuceneIndex(int stripLength, boolean readOnly, boolean storeFullSourceCode) {
31.111 - this.stripLength = stripLength;
31.112 - this.readOnly = readOnly;
31.113 - this.storeFullSourceCode = storeFullSourceCode;
31.114 - }
31.115 -
31.116 - public final IndexWriter openForWriting() throws IOException {
31.117 - if (readOnly) throw new UnsupportedOperationException();
31.118 - return new IndexWriterImpl();
31.119 - }
31.120 -
31.121 - protected abstract IndexReader createReader() throws IOException;
31.122 - protected abstract org.apache.lucene.index.IndexWriter createWriter() throws IOException;
31.123 -
31.124 - @Override
31.125 - public Collection<? extends String> findCandidates(BulkPattern pattern) throws IOException {
31.126 - return findCandidates(pattern, false).keySet();
31.127 - }
31.128 -
31.129 - @Override
31.130 - public Map<String, Map<String, Integer>> findCandidatesWithFrequencies(BulkPattern pattern) throws IOException {
31.131 - return findCandidates(pattern, true);
31.132 - }
31.133 -
31.134 - private Map<String, Map<String, Integer>> findCandidates(BulkPattern pattern, boolean withFrequencies) throws IOException {
31.135 - IndexReader reader = createReader();
31.136 -
31.137 - if (reader == null) {
31.138 - return Collections.emptyMap();
31.139 - }
31.140 -
31.141 - try {
31.142 - Searcher s = new IndexSearcher(reader);
31.143 - BitSet matchingDocuments = new BitSet(reader.maxDoc());
31.144 - Collector c = new BitSetCollector(matchingDocuments);
31.145 -
31.146 - try {
31.147 - s.search(query(pattern), c);
31.148 - } catch (ParseException ex) {
31.149 - throw new IOException(ex);
31.150 - }
31.151 -
31.152 - Map<String, Map<String, Integer>> result = new HashMap<String, Map<String, Integer>>();
31.153 -
31.154 - for (int docNum = matchingDocuments.nextSetBit(0); docNum >= 0; docNum = matchingDocuments.nextSetBit(docNum+1)) {
31.155 - try {
31.156 - final Document doc = reader.document(docNum, new FieldSelector() {
31.157 - public FieldSelectorResult accept(String string) {
31.158 - return "encoded".equals(string) || "path".equals(string) ? FieldSelectorResult.LOAD : FieldSelectorResult.NO_LOAD;
31.159 - }
31.160 - });
31.161 -
31.162 - ByteArrayInputStream in = new ByteArrayInputStream(CompressionTools.decompress(doc.getField("encoded").getBinaryValue()));
31.163 -
31.164 - try {
31.165 - Map<String, Integer> freqs;
31.166 - boolean matches;
31.167 -
31.168 - if (withFrequencies) {
31.169 - freqs = BulkSearch.getDefault().matchesWithFrequencies(in, pattern);
31.170 - matches = !freqs.isEmpty();
31.171 - } else {
31.172 - freqs = null;
31.173 - matches = BulkSearch.getDefault().matches(in, pattern);
31.174 - }
31.175 -
31.176 - if (matches) {
31.177 - result.put(doc.getField("path").stringValue(), freqs);
31.178 - continue;
31.179 - }
31.180 - } finally {
31.181 - in.close();
31.182 - }
31.183 - } catch (DataFormatException ex) {
31.184 - throw new IOException(ex);
31.185 - }
31.186 - }
31.187 -
31.188 - return result;
31.189 - } finally {
31.190 - //TODO: might be better to cache the index/reader(s)
31.191 - reader.close();
31.192 - }
31.193 - }
31.194 -
31.195 - private Query query(BulkPattern pattern) throws ParseException {
31.196 - BooleanQuery result = new BooleanQuery();
31.197 -
31.198 - for (int cntr = 0; cntr < pattern.getIdentifiers().size(); cntr++) {
31.199 - assert !pattern.getRequiredContent().get(cntr).isEmpty();
31.200 -
31.201 - BooleanQuery emb = new BooleanQuery();
31.202 -
31.203 - for (List<String> c : pattern.getRequiredContent().get(cntr)) {
31.204 - if (c.isEmpty()) continue;
31.205 -
31.206 - PhraseQuery pq = new PhraseQuery();
31.207 -
31.208 - for (String s : c) {
31.209 - pq.add(new Term("content", s));
31.210 - }
31.211 -
31.212 - emb.add(pq, BooleanClause.Occur.MUST);
31.213 - }
31.214 -
31.215 - AdditionalQueryConstraints additionalConstraints = pattern.getAdditionalConstraints().get(cntr);
31.216 -
31.217 - if (additionalConstraints != null && !additionalConstraints.requiredErasedTypes.isEmpty()) {
31.218 - BooleanQuery constraintsQuery = new BooleanQuery();
31.219 -
31.220 - constraintsQuery.add(new TermQuery(new Term("attributed", "false")), BooleanClause.Occur.SHOULD);
31.221 -
31.222 - BooleanQuery constr = new BooleanQuery();
31.223 -
31.224 - for (String tc : additionalConstraints.requiredErasedTypes) {
31.225 - constr.add(new TermQuery(new Term("erasedTypes", tc)), BooleanClause.Occur.MUST);
31.226 - }
31.227 -
31.228 - constraintsQuery.add(constr, BooleanClause.Occur.SHOULD);
31.229 - emb.add(constraintsQuery, BooleanClause.Occur.MUST);
31.230 - }
31.231 -
31.232 - result.add(emb, BooleanClause.Occur.SHOULD);
31.233 - }
31.234 -
31.235 - return result;
31.236 - }
31.237 -
31.238 - public CharSequence getSourceCode(String relativePath) {
31.239 - try {
31.240 - IndexReader reader = createReader();
31.241 -
31.242 - if (reader == null) {
31.243 - return "";
31.244 - }
31.245 -
31.246 - Searcher s = new IndexSearcher(reader);
31.247 - TopDocs topDocs = s.search(new TermQuery(new Term("path", relativePath)), 1);
31.248 -
31.249 - if (topDocs.totalHits < 1) return "";
31.250 -
31.251 - Document doc = s.doc(topDocs.scoreDocs[0].doc, new FieldSelector() {
31.252 - public FieldSelectorResult accept(String string) {
31.253 - return "sourceCode".equals(string) ? FieldSelectorResult.LOAD : FieldSelectorResult.NO_LOAD;
31.254 - }
31.255 - });
31.256 -
31.257 - return CompressionTools.decompressString(doc.getField("sourceCode").getBinaryValue()).replaceAll("\r\n", "\n")/*XXX*/;
31.258 - } catch (DataFormatException ex) {
31.259 - Exceptions.printStackTrace(ex);
31.260 - return "";
31.261 - } catch (IOException ex) {
31.262 - Exceptions.printStackTrace(ex);
31.263 - return "";
31.264 - }
31.265 - }
31.266 -
31.267 - public abstract @NonNull IndexInfo getIndexInfo();
31.268 - protected abstract void storeIndexInfo(@NonNull IndexInfo info) throws IOException;
31.269 -
31.270 - private final class IndexWriterImpl extends IndexWriter {
31.271 -
31.272 - private final org.apache.lucene.index.IndexWriter luceneWriter;
31.273 - private final IndexInfo info;
31.274 -
31.275 - public IndexWriterImpl() throws IOException {
31.276 - luceneWriter = createWriter();
31.277 -
31.278 - info = getIndexInfo();
31.279 - }
31.280 -
31.281 - @Override
31.282 - public void record(URL source, final CompilationUnitTree cut, final @NullAllowed AttributionWrapper attributed) throws IOException {
31.283 - String relative = source.getPath().substring(stripLength);
31.284 - ByteArrayOutputStream out = null;
31.285 - EncodingContext ec = null;
31.286 -
31.287 - try {
31.288 - out = new ByteArrayOutputStream();
31.289 -
31.290 - ec = new EncodingContext(out, false);
31.291 -
31.292 - BulkSearch.getDefault().encode(cut, ec);
31.293 -
31.294 - luceneWriter.deleteDocuments(new Term("path", relative));
31.295 -
31.296 - Document doc = new Document();
31.297 -
31.298 - doc.add(new Field("content", new TokenStreamImpl(ec.getContent())));
31.299 - out.close();
31.300 - doc.add(new Field("encoded", CompressionTools.compress(out.toByteArray()), Field.Store.YES));
31.301 - if (storeFullSourceCode) {
31.302 - doc.add(new Field("sourceCode", CompressionTools.compressString(cut.getSourceFile().getCharContent(false).toString()), Field.Store.YES));
31.303 - }
31.304 - doc.add(new Field("path", relative, Field.Store.YES, Field.Index.NOT_ANALYZED));
31.305 -
31.306 - if (attributed != null) {
31.307 - final Set<String> erased = new HashSet<String>();
31.308 -
31.309 - new TreePathScanner<Void, Void>() {
31.310 - @Override
31.311 - public Void scan(Tree tree, Void p) {
31.312 - if (tree != null) {
31.313 - TreePath tp = new TreePath(getCurrentPath(), tree);
31.314 - TypeMirror type = attributed.trees.getTypeMirror(tp);
31.315 -
31.316 - if (type != null) {
31.317 - if (type.getKind() == TypeKind.ARRAY) {
31.318 - erased.add(attributed.types.erasure(type).toString());
31.319 - type = ((ArrayType) type).getComponentType();
31.320 - }
31.321 -
31.322 - if (type.getKind().isPrimitive() || type.getKind() == TypeKind.DECLARED) {
31.323 - addErasedTypeAndSuperTypes(attributed, erased, type);
31.324 - }
31.325 - }
31.326 -
31.327 - //bounds for type variables!!!
31.328 - }
31.329 - return super.scan(tree, p);
31.330 - }
31.331 - }.scan(cut, null);
31.332 -
31.333 - doc.add(new Field("attributed", "true", Field.Store.YES, Field.Index.NOT_ANALYZED));
31.334 - doc.add(new Field("erasedTypes", new TokenStreamImpl(erased)));
31.335 - } else {
31.336 - doc.add(new Field("attributed", "false", Field.Store.YES, Field.Index.NOT_ANALYZED));
31.337 - }
31.338 - luceneWriter.addDocument(doc);
31.339 - } catch (ThreadDeath td) {
31.340 - throw td;
31.341 - } catch (Throwable t) {
31.342 - Logger.getLogger(FileBasedIndex.class.getName()).log(Level.WARNING, null, t);
31.343 - } finally {
31.344 - if (out != null) {
31.345 - out.close();
31.346 - }
31.347 - }
31.348 - }
31.349 -
31.350 - public void remove(String relativePath) throws IOException {
31.351 - luceneWriter.deleteDocuments(new Term("path", relativePath));
31.352 - }
31.353 -
31.354 - public void clear() throws IOException {
31.355 - luceneWriter.deleteAll();
31.356 - }
31.357 -
31.358 - public void close() throws IOException {
31.359 - info.majorVersion = MAJOR_VERSION;
31.360 - info.minorVersion = MINOR_VERSION;
31.361 - info.totalFiles = luceneWriter.numDocs();
31.362 - info.lastUpdate = System.currentTimeMillis();
31.363 - luceneWriter.optimize();
31.364 - luceneWriter.close();
31.365 - storeIndexInfo(info);
31.366 - }
31.367 - }
31.368 -
31.369 - private static void addErasedTypeAndSuperTypes(AttributionWrapper attributed, Set<String> types, TypeMirror type) {
31.370 - if (type.getKind() == TypeKind.DECLARED) {
31.371 - if (types.add(attributed.types.erasure(type).toString())) {
31.372 - for (TypeMirror sup : attributed.types.directSupertypes(type)) {
31.373 - addErasedTypeAndSuperTypes(attributed, types, sup);
31.374 - }
31.375 - }
31.376 - } else if (type.getKind().isPrimitive()) {
31.377 - types.add(type.toString());
31.378 - }
31.379 - }
31.380 -
31.381 - public static final class TokenStreamImpl extends TokenStream {
31.382 -
31.383 - private final Iterator<? extends String> tokens;
31.384 - private final TermAttribute termAtt;
31.385 -
31.386 - public TokenStreamImpl(Iterable<? extends String> tokens) {
31.387 - this.tokens = tokens != null ? tokens.iterator() : /*???*/Collections.<String>emptyList().iterator();
31.388 - this.termAtt = addAttribute(TermAttribute.class);
31.389 - }
31.390 -
31.391 - @Override
31.392 - public boolean incrementToken() throws IOException {
31.393 - if (!tokens.hasNext())
31.394 - return false;
31.395 -
31.396 - String t = tokens.next();
31.397 -
31.398 - termAtt.setTermBuffer(t);
31.399 -
31.400 - return true;
31.401 - }
31.402 - }
31.403 -
31.404 - public static class BitSetCollector extends Collector {
31.405 -
31.406 - private int docBase;
31.407 - public final BitSet bits;
31.408 -
31.409 - public BitSetCollector(final BitSet bitSet) {
31.410 - assert bitSet != null;
31.411 - bits = bitSet;
31.412 - }
31.413 -
31.414 - // ignore scorer
31.415 - public void setScorer(Scorer scorer) {
31.416 - }
31.417 -
31.418 - // accept docs out of order (for a BitSet it doesn't matter)
31.419 - public boolean acceptsDocsOutOfOrder() {
31.420 - return true;
31.421 - }
31.422 -
31.423 - public void collect(int doc) {
31.424 - bits.set(doc + docBase);
31.425 - }
31.426 -
31.427 - public void setNextReader(IndexReader reader, int docBase) {
31.428 - this.docBase = docBase;
31.429 - }
31.430 -
31.431 - }
31.432 -
31.433 -}
32.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/indexing/Cache.java Fri Jan 27 13:35:56 2012 +0100
32.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
32.3 @@ -1,217 +0,0 @@
32.4 -/*
32.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
32.6 - *
32.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
32.8 - *
32.9 - * The contents of this file are subject to the terms of either the GNU
32.10 - * General Public License Version 2 only ("GPL") or the Common
32.11 - * Development and Distribution License("CDDL") (collectively, the
32.12 - * "License"). You may not use this file except in compliance with the
32.13 - * License. You can obtain a copy of the License at
32.14 - * http://www.netbeans.org/cddl-gplv2.html
32.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
32.16 - * specific language governing permissions and limitations under the
32.17 - * License. When distributing the software, include this License Header
32.18 - * Notice in each file and include the License file at
32.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
32.20 - * particular file as subject to the "Classpath" exception as provided
32.21 - * by Sun in the GPL Version 2 section of the License file that
32.22 - * accompanied this code. If applicable, add the following below the
32.23 - * License Header, with the fields enclosed by brackets [] replaced by
32.24 - * your own identifying information:
32.25 - * "Portions Copyrighted [year] [name of copyright owner]"
32.26 - *
32.27 - * If you wish your version of this file to be governed by only the CDDL
32.28 - * or only the GPL Version 2, indicate your decision by adding
32.29 - * "[Contributor] elects to include this software in this distribution
32.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
32.31 - * single choice of license, a recipient has the option to distribute
32.32 - * your version of this file under either the CDDL, the GPL Version 2 or
32.33 - * to extend the choice of license to its licensees as provided above.
32.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
32.35 - * Version 2 license, then the option applies only if the new code is
32.36 - * made subject to such option by the copyright holder.
32.37 - *
32.38 - * Contributor(s):
32.39 - *
32.40 - * Portions Copyrighted 1997-2009 Sun Microsystems, Inc.
32.41 - */
32.42 -package org.netbeans.modules.jackpot30.impl.indexing;
32.43 -
32.44 -import java.io.File;
32.45 -import java.io.FileInputStream;
32.46 -import java.io.FileOutputStream;
32.47 -import java.io.IOException;
32.48 -import java.io.InputStream;
32.49 -import java.io.OutputStream;
32.50 -import java.net.URI;
32.51 -import java.net.URISyntaxException;
32.52 -import java.net.URL;
32.53 -import java.util.HashMap;
32.54 -import java.util.LinkedList;
32.55 -import java.util.List;
32.56 -import java.util.Map;
32.57 -import java.util.Map.Entry;
32.58 -import java.util.Properties;
32.59 -import java.util.logging.Level;
32.60 -import java.util.logging.Logger;
32.61 -import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
32.62 -import org.netbeans.modules.parsing.impl.indexing.SPIAccessor;
32.63 -import org.openide.filesystems.FileObject;
32.64 -import org.openide.filesystems.FileUtil;
32.65 -
32.66 -/**
32.67 - *
32.68 - * @author lahvac
32.69 - */
32.70 -public class Cache {
32.71 -
32.72 - private static File standaloneCacheRoot;
32.73 - private static Map<String, Cache> name2Cache = new HashMap<String, Cache>();
32.74 -
32.75 - public static Cache findCache(String indexName, int version) {
32.76 - Cache cache = name2Cache.get(indexName);
32.77 -
32.78 - if (cache == null) {
32.79 - name2Cache.put(indexName, cache = new Cache(indexName, version));
32.80 - }
32.81 -
32.82 - return cache;
32.83 - }
32.84 -
32.85 - private final String name;
32.86 - private final int version;
32.87 -
32.88 - private Cache(String name, int version) {
32.89 - this.name = name;
32.90 - this.version = version;
32.91 - }
32.92 -
32.93 - public File findCacheRoot(URL sourceRoot) throws IOException {
32.94 - try {
32.95 - sourceRoot = sourceRoot.toURI().normalize().toURL();
32.96 - } catch (URISyntaxException ex) {
32.97 - Logger.getLogger(Cache.class.getName()).log(Level.SEVERE, null, ex);
32.98 - }
32.99 - if (standaloneCacheRoot != null) {
32.100 - return getDataFolder(sourceRoot, name, version);
32.101 - } else {
32.102 - return findCacheRootNB(sourceRoot, version);
32.103 - }
32.104 - }
32.105 -
32.106 - private File findCacheRootNB(URL sourceRoot, int version) throws IOException {
32.107 - FileObject indexBaseFolder = CacheFolder.getDataFolder(sourceRoot);
32.108 - String path = SPIAccessor.getInstance().getIndexerPath(name, version);
32.109 - FileObject indexFolder = FileUtil.createFolder(indexBaseFolder, path);
32.110 - return FileUtil.toFile(indexFolder);
32.111 - }
32.112 -
32.113 - public static void setStandaloneCacheRoot(File standaloneCacheRoot) {
32.114 - Cache.standaloneCacheRoot = standaloneCacheRoot;
32.115 - segments = null;
32.116 - lastSegmentsTimeStamp = -1;
32.117 - invertedSegments = null;
32.118 - index = 0;
32.119 - }
32.120 -
32.121 -
32.122 - private static Properties segments;
32.123 - private static long lastSegmentsTimeStamp = -1;
32.124 - private static Map<String, String> invertedSegments;
32.125 - private static int index = 0;
32.126 -
32.127 - private static final String SEGMENTS_FILE = "segments"; //NOI18N
32.128 - private static final String SLICE_PREFIX = "s"; //NOI18N
32.129 -
32.130 - private static void loadSegments () throws IOException {
32.131 - final File folder = standaloneCacheRoot;
32.132 - assert folder != null;
32.133 - final File segmentsFile = new File(folder, SEGMENTS_FILE);
32.134 -
32.135 - if (lastSegmentsTimeStamp != segmentsFile.lastModified()) {
32.136 - lastSegmentsTimeStamp = segmentsFile.lastModified();
32.137 - segments = null;
32.138 - lastSegmentsTimeStamp = -1;
32.139 - invertedSegments = null;
32.140 - index = 0;
32.141 - }
32.142 -
32.143 - if (segments == null) {
32.144 - segments = new Properties ();
32.145 - invertedSegments = new HashMap<String,String> ();
32.146 - if (segmentsFile.canRead()) {
32.147 - final InputStream in = new FileInputStream(segmentsFile);
32.148 - try {
32.149 - segments.load (in);
32.150 - } finally {
32.151 - in.close();
32.152 - }
32.153 - }
32.154 - for (Entry<Object, Object> entry : segments.entrySet()) {
32.155 - String segment = (String) entry.getKey();
32.156 - String root = (String) entry.getValue();
32.157 - invertedSegments.put(root,segment);
32.158 - try {
32.159 - index = Math.max (index,Integer.parseInt(segment.substring(SLICE_PREFIX.length())));
32.160 - } catch (NumberFormatException nfe) {
32.161 - throw new IllegalStateException(nfe); //TODO: maybe just log the exception?
32.162 - }
32.163 - }
32.164 - }
32.165 - }
32.166 -
32.167 - public static synchronized Iterable<? extends String> knownSourceRoots() throws IOException {
32.168 - loadSegments();
32.169 -
32.170 - List<String> known = new LinkedList<String>();
32.171 -
32.172 - for (String segment : segments.stringPropertyNames()) {
32.173 - known.add(segment);
32.174 - }
32.175 -
32.176 - return known;
32.177 - }
32.178 -
32.179 - public static synchronized File sourceRootForKey(String segment) throws IOException {
32.180 - loadSegments();
32.181 -
32.182 - try {
32.183 - return new File(new File(new URI(segments.getProperty(segment))).getAbsolutePath());
32.184 - } catch (URISyntaxException ex) {
32.185 - throw new IOException(ex);
32.186 - }
32.187 - }
32.188 -
32.189 -
32.190 - private static void storeSegments () throws IOException {
32.191 - final File folder = standaloneCacheRoot;
32.192 - assert folder != null;
32.193 - final File segmentsFile = new File(folder, SEGMENTS_FILE);
32.194 - segmentsFile.getParentFile().mkdirs();
32.195 - final OutputStream out = new FileOutputStream(segmentsFile);
32.196 - try {
32.197 - segments.store(out,null);
32.198 - } finally {
32.199 - out.close();
32.200 - }
32.201 - }
32.202 -
32.203 - private static synchronized File getDataFolder (final URL root, String name, int version) throws IOException {
32.204 - loadSegments ();
32.205 - final String rootName = root.toExternalForm();
32.206 - String slice = invertedSegments.get (rootName);
32.207 - if ( slice == null) {
32.208 - slice = SLICE_PREFIX + (++index);
32.209 - while (segments.getProperty(slice) != null) {
32.210 - slice = SLICE_PREFIX + (++index);
32.211 - }
32.212 - segments.put (slice,rootName);
32.213 - invertedSegments.put(rootName, slice);
32.214 - storeSegments ();
32.215 - }
32.216 - final File folder = standaloneCacheRoot;
32.217 - return new File(new File(new File(folder, slice), name), Integer.toString(version));
32.218 - }
32.219 -
32.220 -}
33.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/indexing/CustomIndexerImpl.java Fri Jan 27 13:35:56 2012 +0100
33.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
33.3 @@ -1,177 +0,0 @@
33.4 -/*
33.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33.6 - *
33.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
33.8 - *
33.9 - * The contents of this file are subject to the terms of either the GNU
33.10 - * General Public License Version 2 only ("GPL") or the Common
33.11 - * Development and Distribution License("CDDL") (collectively, the
33.12 - * "License"). You may not use this file except in compliance with the
33.13 - * License. You can obtain a copy of the License at
33.14 - * http://www.netbeans.org/cddl-gplv2.html
33.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
33.16 - * specific language governing permissions and limitations under the
33.17 - * License. When distributing the software, include this License Header
33.18 - * Notice in each file and include the License file at
33.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
33.20 - * particular file as subject to the "Classpath" exception as provided
33.21 - * by Sun in the GPL Version 2 section of the License file that
33.22 - * accompanied this code. If applicable, add the following below the
33.23 - * License Header, with the fields enclosed by brackets [] replaced by
33.24 - * your own identifying information:
33.25 - * "Portions Copyrighted [year] [name of copyright owner]"
33.26 - *
33.27 - * If you wish your version of this file to be governed by only the CDDL
33.28 - * or only the GPL Version 2, indicate your decision by adding
33.29 - * "[Contributor] elects to include this software in this distribution
33.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
33.31 - * single choice of license, a recipient has the option to distribute
33.32 - * your version of this file under either the CDDL, the GPL Version 2 or
33.33 - * to extend the choice of license to its licensees as provided above.
33.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
33.35 - * Version 2 license, then the option applies only if the new code is
33.36 - * made subject to such option by the copyright holder.
33.37 - *
33.38 - * Contributor(s):
33.39 - *
33.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
33.41 - */
33.42 -
33.43 -package org.netbeans.modules.jackpot30.impl.indexing;
33.44 -
33.45 -import java.io.IOException;
33.46 -import java.util.Collection;
33.47 -import java.util.Collections;
33.48 -import java.util.LinkedList;
33.49 -import org.netbeans.api.java.source.ClasspathInfo;
33.50 -import org.netbeans.api.java.source.CompilationController;
33.51 -import org.netbeans.api.java.source.JavaSource;
33.52 -import org.netbeans.api.java.source.JavaSource.Phase;
33.53 -import org.netbeans.api.java.source.Task;
33.54 -import org.netbeans.modules.jackpot30.impl.indexing.Index.AttributionWrapper;
33.55 -import org.netbeans.modules.jackpot30.impl.indexing.Index.IndexWriter;
33.56 -import org.netbeans.modules.parsing.spi.indexing.Context;
33.57 -import org.netbeans.modules.parsing.spi.indexing.CustomIndexer;
33.58 -import org.netbeans.modules.parsing.spi.indexing.CustomIndexerFactory;
33.59 -import org.netbeans.modules.parsing.spi.indexing.Indexable;
33.60 -import org.openide.filesystems.FileObject;
33.61 -import org.openide.filesystems.URLMapper;
33.62 -import org.openide.util.Exceptions;
33.63 -
33.64 -/**
33.65 - *
33.66 - * @author lahvac
33.67 - */
33.68 -public class CustomIndexerImpl extends CustomIndexer {
33.69 -
33.70 - @Override
33.71 - protected void index(Iterable<? extends Indexable> files, Context context) {
33.72 - Collection<FileObject> toIndex = new LinkedList<FileObject>(); //XXX: better would be to use File
33.73 -
33.74 - for (Indexable i : files) {
33.75 - FileObject f = URLMapper.findFileObject(i.getURL());
33.76 -
33.77 - if (f != null) {
33.78 - toIndex.add(f);
33.79 - }
33.80 - }
33.81 -
33.82 - if (toIndex.isEmpty()) {
33.83 - return ;
33.84 - }
33.85 -
33.86 - try {
33.87 - doIndex(context.getRoot(), toIndex, Collections.<String>emptyList(), FileBasedIndex.get(context.getRootURI()));
33.88 - } catch (IOException ex) {
33.89 - Exceptions.printStackTrace(ex);
33.90 - }
33.91 - }
33.92 -
33.93 - public static void doIndex(FileObject root, Collection<? extends FileObject> toIndex, Iterable<? extends String> deleted, Index index) {
33.94 - if (toIndex.isEmpty() && !deleted.iterator().hasNext()) {
33.95 - return ;
33.96 - }
33.97 -
33.98 - final IndexWriter[] w = new IndexWriter[1];
33.99 -
33.100 - try {
33.101 - ClasspathInfo cpInfo = ClasspathInfo.create(root);
33.102 - w[0] = index.openForWriting();
33.103 -
33.104 - for (String path : deleted) {
33.105 - w[0].remove(path);
33.106 - }
33.107 -
33.108 - final boolean attributed = Boolean.getBoolean(CustomIndexerImpl.class.getName() + "-attributed");
33.109 -
33.110 - if (!toIndex.isEmpty()) {
33.111 - JavaSource.create(cpInfo, toIndex).runUserActionTask(new Task<CompilationController>() {
33.112 - public void run(final CompilationController cc) throws Exception {
33.113 - if (attributed) {
33.114 - if (cc.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0)
33.115 - return ;
33.116 - } else {
33.117 - if (cc.toPhase(Phase.PARSED).compareTo(Phase.PARSED) < 0)
33.118 - return ;
33.119 - }
33.120 -
33.121 - w[0].record(cc.getFileObject().getURL(), cc.getCompilationUnit(), attributed ? new AttributionWrapper(cc) : null);
33.122 - }
33.123 - }, true);
33.124 - }
33.125 - } catch (IOException ex) {
33.126 - Exceptions.printStackTrace(ex);
33.127 - } finally {
33.128 - if (w[0] != null) {
33.129 - try {
33.130 - w[0].close();
33.131 - } catch (IOException ex) {
33.132 - Exceptions.printStackTrace(ex);
33.133 - }
33.134 - }
33.135 - }
33.136 - }
33.137 -
33.138 - public static final class CustomIndexerFactoryImpl extends CustomIndexerFactory {
33.139 -
33.140 - @Override
33.141 - public CustomIndexer createIndexer() {
33.142 - return new CustomIndexerImpl();
33.143 - }
33.144 -
33.145 - @Override
33.146 - public void filesDeleted(Iterable<? extends Indexable> deleted, Context context) {
33.147 - Collection<String> deletedPaths = new LinkedList<String>();
33.148 -
33.149 - for (Indexable i : deleted) {
33.150 - deletedPaths.add(i.getRelativePath());
33.151 -
33.152 - }
33.153 - try {
33.154 - doIndex(context.getRoot(), Collections.<FileObject>emptyList(), deletedPaths, FileBasedIndex.get(context.getRootURI()));
33.155 - } catch (IOException ex) {
33.156 - Exceptions.printStackTrace(ex);
33.157 - }
33.158 - }
33.159 -
33.160 - @Override
33.161 - public void filesDirty(Iterable<? extends Indexable> dirty, Context context) {}
33.162 -
33.163 - @Override
33.164 - public String getIndexerName() {
33.165 - return FileBasedIndex.NAME;
33.166 - }
33.167 -
33.168 - @Override
33.169 - public boolean supportsEmbeddedIndexers() {
33.170 - return false;
33.171 - }
33.172 -
33.173 - @Override
33.174 - public int getIndexVersion() {
33.175 - return FileBasedIndex.VERSION;
33.176 - }
33.177 -
33.178 - }
33.179 -
33.180 -}
34.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/indexing/FileBasedIndex.java Fri Jan 27 13:35:56 2012 +0100
34.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
34.3 @@ -1,176 +0,0 @@
34.4 -/*
34.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
34.6 - *
34.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
34.8 - *
34.9 - * The contents of this file are subject to the terms of either the GNU
34.10 - * General Public License Version 2 only ("GPL") or the Common
34.11 - * Development and Distribution License("CDDL") (collectively, the
34.12 - * "License"). You may not use this file except in compliance with the
34.13 - * License. You can obtain a copy of the License at
34.14 - * http://www.netbeans.org/cddl-gplv2.html
34.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
34.16 - * specific language governing permissions and limitations under the
34.17 - * License. When distributing the software, include this License Header
34.18 - * Notice in each file and include the License file at
34.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
34.20 - * particular file as subject to the "Classpath" exception as provided
34.21 - * by Sun in the GPL Version 2 section of the License file that
34.22 - * accompanied this code. If applicable, add the following below the
34.23 - * License Header, with the fields enclosed by brackets [] replaced by
34.24 - * your own identifying information:
34.25 - * "Portions Copyrighted [year] [name of copyright owner]"
34.26 - *
34.27 - * If you wish your version of this file to be governed by only the CDDL
34.28 - * or only the GPL Version 2, indicate your decision by adding
34.29 - * "[Contributor] elects to include this software in this distribution
34.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
34.31 - * single choice of license, a recipient has the option to distribute
34.32 - * your version of this file under either the CDDL, the GPL Version 2 or
34.33 - * to extend the choice of license to its licensees as provided above.
34.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
34.35 - * Version 2 license, then the option applies only if the new code is
34.36 - * made subject to such option by the copyright holder.
34.37 - *
34.38 - * Contributor(s):
34.39 - *
34.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
34.41 - */
34.42 -
34.43 -package org.netbeans.modules.jackpot30.impl.indexing;
34.44 -
34.45 -import java.io.File;
34.46 -import java.io.IOException;
34.47 -import java.io.InputStream;
34.48 -import java.io.InputStreamReader;
34.49 -import java.io.Reader;
34.50 -import java.net.URI;
34.51 -import java.net.URISyntaxException;
34.52 -import java.net.URL;
34.53 -import org.apache.lucene.analysis.Analyzer;
34.54 -import org.apache.lucene.analysis.TokenStream;
34.55 -import org.apache.lucene.index.IndexReader;
34.56 -import org.apache.lucene.index.IndexWriter.MaxFieldLength;
34.57 -import org.apache.lucene.store.FSDirectory;
34.58 -import org.codeviation.pojson.Pojson;
34.59 -import org.netbeans.api.annotations.common.CheckForNull;
34.60 -import org.netbeans.api.annotations.common.NonNull;
34.61 -import org.openide.util.Exceptions;
34.62 -
34.63 -/**
34.64 - *
34.65 - * @author lahvac
34.66 - */
34.67 -public final class FileBasedIndex extends AbstractLuceneIndex {
34.68 -
34.69 - public static Index create(URL sourceRoot, File indexRoot) {
34.70 - return new FileBasedIndex(sourceRoot, indexRoot, false);
34.71 - }
34.72 -
34.73 - public static @CheckForNull Index get(URL sourceRoot) throws IOException {
34.74 - return new FileBasedIndex(sourceRoot, Cache.findCache(FileBasedIndex.NAME, FileBasedIndex.VERSION).findCacheRoot(sourceRoot), false); //XXX: new!
34.75 - }
34.76 -
34.77 - public static @NonNull Index create(URL sourceRoot, boolean storeSources) throws IOException {
34.78 - return new FileBasedIndex(sourceRoot, Cache.findCache(FileBasedIndex.NAME, FileBasedIndex.VERSION).findCacheRoot(sourceRoot), storeSources);
34.79 - }
34.80 -
34.81 - private final URL sourceRoot;
34.82 - private final File cacheRoot;
34.83 -
34.84 - private FileBasedIndex(URL sourceRoot, File cacheRoot, boolean storeSources) {
34.85 - super(sourceRoot.getPath().length(), false, storeSources);
34.86 - this.sourceRoot = sourceRoot;
34.87 - this.cacheRoot = cacheRoot;
34.88 - }
34.89 -
34.90 - public CharSequence getSourceCode(String relativePath) {
34.91 - return getSourceCode(sourceRoot, relativePath);
34.92 - }
34.93 -
34.94 - static CharSequence getSourceCode(URL sourceRoot, String relativePath) {
34.95 - try {
34.96 - URI absolute = sourceRoot.toURI().resolve(relativePath);
34.97 - StringBuilder result = new StringBuilder();
34.98 - InputStream input = null;
34.99 - Reader reader = null;
34.100 -
34.101 - try {
34.102 - input = absolute.toURL().openStream();
34.103 - reader = new InputStreamReader(input); //XXX encoding!!!
34.104 -
34.105 - int read;
34.106 -
34.107 - while ((read = reader.read()) != (-1)) {
34.108 - result.append((char) read);
34.109 - }
34.110 -
34.111 - return result;
34.112 - } finally {
34.113 - if (reader != null) {
34.114 - reader.close();
34.115 - } else {
34.116 - if (input != null) {
34.117 - input.close();
34.118 - }
34.119 - }
34.120 - }
34.121 - } catch (IOException ex) {
34.122 - Exceptions.printStackTrace(ex);
34.123 - return null;
34.124 - } catch (URISyntaxException ex) {
34.125 - Exceptions.printStackTrace(ex);
34.126 - return null;
34.127 - }
34.128 - }
34.129 -
34.130 - public @NonNull IndexInfo getIndexInfo() {
34.131 - File infoFile = new File(cacheRoot, "info");
34.132 -
34.133 - if (infoFile.exists()) {
34.134 - try {
34.135 - return Pojson.load(IndexInfo.class, infoFile);
34.136 - } catch (IOException ex) {
34.137 - Exceptions.printStackTrace(ex);
34.138 - }
34.139 - }
34.140 -
34.141 - return IndexInfo.empty();
34.142 - }
34.143 -
34.144 - @Override
34.145 - protected IndexReader createReader() throws IOException {
34.146 - File dir = new File(cacheRoot, "fulltext");
34.147 -
34.148 - if (dir.listFiles() == null || dir.listFiles().length == 0) {
34.149 - return null;
34.150 - }
34.151 -
34.152 - return IndexReader.open(FSDirectory.open(dir), true);
34.153 - }
34.154 -
34.155 - @Override
34.156 - protected org.apache.lucene.index.IndexWriter createWriter() throws IOException {
34.157 - return new org.apache.lucene.index.IndexWriter(FSDirectory.open(new File(cacheRoot, "fulltext")), new NoAnalyzer(), MaxFieldLength.UNLIMITED);
34.158 - }
34.159 -
34.160 - @Override
34.161 - protected void storeIndexInfo(IndexInfo info) throws IOException {
34.162 - File infoFile = new File(cacheRoot, "info");
34.163 -
34.164 - Pojson.save(info, infoFile);
34.165 - }
34.166 -
34.167 - public static final class NoAnalyzer extends Analyzer {
34.168 -
34.169 - @Override
34.170 - public TokenStream tokenStream(String string, Reader reader) {
34.171 - throw new UnsupportedOperationException("Should not be called");
34.172 - }
34.173 -
34.174 - }
34.175 -
34.176 - public static final String NAME = "jackpot30"; //NOI18N
34.177 - public static final int VERSION = AbstractLuceneIndex.MAJOR_VERSION * 1000 + AbstractLuceneIndex.MINOR_VERSION;
34.178 -
34.179 -}
35.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/indexing/Index.java Fri Jan 27 13:35:56 2012 +0100
35.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
35.3 @@ -1,168 +0,0 @@
35.4 -/*
35.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
35.6 - *
35.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
35.8 - *
35.9 - * The contents of this file are subject to the terms of either the GNU
35.10 - * General Public License Version 2 only ("GPL") or the Common
35.11 - * Development and Distribution License("CDDL") (collectively, the
35.12 - * "License"). You may not use this file except in compliance with the
35.13 - * License. You can obtain a copy of the License at
35.14 - * http://www.netbeans.org/cddl-gplv2.html
35.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
35.16 - * specific language governing permissions and limitations under the
35.17 - * License. When distributing the software, include this License Header
35.18 - * Notice in each file and include the License file at
35.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
35.20 - * particular file as subject to the "Classpath" exception as provided
35.21 - * by Sun in the GPL Version 2 section of the License file that
35.22 - * accompanied this code. If applicable, add the following below the
35.23 - * License Header, with the fields enclosed by brackets [] replaced by
35.24 - * your own identifying information:
35.25 - * "Portions Copyrighted [year] [name of copyright owner]"
35.26 - *
35.27 - * If you wish your version of this file to be governed by only the CDDL
35.28 - * or only the GPL Version 2, indicate your decision by adding
35.29 - * "[Contributor] elects to include this software in this distribution
35.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
35.31 - * single choice of license, a recipient has the option to distribute
35.32 - * your version of this file under either the CDDL, the GPL Version 2 or
35.33 - * to extend the choice of license to its licensees as provided above.
35.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
35.35 - * Version 2 license, then the option applies only if the new code is
35.36 - * made subject to such option by the copyright holder.
35.37 - *
35.38 - * Contributor(s):
35.39 - *
35.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
35.41 - */
35.42 -
35.43 -package org.netbeans.modules.jackpot30.impl.indexing;
35.44 -
35.45 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch.BulkPattern;
35.46 -import java.util.Map;
35.47 -import com.sun.source.util.Trees;
35.48 -import javax.lang.model.util.Types;
35.49 -import org.netbeans.modules.jackpot30.remoting.api.WebUtilities;
35.50 -import java.util.ArrayList;
35.51 -import com.sun.source.tree.CompilationUnitTree;
35.52 -import java.io.IOException;
35.53 -import java.net.URI;
35.54 -import java.net.URISyntaxException;
35.55 -import java.net.URL;
35.56 -import java.util.Collection;
35.57 -import java.util.Collections;
35.58 -import org.codeviation.pojson.Pojson;
35.59 -import org.netbeans.api.annotations.common.NonNull;
35.60 -import org.netbeans.api.annotations.common.NullAllowed;
35.61 -import org.netbeans.api.java.source.CompilationInfo;
35.62 -import org.openide.util.Exceptions;
35.63 -import static org.netbeans.modules.jackpot30.remoting.api.WebUtilities.escapeForQuery;
35.64 -
35.65 -/**
35.66 - *
35.67 - * @author lahvac
35.68 - */
35.69 -public abstract class Index {
35.70 -
35.71 - protected Index() {}
35.72 -
35.73 - public static Index createWithRemoteIndex(final URL sourceRoot, final String indexURL, final String subIndex) {
35.74 - return new Index() {
35.75 - @Override
35.76 - public IndexWriter openForWriting() throws IOException {
35.77 - throw new UnsupportedOperationException();
35.78 - }
35.79 - @Override
35.80 - public Collection<? extends String> findCandidates(BulkPattern pattern) throws IOException {
35.81 - try {
35.82 - StringBuilder patterns = new StringBuilder();
35.83 -
35.84 - for (String p : pattern.getPatterns()) {
35.85 - patterns.append(p);
35.86 - patterns.append(";;");
35.87 - }
35.88 -
35.89 - URI u = new URI(indexURL + "?path=" + escapeForQuery(subIndex) + "&pattern=" + escapeForQuery(patterns.toString()));
35.90 -
35.91 - return new ArrayList<String>(WebUtilities.requestStringArrayResponse(u));
35.92 - } catch (URISyntaxException ex) {
35.93 - //XXX: better handling?
35.94 - Exceptions.printStackTrace(ex);
35.95 - return Collections.emptyList();
35.96 - }
35.97 - }
35.98 - @Override
35.99 - public Map<String, Map<String, Integer>> findCandidatesWithFrequencies(BulkPattern pattern) throws IOException {
35.100 - throw new UnsupportedOperationException("Not supported yet.");
35.101 - }
35.102 - @Override
35.103 - public @NonNull IndexInfo getIndexInfo() {
35.104 - IndexInfo result = IndexInfo.empty();
35.105 -
35.106 - try {
35.107 - URI u = new URI(indexURL + "/info");
35.108 -
35.109 - Pojson.update(result, WebUtilities.requestStringResponse(u));
35.110 - } catch (URISyntaxException ex) {
35.111 - //XXX: better handling?
35.112 - Exceptions.printStackTrace(ex);
35.113 - }
35.114 -
35.115 - return result;
35.116 - }
35.117 - @Override
35.118 - public CharSequence getSourceCode(String relativePath) {
35.119 - try {
35.120 - URI u = new URI(indexURL + "/cat?path=" + escapeForQuery(subIndex) + "&relative=" + escapeForQuery(relativePath));
35.121 -
35.122 - return WebUtilities.requestStringResponse(u);
35.123 - } catch (URISyntaxException ex) {
35.124 - //XXX: better handling?
35.125 - Exceptions.printStackTrace(ex);
35.126 - return "";
35.127 - }
35.128 - }
35.129 - };
35.130 - }
35.131 -
35.132 - public abstract IndexWriter openForWriting() throws IOException;
35.133 -
35.134 - public abstract Collection<? extends String> findCandidates(BulkPattern pattern) throws IOException;
35.135 - public abstract Map<String, Map<String, Integer>> findCandidatesWithFrequencies(BulkPattern pattern) throws IOException;
35.136 -
35.137 - public abstract CharSequence getSourceCode(String relativePath);
35.138 -
35.139 - public abstract @NonNull IndexInfo getIndexInfo();
35.140 -
35.141 - public abstract static class IndexWriter {
35.142 -
35.143 - protected IndexWriter() throws IOException {}
35.144 -
35.145 - public abstract void record(URL source, final CompilationUnitTree cut, @NullAllowed AttributionWrapper attributed) throws IOException;
35.146 -
35.147 - public abstract void remove(String relativePath) throws IOException;
35.148 -
35.149 - public abstract void clear() throws IOException;
35.150 -
35.151 - public abstract void close() throws IOException;
35.152 -
35.153 - }
35.154 -
35.155 - public static final class AttributionWrapper {
35.156 - public final Trees trees;
35.157 - public final Types types;
35.158 -
35.159 - public AttributionWrapper(CompilationInfo info) {
35.160 - trees = info.getTrees();
35.161 - types = info.getTypes();
35.162 - }
35.163 -
35.164 - public AttributionWrapper(Trees trees, Types types) {
35.165 - this.trees = trees;
35.166 - this.types = types;
35.167 - }
35.168 -
35.169 - }
35.170 -
35.171 -}
36.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/indexing/IndexInfo.java Fri Jan 27 13:35:56 2012 +0100
36.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
36.3 @@ -1,67 +0,0 @@
36.4 -/*
36.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
36.6 - *
36.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
36.8 - *
36.9 - * The contents of this file are subject to the terms of either the GNU
36.10 - * General Public License Version 2 only ("GPL") or the Common
36.11 - * Development and Distribution License("CDDL") (collectively, the
36.12 - * "License"). You may not use this file except in compliance with the
36.13 - * License. You can obtain a copy of the License at
36.14 - * http://www.netbeans.org/cddl-gplv2.html
36.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
36.16 - * specific language governing permissions and limitations under the
36.17 - * License. When distributing the software, include this License Header
36.18 - * Notice in each file and include the License file at
36.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
36.20 - * particular file as subject to the "Classpath" exception as provided
36.21 - * by Sun in the GPL Version 2 section of the License file that
36.22 - * accompanied this code. If applicable, add the following below the
36.23 - * License Header, with the fields enclosed by brackets [] replaced by
36.24 - * your own identifying information:
36.25 - * "Portions Copyrighted [year] [name of copyright owner]"
36.26 - *
36.27 - * If you wish your version of this file to be governed by only the CDDL
36.28 - * or only the GPL Version 2, indicate your decision by adding
36.29 - * "[Contributor] elects to include this software in this distribution
36.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
36.31 - * single choice of license, a recipient has the option to distribute
36.32 - * your version of this file under either the CDDL, the GPL Version 2 or
36.33 - * to extend the choice of license to its licensees as provided above.
36.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
36.35 - * Version 2 license, then the option applies only if the new code is
36.36 - * made subject to such option by the copyright holder.
36.37 - *
36.38 - * Contributor(s):
36.39 - *
36.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
36.41 - */
36.42 -
36.43 -package org.netbeans.modules.jackpot30.impl.indexing;
36.44 -
36.45 -/**
36.46 - *
36.47 - * @author lahvac
36.48 - */
36.49 -public class IndexInfo {
36.50 -
36.51 - public int majorVersion;
36.52 - public int minorVersion;
36.53 - public int totalFiles;
36.54 - public long lastUpdate;
36.55 - public String sourceLocation;
36.56 - public String versionControlTip;
36.57 - public String displayName;
36.58 -
36.59 - public static IndexInfo empty() {
36.60 - IndexInfo info = new IndexInfo();
36.61 -
36.62 - info.majorVersion = 1;
36.63 - info.minorVersion = 0;
36.64 - info.totalFiles = -1;
36.65 - info.lastUpdate = -1;
36.66 -
36.67 - return info;
36.68 - }
36.69 -
36.70 -}
37.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/AbstractApplyHintsRefactoringPlugin.java Fri Jan 27 13:35:56 2012 +0100
37.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
37.3 @@ -1,190 +0,0 @@
37.4 -/*
37.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
37.6 - *
37.7 - * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
37.8 - *
37.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
37.10 - * Other names may be trademarks of their respective owners.
37.11 - *
37.12 - * The contents of this file are subject to the terms of either the GNU
37.13 - * General Public License Version 2 only ("GPL") or the Common
37.14 - * Development and Distribution License("CDDL") (collectively, the
37.15 - * "License"). You may not use this file except in compliance with the
37.16 - * License. You can obtain a copy of the License at
37.17 - * http://www.netbeans.org/cddl-gplv2.html
37.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
37.19 - * specific language governing permissions and limitations under the
37.20 - * License. When distributing the software, include this License Header
37.21 - * Notice in each file and include the License file at
37.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
37.23 - * particular file as subject to the "Classpath" exception as provided
37.24 - * by Oracle in the GPL Version 2 section of the License file that
37.25 - * accompanied this code. If applicable, add the following below the
37.26 - * License Header, with the fields enclosed by brackets [] replaced by
37.27 - * your own identifying information:
37.28 - * "Portions Copyrighted [year] [name of copyright owner]"
37.29 - *
37.30 - * If you wish your version of this file to be governed by only the CDDL
37.31 - * or only the GPL Version 2, indicate your decision by adding
37.32 - * "[Contributor] elects to include this software in this distribution
37.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
37.34 - * single choice of license, a recipient has the option to distribute
37.35 - * your version of this file under either the CDDL, the GPL Version 2 or
37.36 - * to extend the choice of license to its licensees as provided above.
37.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
37.38 - * Version 2 license, then the option applies only if the new code is
37.39 - * made subject to such option by the copyright holder.
37.40 - *
37.41 - * Contributor(s):
37.42 - *
37.43 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
37.44 - */
37.45 -
37.46 -package org.netbeans.modules.jackpot30.impl.refactoring;
37.47 -
37.48 -import java.util.Collection;
37.49 -import java.util.LinkedList;
37.50 -import java.util.List;
37.51 -import java.util.concurrent.atomic.AtomicBoolean;
37.52 -import org.netbeans.api.java.source.CompilationController;
37.53 -import org.netbeans.api.java.source.ModificationResult;
37.54 -import org.netbeans.api.java.source.ModificationResult.Difference;
37.55 -import org.netbeans.modules.java.hints.jackpot.impl.MessageImpl;
37.56 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch;
37.57 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.BatchResult;
37.58 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.Resource;
37.59 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.Scope;
37.60 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchUtilities;
37.61 -import org.netbeans.modules.java.hints.jackpot.impl.batch.ProgressHandleWrapper;
37.62 -import org.netbeans.modules.java.hints.jackpot.impl.batch.ProgressHandleWrapper.ProgressHandleAbstraction;
37.63 -import org.netbeans.modules.java.hints.jackpot.spi.HintContext.MessageKind;
37.64 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
37.65 -import org.netbeans.modules.refactoring.api.AbstractRefactoring;
37.66 -import org.netbeans.modules.refactoring.api.Problem;
37.67 -import org.netbeans.modules.refactoring.java.spi.DiffElement;
37.68 -import org.netbeans.modules.refactoring.spi.ProgressProviderAdapter;
37.69 -import org.netbeans.modules.refactoring.spi.RefactoringElementsBag;
37.70 -import org.netbeans.modules.refactoring.spi.RefactoringPlugin;
37.71 -import org.netbeans.spi.editor.hints.ErrorDescription;
37.72 -import org.openide.filesystems.FileObject;
37.73 -import org.openide.text.PositionBounds;
37.74 -
37.75 -/**
37.76 - *
37.77 - * @author lahvac
37.78 - */
37.79 -public abstract class AbstractApplyHintsRefactoringPlugin extends ProgressProviderAdapter implements RefactoringPlugin, ProgressHandleAbstraction {
37.80 -
37.81 - private final AbstractRefactoring refactoring;
37.82 - protected final AtomicBoolean cancel = new AtomicBoolean();
37.83 -
37.84 - protected AbstractApplyHintsRefactoringPlugin(AbstractRefactoring refactoring) {
37.85 - this.refactoring = refactoring;
37.86 - }
37.87 -
37.88 - public void cancelRequest() {
37.89 - cancel.set(true);
37.90 - }
37.91 -
37.92 - protected final Problem messagesToProblem(Collection<MessageImpl> problems) throws IllegalStateException {
37.93 - Problem current = null;
37.94 -
37.95 - for (MessageImpl problem : problems) {
37.96 - Problem p = new Problem(problem.kind == MessageKind.ERROR, problem.text);
37.97 -
37.98 - if (current != null)
37.99 - p.setNext(current);
37.100 - current = p;
37.101 - }
37.102 -
37.103 - return current;
37.104 - }
37.105 -
37.106 - protected Collection<MessageImpl> performApplyPattern(Iterable<? extends HintDescription> pattern, Scope scope, RefactoringElementsBag refactoringElements) {
37.107 - ProgressHandleWrapper w = new ProgressHandleWrapper(this, 30, 70);
37.108 - BatchResult candidates = BatchSearch.findOccurrences(pattern, scope, w);
37.109 - Collection<MessageImpl> problems = new LinkedList<MessageImpl>(candidates.problems);
37.110 - Collection<? extends ModificationResult> res = BatchUtilities.applyFixes(candidates, w, /*XXX*/new AtomicBoolean(), problems);
37.111 -
37.112 - refactoringElements.registerTransaction(new RetoucheCommit(new LinkedList<ModificationResult>(res)));
37.113 -
37.114 - for (ModificationResult mr : res) {
37.115 - for (FileObject file : mr.getModifiedFileObjects()) {
37.116 - for (Difference d : mr.getDifferences(file)) {
37.117 - refactoringElements.add(refactoring, DiffElement.create(d, file, mr));
37.118 - }
37.119 - }
37.120 - }
37.121 -
37.122 - w.finish();
37.123 -
37.124 - return problems;
37.125 - }
37.126 -
37.127 - protected final void prepareElements(BatchResult candidates, ProgressHandleWrapper w, final RefactoringElementsBag refactoringElements, final boolean verify, List<MessageImpl> problems) {
37.128 - if (verify) {
37.129 - BatchSearch.getVerifiedSpans(candidates, w, new BatchSearch.VerifiedSpansCallBack() {
37.130 - public void groupStarted() {}
37.131 - public boolean spansVerified(CompilationController wc, Resource r, Collection<? extends ErrorDescription> hints) throws Exception {
37.132 - List<PositionBounds> spans = new LinkedList<PositionBounds>();
37.133 -
37.134 - for (ErrorDescription ed : hints) {
37.135 - spans.add(ed.getRange());
37.136 - }
37.137 -
37.138 - refactoringElements.addAll(refactoring, Utilities.createRefactoringElementImplementation(r.getResolvedFile(), spans, verify));
37.139 -
37.140 - return true;
37.141 - }
37.142 - public void groupFinished() {}
37.143 - public void cannotVerifySpan(Resource r) {
37.144 - refactoringElements.addAll(refactoring, Utilities.createRefactoringElementImplementation(r.getResolvedFile(), prepareSpansFor(r), verify));
37.145 - }
37.146 - }, problems, cancel);
37.147 - } else {
37.148 - int[] parts = new int[candidates.getResources().size()];
37.149 - int index = 0;
37.150 -
37.151 - for (Collection<? extends Resource> resources : candidates.getResources()) {
37.152 - parts[index++] = resources.size();
37.153 - }
37.154 -
37.155 - ProgressHandleWrapper inner = w.startNextPartWithEmbedding(parts);
37.156 -
37.157 - for (Collection<? extends Resource> it :candidates.getResources()) {
37.158 - inner.startNextPart(it.size());
37.159 -
37.160 - for (Resource r : it) {
37.161 - refactoringElements.addAll(refactoring, Utilities.createRefactoringElementImplementation(r.getResolvedFile(), prepareSpansFor(r), verify));
37.162 - inner.tick();
37.163 - }
37.164 - }
37.165 - }
37.166 - }
37.167 -
37.168 - private static List<PositionBounds> prepareSpansFor(Resource r) {
37.169 - return Utilities.prepareSpansFor(r.getResolvedFile(), r.getCandidateSpans());
37.170 - }
37.171 -
37.172 - public void start(int totalWork) {
37.173 - fireProgressListenerStart(-1, totalWork);
37.174 - lastWorkDone = 0;
37.175 - }
37.176 -
37.177 - private int lastWorkDone;
37.178 - public void progress(int currentWorkDone) {
37.179 - while (lastWorkDone < currentWorkDone) {
37.180 - fireProgressListenerStep(currentWorkDone);
37.181 - lastWorkDone++;
37.182 - }
37.183 - }
37.184 -
37.185 - public void progress(String message) {
37.186 - //ignored
37.187 - }
37.188 -
37.189 - public void finish() {
37.190 - fireProgressListenerStop();
37.191 - }
37.192 -
37.193 -}
38.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/AddScopePanel.form Fri Jan 27 13:35:56 2012 +0100
38.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
38.3 @@ -1,373 +0,0 @@
38.4 -<?xml version="1.1" encoding="UTF-8" ?>
38.5 -
38.6 -<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
38.7 - <NonVisualComponents>
38.8 - <Component class="javax.swing.ButtonGroup" name="buttonGroup1">
38.9 - </Component>
38.10 - </NonVisualComponents>
38.11 - <Properties>
38.12 - <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
38.13 - <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
38.14 - <EmptyBorder bottom="12" left="12" right="12" top="12"/>
38.15 - </Border>
38.16 - </Property>
38.17 - </Properties>
38.18 - <AuxValues>
38.19 - <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
38.20 - <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
38.21 - <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
38.22 - <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
38.23 - <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
38.24 - <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
38.25 - <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
38.26 - <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
38.27 - <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
38.28 - <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,53,0,0,2,-66"/>
38.29 - </AuxValues>
38.30 -
38.31 - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
38.32 - <SubComponents>
38.33 - <Container class="javax.swing.JPanel" name="folderPanel">
38.34 - <Constraints>
38.35 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
38.36 - <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="1.0" weightY="0.0"/>
38.37 - </Constraint>
38.38 - </Constraints>
38.39 -
38.40 - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
38.41 - <SubComponents>
38.42 - <Component class="javax.swing.JLabel" name="folderLabel">
38.43 - <Properties>
38.44 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
38.45 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="AddScopePanel.folderLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
38.46 - </Property>
38.47 - </Properties>
38.48 - <Constraints>
38.49 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
38.50 - <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="6" anchor="17" weightX="0.0" weightY="0.0"/>
38.51 - </Constraint>
38.52 - </Constraints>
38.53 - </Component>
38.54 - <Component class="javax.swing.JButton" name="folderChooser">
38.55 - <Properties>
38.56 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
38.57 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="AddScopePanel.folderChooser.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
38.58 - </Property>
38.59 - </Properties>
38.60 - <Events>
38.61 - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="folderChooserActionPerformed"/>
38.62 - </Events>
38.63 - <Constraints>
38.64 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
38.65 - <GridBagConstraints gridX="2" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="6" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
38.66 - </Constraint>
38.67 - </Constraints>
38.68 - </Component>
38.69 - <Component class="javax.swing.JTextField" name="folder">
38.70 - <Properties>
38.71 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
38.72 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="AddScopePanel.folder.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
38.73 - </Property>
38.74 - </Properties>
38.75 - <Constraints>
38.76 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
38.77 - <GridBagConstraints gridX="1" gridY="0" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/>
38.78 - </Constraint>
38.79 - </Constraints>
38.80 - </Component>
38.81 - </SubComponents>
38.82 - </Container>
38.83 - <Container class="javax.swing.JPanel" name="indexVariantsChooserPanel">
38.84 - <Constraints>
38.85 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
38.86 - <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
38.87 - </Constraint>
38.88 - </Constraints>
38.89 -
38.90 - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
38.91 - <SubComponents>
38.92 - <Component class="javax.swing.JRadioButton" name="noIndexButton">
38.93 - <Properties>
38.94 - <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
38.95 - <ComponentRef name="buttonGroup1"/>
38.96 - </Property>
38.97 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
38.98 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="AddScopePanel.noIndexButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
38.99 - </Property>
38.100 - </Properties>
38.101 - <Events>
38.102 - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="noIndexButtonActionPerformed"/>
38.103 - </Events>
38.104 - <Constraints>
38.105 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
38.106 - <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
38.107 - </Constraint>
38.108 - </Constraints>
38.109 - </Component>
38.110 - <Component class="javax.swing.JRadioButton" name="localIndexButton">
38.111 - <Properties>
38.112 - <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
38.113 - <ComponentRef name="buttonGroup1"/>
38.114 - </Property>
38.115 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
38.116 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="AddScopePanel.localIndexButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
38.117 - </Property>
38.118 - </Properties>
38.119 - <Events>
38.120 - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="localIndexButtonActionPerformed"/>
38.121 - </Events>
38.122 - <Constraints>
38.123 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
38.124 - <GridBagConstraints gridX="1" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="12" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
38.125 - </Constraint>
38.126 - </Constraints>
38.127 - </Component>
38.128 - <Component class="javax.swing.JRadioButton" name="removeIndexButton">
38.129 - <Properties>
38.130 - <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
38.131 - <ComponentRef name="buttonGroup1"/>
38.132 - </Property>
38.133 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
38.134 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="AddScopePanel.removeIndexButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
38.135 - </Property>
38.136 - </Properties>
38.137 - <Events>
38.138 - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="removeIndexButtonActionPerformed"/>
38.139 - </Events>
38.140 - <Constraints>
38.141 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
38.142 - <GridBagConstraints gridX="2" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="12" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
38.143 - </Constraint>
38.144 - </Constraints>
38.145 - </Component>
38.146 - <Container class="javax.swing.JPanel" name="jPanel1">
38.147 - <Constraints>
38.148 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
38.149 - <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="1.0" weightY="0.0"/>
38.150 - </Constraint>
38.151 - </Constraints>
38.152 -
38.153 - <Layout>
38.154 - <DimensionLayout dim="0">
38.155 - <Group type="103" groupAlignment="0" attributes="0">
38.156 - <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
38.157 - </Group>
38.158 - </DimensionLayout>
38.159 - <DimensionLayout dim="1">
38.160 - <Group type="103" groupAlignment="0" attributes="0">
38.161 - <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
38.162 - </Group>
38.163 - </DimensionLayout>
38.164 - </Layout>
38.165 - </Container>
38.166 - </SubComponents>
38.167 - </Container>
38.168 - <Container class="javax.swing.JPanel" name="indexVariantsPanel">
38.169 - <Constraints>
38.170 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
38.171 - <GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="0.0"/>
38.172 - </Constraint>
38.173 - </Constraints>
38.174 -
38.175 - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignCardLayout"/>
38.176 - <SubComponents>
38.177 - <Container class="javax.swing.JPanel" name="localIndexPanel">
38.178 - <Constraints>
38.179 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription">
38.180 - <CardConstraints cardName="localIndex"/>
38.181 - </Constraint>
38.182 - </Constraints>
38.183 -
38.184 - <Layout>
38.185 - <DimensionLayout dim="0">
38.186 - <Group type="103" groupAlignment="0" attributes="0">
38.187 - <Group type="102" alignment="0" attributes="0">
38.188 - <EmptySpace max="-2" attributes="0"/>
38.189 - <Group type="103" groupAlignment="1" max="-2" attributes="0">
38.190 - <Group type="102" attributes="1">
38.191 - <EmptySpace min="12" pref="12" max="12" attributes="0"/>
38.192 - <Component id="updateIndexCheckbox" max="32767" attributes="0"/>
38.193 - </Group>
38.194 - <Group type="102" alignment="0" attributes="0">
38.195 - <Component id="indexFolderLabel" min="-2" max="-2" attributes="0"/>
38.196 - <EmptySpace max="-2" attributes="0"/>
38.197 - <Component id="indexFolder" min="-2" pref="482" max="-2" attributes="0"/>
38.198 - <EmptySpace type="unrelated" max="-2" attributes="0"/>
38.199 - <Component id="browse" min="-2" max="-2" attributes="0"/>
38.200 - </Group>
38.201 - </Group>
38.202 - <EmptySpace max="-2" attributes="0"/>
38.203 - </Group>
38.204 - </Group>
38.205 - </DimensionLayout>
38.206 - <DimensionLayout dim="1">
38.207 - <Group type="103" groupAlignment="0" attributes="0">
38.208 - <Group type="102" alignment="0" attributes="0">
38.209 - <EmptySpace max="-2" attributes="0"/>
38.210 - <Group type="103" groupAlignment="3" attributes="0">
38.211 - <Component id="indexFolderLabel" alignment="3" min="-2" max="-2" attributes="0"/>
38.212 - <Component id="indexFolder" alignment="3" min="-2" max="-2" attributes="0"/>
38.213 - <Component id="browse" alignment="3" min="-2" max="-2" attributes="0"/>
38.214 - </Group>
38.215 - <EmptySpace type="unrelated" max="-2" attributes="0"/>
38.216 - <Component id="updateIndexCheckbox" min="-2" max="-2" attributes="0"/>
38.217 - <EmptySpace pref="11" max="32767" attributes="0"/>
38.218 - </Group>
38.219 - </Group>
38.220 - </DimensionLayout>
38.221 - </Layout>
38.222 - <SubComponents>
38.223 - <Component class="javax.swing.JTextField" name="indexFolder">
38.224 - <Properties>
38.225 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
38.226 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="AddScopePanel.indexFolder.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
38.227 - </Property>
38.228 - </Properties>
38.229 - </Component>
38.230 - <Component class="javax.swing.JButton" name="browse">
38.231 - <Properties>
38.232 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
38.233 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="AddScopePanel.browse.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
38.234 - </Property>
38.235 - </Properties>
38.236 - <Events>
38.237 - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="browseActionPerformed"/>
38.238 - </Events>
38.239 - </Component>
38.240 - <Component class="javax.swing.JLabel" name="indexFolderLabel">
38.241 - <Properties>
38.242 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
38.243 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="AddScopePanel.indexFolderLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
38.244 - </Property>
38.245 - </Properties>
38.246 - </Component>
38.247 - <Component class="javax.swing.JCheckBox" name="updateIndexCheckbox">
38.248 - <Properties>
38.249 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
38.250 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="AddScopePanel.updateIndexCheckbox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
38.251 - </Property>
38.252 - </Properties>
38.253 - </Component>
38.254 - </SubComponents>
38.255 - </Container>
38.256 - <Container class="javax.swing.JPanel" name="remoteIndexPanel">
38.257 - <Constraints>
38.258 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription">
38.259 - <CardConstraints cardName="remoteIndex"/>
38.260 - </Constraint>
38.261 - </Constraints>
38.262 -
38.263 - <Layout>
38.264 - <DimensionLayout dim="0">
38.265 - <Group type="103" groupAlignment="0" attributes="0">
38.266 - <Group type="102" alignment="0" attributes="0">
38.267 - <EmptySpace max="-2" attributes="0"/>
38.268 - <Group type="103" groupAlignment="0" attributes="0">
38.269 - <Group type="102" alignment="0" attributes="0">
38.270 - <EmptySpace min="12" pref="12" max="12" attributes="0"/>
38.271 - <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
38.272 - <EmptySpace max="-2" attributes="0"/>
38.273 - <Component id="subIndex" pref="570" max="32767" attributes="0"/>
38.274 - </Group>
38.275 - <Group type="102" alignment="0" attributes="0">
38.276 - <Component id="indexURLLabel" min="-2" max="-2" attributes="0"/>
38.277 - <EmptySpace max="-2" attributes="0"/>
38.278 - <Component id="indexURL" min="-2" max="-2" attributes="0"/>
38.279 - </Group>
38.280 - </Group>
38.281 - <EmptySpace max="-2" attributes="0"/>
38.282 - </Group>
38.283 - </Group>
38.284 - </DimensionLayout>
38.285 - <DimensionLayout dim="1">
38.286 - <Group type="103" groupAlignment="0" attributes="0">
38.287 - <Group type="102" alignment="0" attributes="0">
38.288 - <EmptySpace max="-2" attributes="0"/>
38.289 - <Group type="103" groupAlignment="3" attributes="0">
38.290 - <Component id="indexURLLabel" alignment="3" min="-2" max="-2" attributes="0"/>
38.291 - <Component id="indexURL" alignment="3" min="-2" max="-2" attributes="0"/>
38.292 - </Group>
38.293 - <EmptySpace type="unrelated" max="-2" attributes="0"/>
38.294 - <Group type="103" groupAlignment="3" attributes="0">
38.295 - <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
38.296 - <Component id="subIndex" alignment="3" min="-2" max="-2" attributes="0"/>
38.297 - </Group>
38.298 - <EmptySpace max="32767" attributes="0"/>
38.299 - </Group>
38.300 - </Group>
38.301 - </DimensionLayout>
38.302 - </Layout>
38.303 - <SubComponents>
38.304 - <Component class="javax.swing.JTextField" name="indexURL">
38.305 - <Properties>
38.306 - <Property name="columns" type="int" value="40"/>
38.307 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
38.308 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="AddScopePanel.indexURL.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
38.309 - </Property>
38.310 - </Properties>
38.311 - </Component>
38.312 - <Component class="javax.swing.JLabel" name="indexURLLabel">
38.313 - <Properties>
38.314 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
38.315 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="AddScopePanel.indexURLLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
38.316 - </Property>
38.317 - </Properties>
38.318 - </Component>
38.319 - <Component class="javax.swing.JComboBox" name="subIndex">
38.320 - <Properties>
38.321 - <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
38.322 - <StringArray count="0"/>
38.323 - </Property>
38.324 - </Properties>
38.325 - <Events>
38.326 - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="subIndexActionPerformed"/>
38.327 - </Events>
38.328 - </Component>
38.329 - <Component class="javax.swing.JLabel" name="jLabel1">
38.330 - <Properties>
38.331 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
38.332 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="AddScopePanel.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
38.333 - </Property>
38.334 - </Properties>
38.335 - </Component>
38.336 - </SubComponents>
38.337 - </Container>
38.338 - <Container class="javax.swing.JPanel" name="noIndexPanel">
38.339 - <Constraints>
38.340 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription">
38.341 - <CardConstraints cardName="noIndex"/>
38.342 - </Constraint>
38.343 - </Constraints>
38.344 -
38.345 - <Layout>
38.346 - <DimensionLayout dim="0">
38.347 - <Group type="103" groupAlignment="0" attributes="0">
38.348 - <EmptySpace min="0" pref="678" max="32767" attributes="0"/>
38.349 - </Group>
38.350 - </DimensionLayout>
38.351 - <DimensionLayout dim="1">
38.352 - <Group type="103" groupAlignment="0" attributes="0">
38.353 - <EmptySpace min="0" pref="79" max="32767" attributes="0"/>
38.354 - </Group>
38.355 - </DimensionLayout>
38.356 - </Layout>
38.357 - </Container>
38.358 - </SubComponents>
38.359 - </Container>
38.360 - <Component class="javax.swing.JTextArea" name="indexInfo">
38.361 - <Properties>
38.362 - <Property name="columns" type="int" value="20"/>
38.363 - <Property name="editable" type="boolean" value="false"/>
38.364 - <Property name="rows" type="int" value="5"/>
38.365 - <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
38.366 - <Border info="null"/>
38.367 - </Property>
38.368 - </Properties>
38.369 - <Constraints>
38.370 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
38.371 - <GridBagConstraints gridX="0" gridY="3" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="1.0"/>
38.372 - </Constraint>
38.373 - </Constraints>
38.374 - </Component>
38.375 - </SubComponents>
38.376 -</Form>
39.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/AddScopePanel.java Fri Jan 27 13:35:56 2012 +0100
39.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
39.3 @@ -1,726 +0,0 @@
39.4 -/*
39.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
39.6 - *
39.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
39.8 - *
39.9 - * The contents of this file are subject to the terms of either the GNU
39.10 - * General Public License Version 2 only ("GPL") or the Common
39.11 - * Development and Distribution License("CDDL") (collectively, the
39.12 - * "License"). You may not use this file except in compliance with the
39.13 - * License. You can obtain a copy of the License at
39.14 - * http://www.netbeans.org/cddl-gplv2.html
39.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
39.16 - * specific language governing permissions and limitations under the
39.17 - * License. When distributing the software, include this License Header
39.18 - * Notice in each file and include the License file at
39.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
39.20 - * particular file as subject to the "Classpath" exception as provided
39.21 - * by Sun in the GPL Version 2 section of the License file that
39.22 - * accompanied this code. If applicable, add the following below the
39.23 - * License Header, with the fields enclosed by brackets [] replaced by
39.24 - * your own identifying information:
39.25 - * "Portions Copyrighted [year] [name of copyright owner]"
39.26 - *
39.27 - * If you wish your version of this file to be governed by only the CDDL
39.28 - * or only the GPL Version 2, indicate your decision by adding
39.29 - * "[Contributor] elects to include this software in this distribution
39.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
39.31 - * single choice of license, a recipient has the option to distribute
39.32 - * your version of this file under either the CDDL, the GPL Version 2 or
39.33 - * to extend the choice of license to its licensees as provided above.
39.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
39.35 - * Version 2 license, then the option applies only if the new code is
39.36 - * made subject to such option by the copyright holder.
39.37 - *
39.38 - * Contributor(s):
39.39 - *
39.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
39.41 - */
39.42 -package org.netbeans.modules.jackpot30.impl.refactoring;
39.43 -
39.44 -import java.awt.CardLayout;
39.45 -import java.awt.Component;
39.46 -import java.io.File;
39.47 -import java.io.IOException;
39.48 -import java.net.MalformedURLException;
39.49 -import java.net.URISyntaxException;
39.50 -import java.net.URL;
39.51 -import java.text.DateFormat;
39.52 -import java.util.Collection;
39.53 -import java.util.Date;
39.54 -import java.util.HashMap;
39.55 -import java.util.Map;
39.56 -import java.util.concurrent.atomic.AtomicBoolean;
39.57 -import java.util.concurrent.atomic.AtomicReference;
39.58 -import java.util.logging.Level;
39.59 -import java.util.logging.Logger;
39.60 -import javax.swing.DefaultComboBoxModel;
39.61 -import javax.swing.DefaultListCellRenderer;
39.62 -import javax.swing.JButton;
39.63 -import javax.swing.JFileChooser;
39.64 -import javax.swing.JList;
39.65 -import javax.swing.JTextField;
39.66 -import javax.swing.SwingUtilities;
39.67 -import javax.swing.UIManager;
39.68 -import javax.swing.event.DocumentEvent;
39.69 -import javax.swing.event.DocumentListener;
39.70 -import org.codeviation.pojson.Pojson;
39.71 -import org.netbeans.modules.jackpot30.remoting.api.WebUtilities;
39.72 -import org.netbeans.modules.jackpot30.impl.batch.EnhancedScopes.GivenFolderScope;
39.73 -import org.netbeans.modules.jackpot30.impl.indexing.FileBasedIndex;
39.74 -import org.netbeans.modules.jackpot30.impl.indexing.Index;
39.75 -import org.netbeans.modules.jackpot30.impl.indexing.IndexInfo;
39.76 -import org.openide.NotificationLineSupport;
39.77 -import org.openide.util.Exceptions;
39.78 -import org.openide.util.RequestProcessor;
39.79 -
39.80 -/**
39.81 - *
39.82 - * @author lahvac
39.83 - */
39.84 -public class AddScopePanel extends javax.swing.JPanel {
39.85 -
39.86 - private final JButton okButton;
39.87 -
39.88 - public AddScopePanel(JButton okButton) {
39.89 - this.okButton = okButton;
39.90 - initComponents();
39.91 - noIndexButton.setSelected(true);
39.92 - DocumentListener updateErrorsListener = new DocumentListener() {
39.93 - public void insertUpdate(DocumentEvent e) {
39.94 - updateErrors();
39.95 - }
39.96 - public void removeUpdate(DocumentEvent e) {
39.97 - updateErrors();
39.98 - }
39.99 - public void changedUpdate(DocumentEvent e) {}
39.100 - };
39.101 - folder.getDocument().addDocumentListener(updateErrorsListener);
39.102 - indexFolder.getDocument().addDocumentListener(updateErrorsListener);
39.103 - indexURL.getDocument().addDocumentListener(new DocumentListener() {
39.104 - public void insertUpdate(DocumentEvent e) {
39.105 - indexURLUpdated();
39.106 - }
39.107 - public void removeUpdate(DocumentEvent e) {
39.108 - indexURLUpdated();
39.109 - }
39.110 - public void changedUpdate(DocumentEvent e) {
39.111 - }
39.112 - });
39.113 - indexInfo.setFont(UIManager.getFont("Label.font"));
39.114 - indexInfo.setBackground(UIManager.getColor("Label.background"));
39.115 - indexInfo.setDisabledTextColor(UIManager.getColor("Label.foreground"));
39.116 - }
39.117 -
39.118 - /** This method is called from within the constructor to
39.119 - * initialize the form.
39.120 - * WARNING: Do NOT modify this code. The content of this method is
39.121 - * always regenerated by the Form Editor.
39.122 - */
39.123 - @SuppressWarnings("unchecked")
39.124 - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
39.125 - private void initComponents() {
39.126 - java.awt.GridBagConstraints gridBagConstraints;
39.127 -
39.128 - buttonGroup1 = new javax.swing.ButtonGroup();
39.129 - folderPanel = new javax.swing.JPanel();
39.130 - folderLabel = new javax.swing.JLabel();
39.131 - folderChooser = new javax.swing.JButton();
39.132 - folder = new javax.swing.JTextField();
39.133 - indexVariantsChooserPanel = new javax.swing.JPanel();
39.134 - noIndexButton = new javax.swing.JRadioButton();
39.135 - localIndexButton = new javax.swing.JRadioButton();
39.136 - removeIndexButton = new javax.swing.JRadioButton();
39.137 - jPanel1 = new javax.swing.JPanel();
39.138 - indexVariantsPanel = new javax.swing.JPanel();
39.139 - localIndexPanel = new javax.swing.JPanel();
39.140 - indexFolder = new javax.swing.JTextField();
39.141 - browse = new javax.swing.JButton();
39.142 - indexFolderLabel = new javax.swing.JLabel();
39.143 - updateIndexCheckbox = new javax.swing.JCheckBox();
39.144 - remoteIndexPanel = new javax.swing.JPanel();
39.145 - indexURL = new javax.swing.JTextField();
39.146 - indexURLLabel = new javax.swing.JLabel();
39.147 - subIndex = new javax.swing.JComboBox();
39.148 - jLabel1 = new javax.swing.JLabel();
39.149 - noIndexPanel = new javax.swing.JPanel();
39.150 - indexInfo = new javax.swing.JTextArea();
39.151 -
39.152 - setBorder(javax.swing.BorderFactory.createEmptyBorder(12, 12, 12, 12));
39.153 - setLayout(new java.awt.GridBagLayout());
39.154 -
39.155 - folderPanel.setLayout(new java.awt.GridBagLayout());
39.156 -
39.157 - org.openide.awt.Mnemonics.setLocalizedText(folderLabel, org.openide.util.NbBundle.getMessage(AddScopePanel.class, "AddScopePanel.folderLabel.text")); // NOI18N
39.158 - gridBagConstraints = new java.awt.GridBagConstraints();
39.159 - gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
39.160 - gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 6);
39.161 - folderPanel.add(folderLabel, gridBagConstraints);
39.162 -
39.163 - org.openide.awt.Mnemonics.setLocalizedText(folderChooser, org.openide.util.NbBundle.getMessage(AddScopePanel.class, "AddScopePanel.folderChooser.text")); // NOI18N
39.164 - folderChooser.addActionListener(new java.awt.event.ActionListener() {
39.165 - public void actionPerformed(java.awt.event.ActionEvent evt) {
39.166 - folderChooserActionPerformed(evt);
39.167 - }
39.168 - });
39.169 - gridBagConstraints = new java.awt.GridBagConstraints();
39.170 - gridBagConstraints.gridx = 2;
39.171 - gridBagConstraints.gridy = 0;
39.172 - gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
39.173 - gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0);
39.174 - folderPanel.add(folderChooser, gridBagConstraints);
39.175 -
39.176 - folder.setText(org.openide.util.NbBundle.getMessage(AddScopePanel.class, "AddScopePanel.folder.text")); // NOI18N
39.177 - gridBagConstraints = new java.awt.GridBagConstraints();
39.178 - gridBagConstraints.gridx = 1;
39.179 - gridBagConstraints.gridy = 0;
39.180 - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
39.181 - gridBagConstraints.weightx = 1.0;
39.182 - folderPanel.add(folder, gridBagConstraints);
39.183 -
39.184 - gridBagConstraints = new java.awt.GridBagConstraints();
39.185 - gridBagConstraints.gridx = 0;
39.186 - gridBagConstraints.gridy = 0;
39.187 - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
39.188 - gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
39.189 - gridBagConstraints.weightx = 1.0;
39.190 - add(folderPanel, gridBagConstraints);
39.191 -
39.192 - indexVariantsChooserPanel.setLayout(new java.awt.GridBagLayout());
39.193 -
39.194 - buttonGroup1.add(noIndexButton);
39.195 - org.openide.awt.Mnemonics.setLocalizedText(noIndexButton, org.openide.util.NbBundle.getMessage(AddScopePanel.class, "AddScopePanel.noIndexButton.text")); // NOI18N
39.196 - noIndexButton.addActionListener(new java.awt.event.ActionListener() {
39.197 - public void actionPerformed(java.awt.event.ActionEvent evt) {
39.198 - noIndexButtonActionPerformed(evt);
39.199 - }
39.200 - });
39.201 - gridBagConstraints = new java.awt.GridBagConstraints();
39.202 - gridBagConstraints.gridx = 0;
39.203 - gridBagConstraints.gridy = 0;
39.204 - gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
39.205 - indexVariantsChooserPanel.add(noIndexButton, gridBagConstraints);
39.206 -
39.207 - buttonGroup1.add(localIndexButton);
39.208 - org.openide.awt.Mnemonics.setLocalizedText(localIndexButton, org.openide.util.NbBundle.getMessage(AddScopePanel.class, "AddScopePanel.localIndexButton.text")); // NOI18N
39.209 - localIndexButton.addActionListener(new java.awt.event.ActionListener() {
39.210 - public void actionPerformed(java.awt.event.ActionEvent evt) {
39.211 - localIndexButtonActionPerformed(evt);
39.212 - }
39.213 - });
39.214 - gridBagConstraints = new java.awt.GridBagConstraints();
39.215 - gridBagConstraints.gridx = 1;
39.216 - gridBagConstraints.gridy = 0;
39.217 - gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
39.218 - gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
39.219 - indexVariantsChooserPanel.add(localIndexButton, gridBagConstraints);
39.220 -
39.221 - buttonGroup1.add(removeIndexButton);
39.222 - org.openide.awt.Mnemonics.setLocalizedText(removeIndexButton, org.openide.util.NbBundle.getMessage(AddScopePanel.class, "AddScopePanel.removeIndexButton.text")); // NOI18N
39.223 - removeIndexButton.addActionListener(new java.awt.event.ActionListener() {
39.224 - public void actionPerformed(java.awt.event.ActionEvent evt) {
39.225 - removeIndexButtonActionPerformed(evt);
39.226 - }
39.227 - });
39.228 - gridBagConstraints = new java.awt.GridBagConstraints();
39.229 - gridBagConstraints.gridx = 2;
39.230 - gridBagConstraints.gridy = 0;
39.231 - gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
39.232 - gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
39.233 - indexVariantsChooserPanel.add(removeIndexButton, gridBagConstraints);
39.234 -
39.235 - javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
39.236 - jPanel1.setLayout(jPanel1Layout);
39.237 - jPanel1Layout.setHorizontalGroup(
39.238 - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
39.239 - .addGap(0, 0, Short.MAX_VALUE)
39.240 - );
39.241 - jPanel1Layout.setVerticalGroup(
39.242 - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
39.243 - .addGap(0, 0, Short.MAX_VALUE)
39.244 - );
39.245 -
39.246 - gridBagConstraints = new java.awt.GridBagConstraints();
39.247 - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
39.248 - gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
39.249 - gridBagConstraints.weightx = 1.0;
39.250 - indexVariantsChooserPanel.add(jPanel1, gridBagConstraints);
39.251 -
39.252 - gridBagConstraints = new java.awt.GridBagConstraints();
39.253 - gridBagConstraints.gridx = 0;
39.254 - gridBagConstraints.gridy = 1;
39.255 - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
39.256 - gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
39.257 - gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
39.258 - add(indexVariantsChooserPanel, gridBagConstraints);
39.259 -
39.260 - indexVariantsPanel.setLayout(new java.awt.CardLayout());
39.261 -
39.262 - indexFolder.setText(org.openide.util.NbBundle.getMessage(AddScopePanel.class, "AddScopePanel.indexFolder.text")); // NOI18N
39.263 -
39.264 - org.openide.awt.Mnemonics.setLocalizedText(browse, org.openide.util.NbBundle.getMessage(AddScopePanel.class, "AddScopePanel.browse.text")); // NOI18N
39.265 - browse.addActionListener(new java.awt.event.ActionListener() {
39.266 - public void actionPerformed(java.awt.event.ActionEvent evt) {
39.267 - browseActionPerformed(evt);
39.268 - }
39.269 - });
39.270 -
39.271 - org.openide.awt.Mnemonics.setLocalizedText(indexFolderLabel, org.openide.util.NbBundle.getMessage(AddScopePanel.class, "AddScopePanel.indexFolderLabel.text")); // NOI18N
39.272 -
39.273 - org.openide.awt.Mnemonics.setLocalizedText(updateIndexCheckbox, org.openide.util.NbBundle.getMessage(AddScopePanel.class, "AddScopePanel.updateIndexCheckbox.text")); // NOI18N
39.274 -
39.275 - javax.swing.GroupLayout localIndexPanelLayout = new javax.swing.GroupLayout(localIndexPanel);
39.276 - localIndexPanel.setLayout(localIndexPanelLayout);
39.277 - localIndexPanelLayout.setHorizontalGroup(
39.278 - localIndexPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
39.279 - .addGroup(localIndexPanelLayout.createSequentialGroup()
39.280 - .addContainerGap()
39.281 - .addGroup(localIndexPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
39.282 - .addGroup(localIndexPanelLayout.createSequentialGroup()
39.283 - .addGap(12, 12, 12)
39.284 - .addComponent(updateIndexCheckbox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
39.285 - .addGroup(javax.swing.GroupLayout.Alignment.LEADING, localIndexPanelLayout.createSequentialGroup()
39.286 - .addComponent(indexFolderLabel)
39.287 - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
39.288 - .addComponent(indexFolder, javax.swing.GroupLayout.PREFERRED_SIZE, 482, javax.swing.GroupLayout.PREFERRED_SIZE)
39.289 - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
39.290 - .addComponent(browse)))
39.291 - .addContainerGap())
39.292 - );
39.293 - localIndexPanelLayout.setVerticalGroup(
39.294 - localIndexPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
39.295 - .addGroup(localIndexPanelLayout.createSequentialGroup()
39.296 - .addContainerGap()
39.297 - .addGroup(localIndexPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
39.298 - .addComponent(indexFolderLabel)
39.299 - .addComponent(indexFolder, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
39.300 - .addComponent(browse))
39.301 - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
39.302 - .addComponent(updateIndexCheckbox)
39.303 - .addContainerGap(11, Short.MAX_VALUE))
39.304 - );
39.305 -
39.306 - indexVariantsPanel.add(localIndexPanel, "localIndex");
39.307 -
39.308 - indexURL.setColumns(40);
39.309 - indexURL.setText(org.openide.util.NbBundle.getMessage(AddScopePanel.class, "AddScopePanel.indexURL.text")); // NOI18N
39.310 -
39.311 - org.openide.awt.Mnemonics.setLocalizedText(indexURLLabel, org.openide.util.NbBundle.getMessage(AddScopePanel.class, "AddScopePanel.indexURLLabel.text")); // NOI18N
39.312 -
39.313 - subIndex.addActionListener(new java.awt.event.ActionListener() {
39.314 - public void actionPerformed(java.awt.event.ActionEvent evt) {
39.315 - subIndexActionPerformed(evt);
39.316 - }
39.317 - });
39.318 -
39.319 - org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(AddScopePanel.class, "AddScopePanel.jLabel1.text")); // NOI18N
39.320 -
39.321 - javax.swing.GroupLayout remoteIndexPanelLayout = new javax.swing.GroupLayout(remoteIndexPanel);
39.322 - remoteIndexPanel.setLayout(remoteIndexPanelLayout);
39.323 - remoteIndexPanelLayout.setHorizontalGroup(
39.324 - remoteIndexPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
39.325 - .addGroup(remoteIndexPanelLayout.createSequentialGroup()
39.326 - .addContainerGap()
39.327 - .addGroup(remoteIndexPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
39.328 - .addGroup(remoteIndexPanelLayout.createSequentialGroup()
39.329 - .addGap(12, 12, 12)
39.330 - .addComponent(jLabel1)
39.331 - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
39.332 - .addComponent(subIndex, 0, 570, Short.MAX_VALUE))
39.333 - .addGroup(remoteIndexPanelLayout.createSequentialGroup()
39.334 - .addComponent(indexURLLabel)
39.335 - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
39.336 - .addComponent(indexURL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
39.337 - .addContainerGap())
39.338 - );
39.339 - remoteIndexPanelLayout.setVerticalGroup(
39.340 - remoteIndexPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
39.341 - .addGroup(remoteIndexPanelLayout.createSequentialGroup()
39.342 - .addContainerGap()
39.343 - .addGroup(remoteIndexPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
39.344 - .addComponent(indexURLLabel)
39.345 - .addComponent(indexURL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
39.346 - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
39.347 - .addGroup(remoteIndexPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
39.348 - .addComponent(jLabel1)
39.349 - .addComponent(subIndex, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
39.350 - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
39.351 - );
39.352 -
39.353 - indexVariantsPanel.add(remoteIndexPanel, "remoteIndex");
39.354 -
39.355 - javax.swing.GroupLayout noIndexPanelLayout = new javax.swing.GroupLayout(noIndexPanel);
39.356 - noIndexPanel.setLayout(noIndexPanelLayout);
39.357 - noIndexPanelLayout.setHorizontalGroup(
39.358 - noIndexPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
39.359 - .addGap(0, 678, Short.MAX_VALUE)
39.360 - );
39.361 - noIndexPanelLayout.setVerticalGroup(
39.362 - noIndexPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
39.363 - .addGap(0, 79, Short.MAX_VALUE)
39.364 - );
39.365 -
39.366 - indexVariantsPanel.add(noIndexPanel, "noIndex");
39.367 -
39.368 - gridBagConstraints = new java.awt.GridBagConstraints();
39.369 - gridBagConstraints.gridx = 0;
39.370 - gridBagConstraints.gridy = 2;
39.371 - gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
39.372 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
39.373 - gridBagConstraints.weightx = 1.0;
39.374 - gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
39.375 - add(indexVariantsPanel, gridBagConstraints);
39.376 -
39.377 - indexInfo.setColumns(20);
39.378 - indexInfo.setEditable(false);
39.379 - indexInfo.setRows(5);
39.380 - indexInfo.setBorder(null);
39.381 - gridBagConstraints = new java.awt.GridBagConstraints();
39.382 - gridBagConstraints.gridx = 0;
39.383 - gridBagConstraints.gridy = 3;
39.384 - gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
39.385 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
39.386 - gridBagConstraints.weightx = 1.0;
39.387 - gridBagConstraints.weighty = 1.0;
39.388 - gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
39.389 - add(indexInfo, gridBagConstraints);
39.390 - }// </editor-fold>//GEN-END:initComponents
39.391 -
39.392 - private void folderChooserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_folderChooserActionPerformed
39.393 - showFileChooser(folder);
39.394 -}//GEN-LAST:event_folderChooserActionPerformed
39.395 -
39.396 - private void noIndexButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_noIndexButtonActionPerformed
39.397 - selectCorrectCard();
39.398 - }//GEN-LAST:event_noIndexButtonActionPerformed
39.399 -
39.400 - private void localIndexButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_localIndexButtonActionPerformed
39.401 - selectCorrectCard();
39.402 - }//GEN-LAST:event_localIndexButtonActionPerformed
39.403 -
39.404 - private void removeIndexButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeIndexButtonActionPerformed
39.405 - selectCorrectCard();
39.406 - }//GEN-LAST:event_removeIndexButtonActionPerformed
39.407 -
39.408 - private void browseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseActionPerformed
39.409 - showFileChooser(indexFolder);
39.410 - }//GEN-LAST:event_browseActionPerformed
39.411 -
39.412 - private void subIndexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subIndexActionPerformed
39.413 - subindexSelectionUpdated();
39.414 - }//GEN-LAST:event_subIndexActionPerformed
39.415 -
39.416 - private void selectCorrectCard() {
39.417 - String card;
39.418 -
39.419 - indexInfo.setText("");
39.420 -
39.421 - if (noIndexButton.isSelected()) card = "noIndex";
39.422 - else if (localIndexButton.isSelected()) card = "localIndex";
39.423 - else {
39.424 - card = "remoteIndex";
39.425 - indexURLUpdated();
39.426 - }
39.427 -
39.428 - ((CardLayout) indexVariantsPanel.getLayout()).show(indexVariantsPanel, card);
39.429 -
39.430 - updateErrors();
39.431 - }
39.432 -
39.433 - // Variables declaration - do not modify//GEN-BEGIN:variables
39.434 - private javax.swing.JButton browse;
39.435 - private javax.swing.ButtonGroup buttonGroup1;
39.436 - private javax.swing.JTextField folder;
39.437 - private javax.swing.JButton folderChooser;
39.438 - private javax.swing.JLabel folderLabel;
39.439 - private javax.swing.JPanel folderPanel;
39.440 - private javax.swing.JTextField indexFolder;
39.441 - private javax.swing.JLabel indexFolderLabel;
39.442 - private javax.swing.JTextArea indexInfo;
39.443 - private javax.swing.JTextField indexURL;
39.444 - private javax.swing.JLabel indexURLLabel;
39.445 - private javax.swing.JPanel indexVariantsChooserPanel;
39.446 - private javax.swing.JPanel indexVariantsPanel;
39.447 - private javax.swing.JLabel jLabel1;
39.448 - private javax.swing.JPanel jPanel1;
39.449 - private javax.swing.JRadioButton localIndexButton;
39.450 - private javax.swing.JPanel localIndexPanel;
39.451 - private javax.swing.JRadioButton noIndexButton;
39.452 - private javax.swing.JPanel noIndexPanel;
39.453 - private javax.swing.JPanel remoteIndexPanel;
39.454 - private javax.swing.JRadioButton removeIndexButton;
39.455 - private javax.swing.JComboBox subIndex;
39.456 - private javax.swing.JCheckBox updateIndexCheckbox;
39.457 - // End of variables declaration//GEN-END:variables
39.458 -
39.459 - private void showFileChooser(JTextField folder) {
39.460 - JFileChooser c = new JFileChooser();
39.461 -
39.462 - c.setSelectedFile(new File(folder.getText()));
39.463 - c.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
39.464 - c.setMultiSelectionEnabled(false);
39.465 - c.setApproveButtonText("Select");
39.466 -
39.467 - if (c.showDialog(this, null) == JFileChooser.APPROVE_OPTION) {
39.468 - folder.setText(c.getSelectedFile().getAbsolutePath());
39.469 - }
39.470 - }
39.471 -
39.472 - public void setScope(GivenFolderScope scope) {
39.473 - folder.setText(scope.folder);
39.474 - if (scope.indexURL != null) {
39.475 - if (scope.subIndex != null) {
39.476 - removeIndexButton.setSelected(true);
39.477 - indexURL.setText(scope.indexURL);
39.478 - subIndex.setSelectedItem(scope.subIndex);
39.479 - } else {
39.480 - localIndexButton.setSelected(true);
39.481 - indexFolder.setText(scope.indexURL);
39.482 - updateIndexCheckbox.setSelected(scope.update);
39.483 - }
39.484 - } else {
39.485 - noIndexButton.setSelected(true);
39.486 - }
39.487 -
39.488 - selectCorrectCard();
39.489 - }
39.490 -
39.491 - public GivenFolderScope getScope() {
39.492 - if (noIndexButton.isSelected()) {
39.493 - return new GivenFolderScope(folder.getText(), null, null, false);
39.494 - }
39.495 - if (localIndexButton.isSelected()) {
39.496 - return new GivenFolderScope(folder.getText(), new File(indexFolder.getText()).getAbsolutePath(), null, updateIndexCheckbox.isSelected());
39.497 - }
39.498 - if (removeIndexButton.isSelected()) {
39.499 - return new GivenFolderScope(folder.getText(), indexURL.getText(), (String) subIndex.getSelectedItem(), false);
39.500 - }
39.501 -
39.502 - throw new IllegalStateException();
39.503 - }
39.504 -
39.505 - private NotificationLineSupport notificationSupport;
39.506 -
39.507 - public void setNotificationSupport(NotificationLineSupport notificationSupport) {
39.508 - this.notificationSupport = notificationSupport;
39.509 - selectCorrectCard();
39.510 - }
39.511 -
39.512 - private void updateErrors() {
39.513 - notificationSupport.clearMessages();
39.514 -
39.515 - File folderFile = new File(folder.getText());
39.516 -
39.517 - if (!folderFile.exists()) {
39.518 - notificationSupport.setErrorMessage("Specified directory does not exist.");
39.519 - okButton.setEnabled(false);
39.520 - return;
39.521 - }
39.522 -
39.523 - if (!folderFile.isDirectory()) {
39.524 - notificationSupport.setErrorMessage("Specified directory is not directory.");
39.525 - okButton.setEnabled(false);
39.526 - return ;
39.527 - }
39.528 -
39.529 - if (localIndexButton.isSelected()) {
39.530 - File indexFile = new File(indexFolder.getText());
39.531 -
39.532 - updateIndexCheckbox.setEnabled(indexFile.exists());
39.533 -
39.534 - if (!indexFile.exists()) {
39.535 - notificationSupport.setInformationMessage("Index does not exist and will be created.");
39.536 - okButton.setEnabled(true);
39.537 - return;
39.538 - }
39.539 -
39.540 - if (!indexFile.isDirectory()) {
39.541 - notificationSupport.setErrorMessage("Index is not a folder.");
39.542 - okButton.setEnabled(false);
39.543 - return;
39.544 - }
39.545 - try {
39.546 - Index idx = FileBasedIndex.create(folderFile.toURI().toURL(), indexFile);
39.547 - IndexInfo info = idx.getIndexInfo();
39.548 -
39.549 - indexInfo.setText(toDisplayText(info));
39.550 - } catch (MalformedURLException ex) {
39.551 - Exceptions.printStackTrace(ex);
39.552 - } catch (IOException ex) {
39.553 - Exceptions.printStackTrace(ex);
39.554 - }
39.555 - }
39.556 -
39.557 - if (removeIndexButton.isSelected()) {
39.558 - if (checkingIndexURL.get()) {
39.559 - notificationSupport.setInformationMessage("Checking index URL");
39.560 - okButton.setEnabled(false);
39.561 - return;
39.562 - }
39.563 -
39.564 - String urlError = checkingIndexURLError.get();
39.565 -
39.566 - if (urlError != null) {
39.567 - notificationSupport.setErrorMessage(urlError);
39.568 - okButton.setEnabled(false);
39.569 - return;
39.570 - }
39.571 - }
39.572 -
39.573 - okButton.setEnabled(true);
39.574 - }
39.575 -
39.576 - private final AtomicBoolean checkingIndexURL = new AtomicBoolean();
39.577 - private final AtomicReference<String> checkingIndexURLContentCopy = new AtomicReference<String>();
39.578 - private final AtomicReference<String> checkingIndexURLError = new AtomicReference<String>();
39.579 -
39.580 - private void indexURLUpdated() {
39.581 - checkingIndexURLContentCopy.set(indexURL.getText());
39.582 - urlCheckerTask.cancel();
39.583 - urlCheckerTask.schedule(50);
39.584 - }
39.585 -
39.586 - private static final RequestProcessor WORKER = new RequestProcessor(AddScopePanel.class.getName(), 1, false, false);
39.587 - private final RequestProcessor.Task urlCheckerTask = WORKER.create(new Runnable() {
39.588 -
39.589 - public void run() {
39.590 - checkingIndexURL.set(true);
39.591 - checkingIndexURLError.set(null);
39.592 -
39.593 - SwingUtilities.invokeLater(new Runnable() {
39.594 - public void run() {
39.595 - updateErrors();
39.596 - }
39.597 - });
39.598 -
39.599 - String urlText = checkingIndexURLContentCopy.get();
39.600 - Collection<? extends String> subindices = null;
39.601 -
39.602 - try {
39.603 - URL url = new URL(urlText);
39.604 -
39.605 - if (!url.getPath().endsWith("/"))
39.606 - url = new URL(url.getProtocol(), url.getHost(), url.getPort(), url.getPath() + "/" + (url.getQuery() != null ? "?" + url.getQuery() : ""));
39.607 -
39.608 - subindices = WebUtilities.requestStringArrayResponse(url.toURI().resolve("list"));
39.609 -
39.610 - if (subindices.isEmpty()) {
39.611 - checkingIndexURLError.set("Not an index.");
39.612 - }
39.613 - } catch (URISyntaxException ex) {
39.614 - checkingIndexURLError.set(ex.getLocalizedMessage());
39.615 - } catch (MalformedURLException ex) {
39.616 - checkingIndexURLError.set(ex.getLocalizedMessage());
39.617 - }
39.618 -
39.619 - checkingIndexURL.set(false);
39.620 -
39.621 - final Collection<? extends String> subindicesFinal = subindices;
39.622 -
39.623 - SwingUtilities.invokeLater(new Runnable() {
39.624 - public void run() {
39.625 - updateErrors();
39.626 -
39.627 - if (subindicesFinal == null) return;
39.628 -
39.629 - DefaultComboBoxModel model = (DefaultComboBoxModel) subIndex.getModel();
39.630 - String selected = (String) model.getSelectedItem();
39.631 -
39.632 - model.removeAllElements();
39.633 -
39.634 - boolean containsSelection = false;
39.635 - Map<String, String> displayNames = new HashMap<String, String>();
39.636 -
39.637 - for (String subindex : subindicesFinal) {
39.638 - String[] subindexSplit = subindex.split(":", 2);
39.639 - if (subindexSplit[0].equals(selected)) containsSelection = true;
39.640 - model.addElement(subindexSplit[0]);
39.641 - displayNames.put(subindexSplit[0], subindexSplit[1]);
39.642 - }
39.643 -
39.644 - if (containsSelection) {
39.645 - model.setSelectedItem(selected);
39.646 - }
39.647 -
39.648 - subindexSelectionUpdated();
39.649 - subIndex.setRenderer(new RendererImpl(displayNames));
39.650 - }
39.651 - });
39.652 - }
39.653 - });
39.654 -
39.655 - private final AtomicReference<String> indexInfoURLContentCopy = new AtomicReference<String>();
39.656 - private final AtomicReference<String> indexInfoSubIndexCopy = new AtomicReference<String>();
39.657 - private void subindexSelectionUpdated() {
39.658 - indexInfoURLContentCopy.set(indexURL.getText());
39.659 - indexInfoSubIndexCopy.set((String) subIndex.getSelectedItem());
39.660 - indexInfoTask.cancel();
39.661 - indexInfoTask.schedule(50);
39.662 - }
39.663 -
39.664 - private final RequestProcessor.Task indexInfoTask = WORKER.create(new Runnable() {
39.665 -
39.666 - public void run() {
39.667 - String urlText = indexInfoURLContentCopy.get();
39.668 - String subIndex = indexInfoSubIndexCopy.get();
39.669 - IndexInfo info = null;
39.670 -
39.671 - try {
39.672 - URL url = new URL(urlText);
39.673 -
39.674 - if (!url.getPath().endsWith("/"))
39.675 - url = new URL(url.getProtocol(), url.getHost(), url.getPort(), url.getPath() + "/" + (url.getQuery() != null ? "?" + url.getQuery() : ""));
39.676 -
39.677 - String indexInfoText = WebUtilities.requestStringResponse(url.toURI().resolve("info?path=" + WebUtilities.escapeForQuery(subIndex)));
39.678 - info = IndexInfo.empty();
39.679 -
39.680 - Pojson.update(info, indexInfoText);
39.681 - } catch (URISyntaxException ex) {
39.682 - Logger.getLogger(AddScopePanel.class.getName()).log(Level.FINE, null, ex);
39.683 - } catch (MalformedURLException ex) {
39.684 - Logger.getLogger(AddScopePanel.class.getName()).log(Level.FINE, null, ex);
39.685 - }
39.686 -
39.687 - final IndexInfo infoFinal = info;
39.688 -
39.689 - SwingUtilities.invokeLater(new Runnable() {
39.690 - public void run() {
39.691 - if (infoFinal != null) {
39.692 - indexInfo.setText(toDisplayText(infoFinal));
39.693 - } else {
39.694 - indexInfo.setText("");
39.695 - }
39.696 - }
39.697 - });
39.698 - }
39.699 - });
39.700 -
39.701 - private static String toDisplayText(IndexInfo info) {
39.702 - StringBuilder sb = new StringBuilder();
39.703 -
39.704 - if (info.sourceLocation != null) {
39.705 - sb.append("Source Location: ").append(info.sourceLocation).append("\n");
39.706 - }
39.707 - if (info.lastUpdate >= 0) {
39.708 - sb.append("Last Update:\t").append(DateFormat.getDateTimeInstance().format(new Date(info.lastUpdate))).append("\n");
39.709 - }
39.710 - if (info.totalFiles >= 0) {
39.711 - sb.append("Indexed Files:\t").append(info.totalFiles).append("\n");
39.712 - }
39.713 -
39.714 - return sb.toString();
39.715 - }
39.716 -
39.717 - private static final class RendererImpl extends DefaultListCellRenderer {
39.718 - private final Map<String, String> displayNames;
39.719 - public RendererImpl(Map<String, String> displayNames) {
39.720 - this.displayNames = displayNames;
39.721 - }
39.722 -
39.723 - @Override
39.724 - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
39.725 - return super.getListCellRendererComponent(list, displayNames.get(value), index, isSelected, cellHasFocus);
39.726 - }
39.727 -
39.728 - }
39.729 -}
40.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/ApplyPatternAction.java Fri Jan 27 13:35:56 2012 +0100
40.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
40.3 @@ -1,52 +0,0 @@
40.4 -/*
40.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
40.6 - *
40.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
40.8 - *
40.9 - * The contents of this file are subject to the terms of either the GNU
40.10 - * General Public License Version 2 only ("GPL") or the Common
40.11 - * Development and Distribution License("CDDL") (collectively, the
40.12 - * "License"). You may not use this file except in compliance with the
40.13 - * License. You can obtain a copy of the License at
40.14 - * http://www.netbeans.org/cddl-gplv2.html
40.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
40.16 - * specific language governing permissions and limitations under the
40.17 - * License. When distributing the software, include this License Header
40.18 - * Notice in each file and include the License file at
40.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
40.20 - * particular file as subject to the "Classpath" exception as provided
40.21 - * by Sun in the GPL Version 2 section of the License file that
40.22 - * accompanied this code. If applicable, add the following below the
40.23 - * License Header, with the fields enclosed by brackets [] replaced by
40.24 - * your own identifying information:
40.25 - * "Portions Copyrighted [year] [name of copyright owner]"
40.26 - *
40.27 - * If you wish your version of this file to be governed by only the CDDL
40.28 - * or only the GPL Version 2, indicate your decision by adding
40.29 - * "[Contributor] elects to include this software in this distribution
40.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
40.31 - * single choice of license, a recipient has the option to distribute
40.32 - * your version of this file under either the CDDL, the GPL Version 2 or
40.33 - * to extend the choice of license to its licensees as provided above.
40.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
40.35 - * Version 2 license, then the option applies only if the new code is
40.36 - * made subject to such option by the copyright holder.
40.37 - *
40.38 - * Contributor(s):
40.39 - *
40.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
40.41 - */
40.42 -
40.43 -package org.netbeans.modules.jackpot30.impl.refactoring;
40.44 -
40.45 -import java.awt.event.ActionEvent;
40.46 -import java.awt.event.ActionListener;
40.47 -import org.netbeans.modules.java.hints.jackpot.impl.batch.Scopes;
40.48 -import org.netbeans.modules.refactoring.spi.ui.UI;
40.49 -
40.50 -public final class ApplyPatternAction implements ActionListener {
40.51 -
40.52 - public void actionPerformed(ActionEvent e) {
40.53 - UI.openRefactoringUI(new FindDuplicatesRefactoringUI(null, Scopes.allOpenedProjectsScope(), true, false));
40.54 - }
40.55 -}
41.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties Fri Jan 27 13:35:56 2012 +0100
41.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
41.3 @@ -1,74 +0,0 @@
41.4 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
41.5 -#
41.6 -# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
41.7 -#
41.8 -# The contents of this file are subject to the terms of either the GNU
41.9 -# General Public License Version 2 only ("GPL") or the Common
41.10 -# Development and Distribution License("CDDL") (collectively, the
41.11 -# "License"). You may not use this file except in compliance with the
41.12 -# License. You can obtain a copy of the License at
41.13 -# http://www.netbeans.org/cddl-gplv2.html
41.14 -# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
41.15 -# specific language governing permissions and limitations under the
41.16 -# License. When distributing the software, include this License Header
41.17 -# Notice in each file and include the License file at
41.18 -# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
41.19 -# particular file as subject to the "Classpath" exception as provided
41.20 -# by Sun in the GPL Version 2 section of the License file that
41.21 -# accompanied this code. If applicable, add the following below the
41.22 -# License Header, with the fields enclosed by brackets [] replaced by
41.23 -# your own identifying information:
41.24 -# "Portions Copyrighted [year] [name of copyright owner]"
41.25 -#
41.26 -# If you wish your version of this file to be governed by only the CDDL
41.27 -# or only the GPL Version 2, indicate your decision by adding
41.28 -# "[Contributor] elects to include this software in this distribution
41.29 -# under the [CDDL or GPL Version 2] license." If you do not indicate a
41.30 -# single choice of license, a recipient has the option to distribute
41.31 -# your version of this file under either the CDDL, the GPL Version 2 or
41.32 -# to extend the choice of license to its licensees as provided above.
41.33 -# However, if you add GPL Version 2 code and therefore, elected the GPL
41.34 -# Version 2 license, then the option applies only if the new code is
41.35 -# made subject to such option by the copyright holder.
41.36 -#
41.37 -# Contributor(s):
41.38 -#
41.39 -# Portions Copyrighted 2009 Sun Microsystems, Inc.
41.40 -
41.41 -CTL_ApplyPatternAction=Apply Pattern
41.42 -CTL_FindOccurrencesAction=Find Pattern Occurrences
41.43 -AdvancedOptions.externalIndex.text=Use &external index
41.44 -AdvancedOptions.indexLocation.text=
41.45 -AdvancedOptions.indexLocationLabel.text=&Location:
41.46 -AdvancedOptions.indexProjectLabel.text=&Project:
41.47 -AddScopePanel.indexFolder.text=
41.48 -AddScopePanel.browse.text=Browse
41.49 -AddScopePanel.indexFolderLabel.text=Index Path:
41.50 -AddScopePanel.indexURLLabel.text=Index URL:
41.51 -AddScopePanel.indexURL.text=
41.52 -AddScopePanel.noIndexButton.text=&No External Index
41.53 -AddScopePanel.localIndexButton.text=&Local Index
41.54 -AddScopePanel.removeIndexButton.text=&Remote Index
41.55 -AddScopePanel.folder.text=
41.56 -AddScopePanel.folderChooser.text=Browse
41.57 -AddScopePanel.folderLabel.text=&Folder:
41.58 -AddScopePanel.updateIndexCheckbox.text=&Update Index
41.59 -AddScopePanel.jLabel1.text=Subindex:
41.60 -ScopesPanel.edit.text=Edit
41.61 -ScopesPanel.removeButton.text=Remove
41.62 -ScopesPanel.add.text=Add
41.63 -ScopesPanel.jLabel2.text=&Scope:
41.64 -FindDuplicatesRefactoringPanel.verify.text=Verify occurrences if possible (slower)
41.65 -FindDuplicatesRefactoringPanel.removeAllHints.text=<<
41.66 -FindDuplicatesRefactoringPanel.removeHint.text=<
41.67 -FindDuplicatesRefactoringPanel.addAllHints.text=>>
41.68 -FindDuplicatesRefactoringPanel.addHint.text=>
41.69 -FindDuplicatesRefactoringPanel.selectedHintsLabel.text=Selected Hints
41.70 -FindDuplicatesRefactoringPanel.allHintsLabel.text=All Hints:
41.71 -FindDuplicatesRefactoringPanel.customPattern.text=&Custom Pattern
41.72 -FindDuplicatesRefactoringPanel.knowPatterns.text=&Known patterns
41.73 -FindDuplicatesRefactoringPanel.examplesButton.text=
41.74 -BTN_Examples=Examples
41.75 -FindDuplicatesRefactoringPanel.recentButton.toolTipText=Recent Rules
41.76 -FindDuplicatesRefactoringPanel.recentButton.text=
41.77 -ExamplesList.pattern.contentType=text/x-javahints
42.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/ExamplesList.form Fri Jan 27 13:35:56 2012 +0100
42.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
42.3 @@ -1,95 +0,0 @@
42.4 -<?xml version="1.1" encoding="UTF-8" ?>
42.5 -
42.6 -<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
42.7 - <AuxValues>
42.8 - <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
42.9 - <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
42.10 - <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
42.11 - <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
42.12 - <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
42.13 - <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
42.14 - <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
42.15 - <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
42.16 - <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
42.17 - </AuxValues>
42.18 -
42.19 - <Layout>
42.20 - <DimensionLayout dim="0">
42.21 - <Group type="103" groupAlignment="0" attributes="0">
42.22 - <Group type="102" alignment="1" attributes="0">
42.23 - <EmptySpace max="-2" attributes="0"/>
42.24 - <Group type="103" groupAlignment="1" attributes="0">
42.25 - <Component id="jScrollPane2" alignment="0" pref="376" max="32767" attributes="0"/>
42.26 - <Component id="jScrollPane1" alignment="0" pref="376" max="32767" attributes="0"/>
42.27 - <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
42.28 - </Group>
42.29 - <EmptySpace max="-2" attributes="0"/>
42.30 - </Group>
42.31 - </Group>
42.32 - </DimensionLayout>
42.33 - <DimensionLayout dim="1">
42.34 - <Group type="103" groupAlignment="0" attributes="0">
42.35 - <Group type="102" alignment="0" attributes="0">
42.36 - <EmptySpace max="-2" attributes="0"/>
42.37 - <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
42.38 - <EmptySpace max="-2" attributes="0"/>
42.39 - <Component id="jScrollPane1" pref="130" max="32767" attributes="0"/>
42.40 - <EmptySpace max="-2" attributes="0"/>
42.41 - <Component id="jScrollPane2" min="-2" pref="119" max="-2" attributes="0"/>
42.42 - <EmptySpace max="-2" attributes="0"/>
42.43 - </Group>
42.44 - </Group>
42.45 - </DimensionLayout>
42.46 - </Layout>
42.47 - <SubComponents>
42.48 - <Component class="javax.swing.JLabel" name="jLabel1">
42.49 - <Properties>
42.50 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
42.51 - <Connection code="convertor.getHeader()" type="code"/>
42.52 - </Property>
42.53 - </Properties>
42.54 - </Component>
42.55 - <Container class="javax.swing.JScrollPane" name="jScrollPane1">
42.56 - <AuxValues>
42.57 - <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
42.58 - </AuxValues>
42.59 -
42.60 - <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
42.61 - <SubComponents>
42.62 - <Component class="javax.swing.JList" name="list">
42.63 - <Properties>
42.64 - <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
42.65 - <StringArray count="5">
42.66 - <StringItem index="0" value="Item 1"/>
42.67 - <StringItem index="1" value="Item 2"/>
42.68 - <StringItem index="2" value="Item 3"/>
42.69 - <StringItem index="3" value="Item 4"/>
42.70 - <StringItem index="4" value="Item 5"/>
42.71 - </StringArray>
42.72 - </Property>
42.73 - </Properties>
42.74 - <Events>
42.75 - <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="listMouseClicked"/>
42.76 - <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="listValueChanged"/>
42.77 - </Events>
42.78 - </Component>
42.79 - </SubComponents>
42.80 - </Container>
42.81 - <Container class="javax.swing.JScrollPane" name="jScrollPane2">
42.82 - <AuxValues>
42.83 - <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
42.84 - </AuxValues>
42.85 -
42.86 - <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
42.87 - <SubComponents>
42.88 - <Component class="javax.swing.JEditorPane" name="pattern">
42.89 - <Properties>
42.90 - <Property name="contentType" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
42.91 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="ExamplesList.pattern.contentType" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
42.92 - </Property>
42.93 - </Properties>
42.94 - </Component>
42.95 - </SubComponents>
42.96 - </Container>
42.97 - </SubComponents>
42.98 -</Form>
43.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/ExamplesList.java Fri Jan 27 13:35:56 2012 +0100
43.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
43.3 @@ -1,223 +0,0 @@
43.4 -/*
43.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
43.6 - *
43.7 - * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
43.8 - *
43.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
43.10 - * Other names may be trademarks of their respective owners.
43.11 - *
43.12 - * The contents of this file are subject to the terms of either the GNU
43.13 - * General Public License Version 2 only ("GPL") or the Common
43.14 - * Development and Distribution License("CDDL") (collectively, the
43.15 - * "License"). You may not use this file except in compliance with the
43.16 - * License. You can obtain a copy of the License at
43.17 - * http://www.netbeans.org/cddl-gplv2.html
43.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
43.19 - * specific language governing permissions and limitations under the
43.20 - * License. When distributing the software, include this License Header
43.21 - * Notice in each file and include the License file at
43.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
43.23 - * particular file as subject to the "Classpath" exception as provided
43.24 - * by Oracle in the GPL Version 2 section of the License file that
43.25 - * accompanied this code. If applicable, add the following below the
43.26 - * License Header, with the fields enclosed by brackets [] replaced by
43.27 - * your own identifying information:
43.28 - * "Portions Copyrighted [year] [name of copyright owner]"
43.29 - *
43.30 - * If you wish your version of this file to be governed by only the CDDL
43.31 - * or only the GPL Version 2, indicate your decision by adding
43.32 - * "[Contributor] elects to include this software in this distribution
43.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
43.34 - * single choice of license, a recipient has the option to distribute
43.35 - * your version of this file under either the CDDL, the GPL Version 2 or
43.36 - * to extend the choice of license to its licensees as provided above.
43.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
43.38 - * Version 2 license, then the option applies only if the new code is
43.39 - * made subject to such option by the copyright holder.
43.40 - *
43.41 - * Contributor(s):
43.42 - *
43.43 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
43.44 - */
43.45 -package org.netbeans.modules.jackpot30.impl.refactoring;
43.46 -
43.47 -import java.awt.Component;
43.48 -import java.awt.Dialog;
43.49 -import java.awt.Rectangle;
43.50 -import java.util.Collections;
43.51 -import java.util.Set;
43.52 -import javax.swing.DefaultListCellRenderer;
43.53 -import javax.swing.DefaultListModel;
43.54 -import javax.swing.JList;
43.55 -import javax.swing.text.BadLocationException;
43.56 -import org.netbeans.modules.jackpot30.impl.examples.Example.Option;
43.57 -import org.openide.DialogDescriptor;
43.58 -import org.openide.DialogDisplayer;
43.59 -import org.openide.util.Exceptions;
43.60 -
43.61 -/**
43.62 - *
43.63 - * @author lahvac
43.64 - */
43.65 -public class ExamplesList<T> extends javax.swing.JPanel {
43.66 -
43.67 - private final DialogDescription<T> convertor;
43.68 - private final Class<T> dataClass;
43.69 -
43.70 - public ExamplesList(Iterable<? extends T> data, DialogDescription<T> convertor, Class<T> dataClass, Set<Option> require, Set<Option> forbidden) {
43.71 - this.convertor = convertor;
43.72 - this.dataClass = dataClass;
43.73 -
43.74 - initComponents();
43.75 -
43.76 - DefaultListModel listModel = new DefaultListModel();
43.77 -
43.78 - for (T t : data) {
43.79 - Set<Option> options = convertor.getOptions(t);
43.80 - if (!options.containsAll(require)) continue;
43.81 - if (!Collections.disjoint(options, forbidden)) continue;
43.82 -
43.83 - listModel.addElement(t);
43.84 - }
43.85 -
43.86 - list.setModel(listModel);
43.87 - list.setCellRenderer(new ExamplesRenderer());
43.88 - list.setSelectedIndex(0);
43.89 - }
43.90 -
43.91 - /** This method is called from within the constructor to
43.92 - * initialize the form.
43.93 - * WARNING: Do NOT modify this code. The content of this method is
43.94 - * always regenerated by the Form Editor.
43.95 - */
43.96 - @SuppressWarnings("unchecked")
43.97 - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
43.98 - private void initComponents() {
43.99 -
43.100 - jLabel1 = new javax.swing.JLabel();
43.101 - jScrollPane1 = new javax.swing.JScrollPane();
43.102 - list = new javax.swing.JList();
43.103 - jScrollPane2 = new javax.swing.JScrollPane();
43.104 - pattern = new javax.swing.JEditorPane();
43.105 -
43.106 - jLabel1.setText(convertor.getHeader());
43.107 -
43.108 - list.setModel(new javax.swing.AbstractListModel() {
43.109 - String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
43.110 - public int getSize() { return strings.length; }
43.111 - public Object getElementAt(int i) { return strings[i]; }
43.112 - });
43.113 - list.addMouseListener(new java.awt.event.MouseAdapter() {
43.114 - public void mouseClicked(java.awt.event.MouseEvent evt) {
43.115 - listMouseClicked(evt);
43.116 - }
43.117 - });
43.118 - list.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
43.119 - public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
43.120 - listValueChanged(evt);
43.121 - }
43.122 - });
43.123 - jScrollPane1.setViewportView(list);
43.124 -
43.125 - pattern.setContentType(org.openide.util.NbBundle.getMessage(ExamplesList.class, "ExamplesList.pattern.contentType")); // NOI18N
43.126 - jScrollPane2.setViewportView(pattern);
43.127 -
43.128 - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
43.129 - this.setLayout(layout);
43.130 - layout.setHorizontalGroup(
43.131 - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
43.132 - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
43.133 - .addContainerGap()
43.134 - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
43.135 - .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
43.136 - .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
43.137 - .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING))
43.138 - .addContainerGap())
43.139 - );
43.140 - layout.setVerticalGroup(
43.141 - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
43.142 - .addGroup(layout.createSequentialGroup()
43.143 - .addContainerGap()
43.144 - .addComponent(jLabel1)
43.145 - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
43.146 - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE)
43.147 - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
43.148 - .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
43.149 - .addContainerGap())
43.150 - );
43.151 - }// </editor-fold>//GEN-END:initComponents
43.152 -
43.153 - private void listMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_listMouseClicked
43.154 - if (evt.getClickCount() > 1) {
43.155 - desc.setValue(DialogDescriptor.OK_OPTION);
43.156 - dialog.setVisible(false);
43.157 - }
43.158 - }//GEN-LAST:event_listMouseClicked
43.159 -
43.160 - private void listValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_listValueChanged
43.161 - T ex = dataClass.cast(list.getSelectedValue());
43.162 -
43.163 - pattern.setText(convertor.getCode(ex));
43.164 -
43.165 - try {
43.166 - Rectangle rect = pattern.modelToView(0);
43.167 -
43.168 - if (rect != null) {
43.169 - pattern.scrollRectToVisible(rect);
43.170 - }
43.171 - } catch (BadLocationException ex1) {
43.172 - Exceptions.printStackTrace(ex1);
43.173 - }
43.174 - }//GEN-LAST:event_listValueChanged
43.175 -
43.176 - // Variables declaration - do not modify//GEN-BEGIN:variables
43.177 - private javax.swing.JLabel jLabel1;
43.178 - private javax.swing.JScrollPane jScrollPane1;
43.179 - private javax.swing.JScrollPane jScrollPane2;
43.180 - private javax.swing.JList list;
43.181 - private javax.swing.JEditorPane pattern;
43.182 - // End of variables declaration//GEN-END:variables
43.183 -
43.184 - private DialogDescriptor desc;
43.185 - private Dialog dialog;
43.186 -
43.187 - public void setDialog(DialogDescriptor desc, Dialog dialog) {
43.188 - this.desc = desc;
43.189 - this.dialog = dialog;
43.190 - }
43.191 -
43.192 - public T getSelectedExample() {
43.193 - return dataClass.cast(list.getSelectedValue());
43.194 - }
43.195 -
43.196 - private class ExamplesRenderer extends DefaultListCellRenderer {
43.197 - @Override
43.198 - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
43.199 - value = convertor.getDisplayName(dataClass.cast(value));
43.200 - return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
43.201 - }
43.202 - }
43.203 -
43.204 - public static <T> T chooseExample(Iterable<? extends T> examplesList, DialogDescription<T> convertor, Class<T> dataClass, Set<Option> require, Set<Option> forbidden) {
43.205 - ExamplesList<T> examples = new ExamplesList<T>(examplesList, convertor, dataClass, require, forbidden);
43.206 - DialogDescriptor dd = new DialogDescriptor(examples, convertor.getCaption(), true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, null);
43.207 - Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
43.208 -
43.209 - examples.setDialog(dd, dialog);
43.210 - dialog.setVisible(true);
43.211 -
43.212 - if (dd.getValue() == DialogDescriptor.OK_OPTION) {
43.213 - return examples.getSelectedExample();
43.214 - }
43.215 -
43.216 - return null;
43.217 - }
43.218 -
43.219 - public interface DialogDescription<T> {
43.220 - public String getCaption();
43.221 - public String getHeader();
43.222 - public String getDisplayName(T t);
43.223 - public String getCode(T t);
43.224 - public Set<Option> getOptions(T t);
43.225 - }
43.226 -}
44.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/FindDuplicatesRefactoring.java Fri Jan 27 13:35:56 2012 +0100
44.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
44.3 @@ -1,87 +0,0 @@
44.4 -/*
44.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
44.6 - *
44.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
44.8 - *
44.9 - * The contents of this file are subject to the terms of either the GNU
44.10 - * General Public License Version 2 only ("GPL") or the Common
44.11 - * Development and Distribution License("CDDL") (collectively, the
44.12 - * "License"). You may not use this file except in compliance with the
44.13 - * License. You can obtain a copy of the License at
44.14 - * http://www.netbeans.org/cddl-gplv2.html
44.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
44.16 - * specific language governing permissions and limitations under the
44.17 - * License. When distributing the software, include this License Header
44.18 - * Notice in each file and include the License file at
44.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
44.20 - * particular file as subject to the "Classpath" exception as provided
44.21 - * by Sun in the GPL Version 2 section of the License file that
44.22 - * accompanied this code. If applicable, add the following below the
44.23 - * License Header, with the fields enclosed by brackets [] replaced by
44.24 - * your own identifying information:
44.25 - * "Portions Copyrighted [year] [name of copyright owner]"
44.26 - *
44.27 - * If you wish your version of this file to be governed by only the CDDL
44.28 - * or only the GPL Version 2, indicate your decision by adding
44.29 - * "[Contributor] elects to include this software in this distribution
44.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
44.31 - * single choice of license, a recipient has the option to distribute
44.32 - * your version of this file under either the CDDL, the GPL Version 2 or
44.33 - * to extend the choice of license to its licensees as provided above.
44.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
44.35 - * Version 2 license, then the option applies only if the new code is
44.36 - * made subject to such option by the copyright holder.
44.37 - *
44.38 - * Contributor(s):
44.39 - *
44.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
44.41 - */
44.42 -
44.43 -package org.netbeans.modules.jackpot30.impl.refactoring;
44.44 -
44.45 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.Scope;
44.46 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
44.47 -import org.netbeans.modules.refactoring.api.AbstractRefactoring;
44.48 -import org.openide.util.Lookup;
44.49 -
44.50 -public class FindDuplicatesRefactoring extends AbstractRefactoring {
44.51 -
44.52 - private final boolean query;
44.53 - private Iterable<? extends HintDescription> patterns;
44.54 - private Scope scope;
44.55 - private boolean verify;
44.56 -
44.57 - public FindDuplicatesRefactoring(boolean query) {
44.58 - super(Lookup.EMPTY);
44.59 - this.query = query;
44.60 - }
44.61 -
44.62 - public boolean isQuery() {
44.63 - return query;
44.64 - }
44.65 -
44.66 - public synchronized Iterable<? extends HintDescription> getPattern() {
44.67 - return patterns;
44.68 - }
44.69 -
44.70 - public synchronized void setPattern(Iterable<? extends HintDescription> patterns) {
44.71 - this.patterns = patterns;
44.72 - }
44.73 -
44.74 - public synchronized Scope getScope() {
44.75 - return scope;
44.76 - }
44.77 -
44.78 - public synchronized void setScope(Scope scope) {
44.79 - this.scope = scope;
44.80 - }
44.81 -
44.82 - public boolean isVerify() {
44.83 - return verify;
44.84 - }
44.85 -
44.86 - public void setVerify(boolean verify) {
44.87 - this.verify = verify;
44.88 - }
44.89 -
44.90 -}
45.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/FindDuplicatesRefactoringPanel.form Fri Jan 27 13:35:56 2012 +0100
45.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
45.3 @@ -1,358 +0,0 @@
45.4 -<?xml version="1.0" encoding="UTF-8" ?>
45.5 -
45.6 -<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
45.7 - <NonVisualComponents>
45.8 - <Component class="javax.swing.ButtonGroup" name="main">
45.9 - </Component>
45.10 - </NonVisualComponents>
45.11 - <AuxValues>
45.12 - <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
45.13 - <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
45.14 - <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
45.15 - <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
45.16 - <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
45.17 - <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
45.18 - <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
45.19 - <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
45.20 - <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
45.21 - <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,43,0,0,2,64"/>
45.22 - </AuxValues>
45.23 -
45.24 - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
45.25 - <SubComponents>
45.26 - <Component class="javax.swing.JCheckBox" name="verify">
45.27 - <Properties>
45.28 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
45.29 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="FindDuplicatesRefactoringPanel.verify.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
45.30 - </Property>
45.31 - </Properties>
45.32 - <Constraints>
45.33 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45.34 - <GridBagConstraints gridX="0" gridY="3" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="18" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="0.0"/>
45.35 - </Constraint>
45.36 - </Constraints>
45.37 - </Component>
45.38 - <Container class="javax.swing.JPanel" name="patternSelection">
45.39 - <Constraints>
45.40 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45.41 - <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="1.0"/>
45.42 - </Constraint>
45.43 - </Constraints>
45.44 -
45.45 - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignCardLayout"/>
45.46 - <SubComponents>
45.47 - <Container class="javax.swing.JPanel" name="knownPatternsPanel">
45.48 - <AuxValues>
45.49 - <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,2,8"/>
45.50 - </AuxValues>
45.51 - <Constraints>
45.52 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription">
45.53 - <CardConstraints cardName="knownPatterns"/>
45.54 - </Constraint>
45.55 - </Constraints>
45.56 -
45.57 - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
45.58 - <SubComponents>
45.59 - <Component class="javax.swing.JLabel" name="allHintsLabel">
45.60 - <Properties>
45.61 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
45.62 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="FindDuplicatesRefactoringPanel.allHintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
45.63 - </Property>
45.64 - </Properties>
45.65 - <Constraints>
45.66 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45.67 - <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/>
45.68 - </Constraint>
45.69 - </Constraints>
45.70 - </Component>
45.71 - <Container class="javax.swing.JScrollPane" name="jScrollPane2">
45.72 - <AuxValues>
45.73 - <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
45.74 - </AuxValues>
45.75 - <Constraints>
45.76 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45.77 - <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.5" weightY="1.0"/>
45.78 - </Constraint>
45.79 - </Constraints>
45.80 -
45.81 - <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
45.82 - <SubComponents>
45.83 - <Component class="javax.swing.JList" name="allHints">
45.84 - <Properties>
45.85 - <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
45.86 - <StringArray count="5">
45.87 - <StringItem index="0" value="Item 1"/>
45.88 - <StringItem index="1" value="Item 2"/>
45.89 - <StringItem index="2" value="Item 3"/>
45.90 - <StringItem index="3" value="Item 4"/>
45.91 - <StringItem index="4" value="Item 5"/>
45.92 - </StringArray>
45.93 - </Property>
45.94 - <Property name="prototypeCellValue" type="java.lang.Object" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
45.95 - <Connection code="HINTS_LIST_PROTOTYPE" type="code"/>
45.96 - </Property>
45.97 - <Property name="visibleRowCount" type="int" value="24"/>
45.98 - </Properties>
45.99 - </Component>
45.100 - </SubComponents>
45.101 - </Container>
45.102 - <Container class="javax.swing.JScrollPane" name="jScrollPane3">
45.103 - <AuxValues>
45.104 - <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
45.105 - </AuxValues>
45.106 - <Constraints>
45.107 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45.108 - <GridBagConstraints gridX="2" gridY="1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="6" insetsBottom="0" insetsRight="0" anchor="18" weightX="0.5" weightY="1.0"/>
45.109 - </Constraint>
45.110 - </Constraints>
45.111 -
45.112 - <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
45.113 - <SubComponents>
45.114 - <Component class="javax.swing.JList" name="selectedHints">
45.115 - <Properties>
45.116 - <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
45.117 - <StringArray count="5">
45.118 - <StringItem index="0" value="Item 1"/>
45.119 - <StringItem index="1" value="Item 2"/>
45.120 - <StringItem index="2" value="Item 3"/>
45.121 - <StringItem index="3" value="Item 4"/>
45.122 - <StringItem index="4" value="Item 5"/>
45.123 - </StringArray>
45.124 - </Property>
45.125 - <Property name="prototypeCellValue" type="java.lang.Object" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
45.126 - <Connection code="HINTS_LIST_PROTOTYPE" type="code"/>
45.127 - </Property>
45.128 - <Property name="visibleRowCount" type="int" value="24"/>
45.129 - </Properties>
45.130 - </Component>
45.131 - </SubComponents>
45.132 - </Container>
45.133 - <Component class="javax.swing.JLabel" name="selectedHintsLabel">
45.134 - <Properties>
45.135 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
45.136 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="FindDuplicatesRefactoringPanel.selectedHintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
45.137 - </Property>
45.138 - </Properties>
45.139 - <Constraints>
45.140 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45.141 - <GridBagConstraints gridX="2" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="6" insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
45.142 - </Constraint>
45.143 - </Constraints>
45.144 - </Component>
45.145 - <Container class="javax.swing.JPanel" name="jPanel2">
45.146 - <Constraints>
45.147 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45.148 - <GridBagConstraints gridX="1" gridY="1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="6" insetsBottom="0" insetsRight="5" anchor="10" weightX="0.0" weightY="1.0"/>
45.149 - </Constraint>
45.150 - </Constraints>
45.151 -
45.152 - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
45.153 - <SubComponents>
45.154 - <Component class="javax.swing.JButton" name="addHint">
45.155 - <Properties>
45.156 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
45.157 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="FindDuplicatesRefactoringPanel.addHint.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
45.158 - </Property>
45.159 - </Properties>
45.160 - <Events>
45.161 - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addHintActionPerformed"/>
45.162 - </Events>
45.163 - <Constraints>
45.164 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45.165 - <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="6" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
45.166 - </Constraint>
45.167 - </Constraints>
45.168 - </Component>
45.169 - <Component class="javax.swing.JButton" name="addAllHints">
45.170 - <Properties>
45.171 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
45.172 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="FindDuplicatesRefactoringPanel.addAllHints.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
45.173 - </Property>
45.174 - </Properties>
45.175 - <Events>
45.176 - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addAllHintsActionPerformed"/>
45.177 - </Events>
45.178 - <Constraints>
45.179 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45.180 - <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="6" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
45.181 - </Constraint>
45.182 - </Constraints>
45.183 - </Component>
45.184 - <Component class="javax.swing.JButton" name="removeHint">
45.185 - <Properties>
45.186 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
45.187 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="FindDuplicatesRefactoringPanel.removeHint.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
45.188 - </Property>
45.189 - </Properties>
45.190 - <Events>
45.191 - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="removeHintActionPerformed"/>
45.192 - </Events>
45.193 - <Constraints>
45.194 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45.195 - <GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="6" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
45.196 - </Constraint>
45.197 - </Constraints>
45.198 - </Component>
45.199 - <Component class="javax.swing.JButton" name="removeAllHints">
45.200 - <Properties>
45.201 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
45.202 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="FindDuplicatesRefactoringPanel.removeAllHints.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
45.203 - </Property>
45.204 - </Properties>
45.205 - <Events>
45.206 - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="removeAllHintsActionPerformed"/>
45.207 - </Events>
45.208 - <Constraints>
45.209 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45.210 - <GridBagConstraints gridX="0" gridY="3" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
45.211 - </Constraint>
45.212 - </Constraints>
45.213 - </Component>
45.214 - </SubComponents>
45.215 - </Container>
45.216 - </SubComponents>
45.217 - </Container>
45.218 - <Container class="javax.swing.JPanel" name="customPatternPanel">
45.219 - <Constraints>
45.220 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription">
45.221 - <CardConstraints cardName="customPattern"/>
45.222 - </Constraint>
45.223 - </Constraints>
45.224 -
45.225 - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
45.226 - <SubComponents>
45.227 - <Container class="javax.swing.JPanel" name="jPanel3">
45.228 - <Constraints>
45.229 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45.230 - <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="3" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="13" weightX="0.0" weightY="0.0"/>
45.231 - </Constraint>
45.232 - </Constraints>
45.233 -
45.234 - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
45.235 - <Property name="horizontalGap" type="int" value="0"/>
45.236 - </Layout>
45.237 - <SubComponents>
45.238 - <Component class="javax.swing.JButton" name="recentButton">
45.239 - <Properties>
45.240 - <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
45.241 - <Image iconType="3" name="/org/netbeans/modules/jackpot30/impl/resources/recent_icon.png"/>
45.242 - </Property>
45.243 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
45.244 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="FindDuplicatesRefactoringPanel.recentButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
45.245 - </Property>
45.246 - <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
45.247 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="FindDuplicatesRefactoringPanel.recentButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
45.248 - </Property>
45.249 - <Property name="borderPainted" type="boolean" value="false"/>
45.250 - <Property name="contentAreaFilled" type="boolean" value="false"/>
45.251 - </Properties>
45.252 - <Events>
45.253 - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="recentButtonActionPerformed"/>
45.254 - </Events>
45.255 - </Component>
45.256 - <Component class="javax.swing.JButton" name="examplesButton">
45.257 - <Properties>
45.258 - <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
45.259 - <Image iconType="3" name="/org/netbeans/modules/jackpot30/impl/resources/examples_icon.png"/>
45.260 - </Property>
45.261 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
45.262 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="FindDuplicatesRefactoringPanel.examplesButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
45.263 - </Property>
45.264 - <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
45.265 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="BTN_Examples" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
45.266 - </Property>
45.267 - <Property name="borderPainted" type="boolean" value="false"/>
45.268 - <Property name="contentAreaFilled" type="boolean" value="false"/>
45.269 - </Properties>
45.270 - <Events>
45.271 - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="examplesButtonActionPerformed"/>
45.272 - </Events>
45.273 - </Component>
45.274 - </SubComponents>
45.275 - </Container>
45.276 - <Container class="javax.swing.JScrollPane" name="jScrollPane4">
45.277 - <AuxValues>
45.278 - <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
45.279 - </AuxValues>
45.280 - <Constraints>
45.281 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45.282 - <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="1.0"/>
45.283 - </Constraint>
45.284 - </Constraints>
45.285 -
45.286 - <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
45.287 - <SubComponents>
45.288 - <Component class="javax.swing.JEditorPane" name="pattern">
45.289 - </Component>
45.290 - </SubComponents>
45.291 - </Container>
45.292 - </SubComponents>
45.293 - </Container>
45.294 - </SubComponents>
45.295 - </Container>
45.296 - <Container class="javax.swing.JPanel" name="patternTypeSelectionPanel">
45.297 - <Constraints>
45.298 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45.299 - <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="0.0"/>
45.300 - </Constraint>
45.301 - </Constraints>
45.302 -
45.303 - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
45.304 - <SubComponents>
45.305 - <Component class="javax.swing.JRadioButton" name="knowPatterns">
45.306 - <Properties>
45.307 - <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
45.308 - <ComponentRef name="main"/>
45.309 - </Property>
45.310 - <Property name="selected" type="boolean" value="true"/>
45.311 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
45.312 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="FindDuplicatesRefactoringPanel.knowPatterns.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
45.313 - </Property>
45.314 - </Properties>
45.315 - <Events>
45.316 - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="knowPatternsActionPerformed"/>
45.317 - </Events>
45.318 - <Constraints>
45.319 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45.320 - <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
45.321 - </Constraint>
45.322 - </Constraints>
45.323 - </Component>
45.324 - <Component class="javax.swing.JRadioButton" name="customPattern">
45.325 - <Properties>
45.326 - <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
45.327 - <ComponentRef name="main"/>
45.328 - </Property>
45.329 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
45.330 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="FindDuplicatesRefactoringPanel.customPattern.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
45.331 - </Property>
45.332 - </Properties>
45.333 - <Events>
45.334 - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="customPatternActionPerformed"/>
45.335 - </Events>
45.336 - <Constraints>
45.337 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45.338 - <GridBagConstraints gridX="1" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="24" insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
45.339 - </Constraint>
45.340 - </Constraints>
45.341 - </Component>
45.342 - <Container class="javax.swing.JPanel" name="jPanel1">
45.343 - <Constraints>
45.344 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45.345 - <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="0.0"/>
45.346 - </Constraint>
45.347 - </Constraints>
45.348 -
45.349 - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
45.350 - </Container>
45.351 - </SubComponents>
45.352 - </Container>
45.353 - <Component class="org.netbeans.modules.jackpot30.impl.refactoring.ScopesPanel" name="scopesPanel">
45.354 - <Constraints>
45.355 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45.356 - <GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="18" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="0.0"/>
45.357 - </Constraint>
45.358 - </Constraints>
45.359 - </Component>
45.360 - </SubComponents>
45.361 -</Form>
46.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/FindDuplicatesRefactoringPanel.java Fri Jan 27 13:35:56 2012 +0100
46.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
46.3 @@ -1,723 +0,0 @@
46.4 -/*
46.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
46.6 - *
46.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
46.8 - *
46.9 - * The contents of this file are subject to the terms of either the GNU
46.10 - * General Public License Version 2 only ("GPL") or the Common
46.11 - * Development and Distribution License("CDDL") (collectively, the
46.12 - * "License"). You may not use this file except in compliance with the
46.13 - * License. You can obtain a copy of the License at
46.14 - * http://www.netbeans.org/cddl-gplv2.html
46.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
46.16 - * specific language governing permissions and limitations under the
46.17 - * License. When distributing the software, include this License Header
46.18 - * Notice in each file and include the License file at
46.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
46.20 - * particular file as subject to the "Classpath" exception as provided
46.21 - * by Sun in the GPL Version 2 section of the License file that
46.22 - * accompanied this code. If applicable, add the following below the
46.23 - * License Header, with the fields enclosed by brackets [] replaced by
46.24 - * your own identifying information:
46.25 - * "Portions Copyrighted [year] [name of copyright owner]"
46.26 - *
46.27 - * If you wish your version of this file to be governed by only the CDDL
46.28 - * or only the GPL Version 2, indicate your decision by adding
46.29 - * "[Contributor] elects to include this software in this distribution
46.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
46.31 - * single choice of license, a recipient has the option to distribute
46.32 - * your version of this file under either the CDDL, the GPL Version 2 or
46.33 - * to extend the choice of license to its licensees as provided above.
46.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
46.35 - * Version 2 license, then the option applies only if the new code is
46.36 - * made subject to such option by the copyright holder.
46.37 - *
46.38 - * Contributor(s):
46.39 - *
46.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
46.41 - */
46.42 -
46.43 -package org.netbeans.modules.jackpot30.impl.refactoring;
46.44 -
46.45 -import java.awt.CardLayout;
46.46 -import java.awt.event.KeyEvent;
46.47 -import java.awt.event.KeyListener;
46.48 -import java.io.IOException;
46.49 -import java.util.Collection;
46.50 -import java.util.Collections;
46.51 -import java.util.EnumSet;
46.52 -import java.util.HashSet;
46.53 -import java.util.LinkedList;
46.54 -import java.util.List;
46.55 -import java.util.Map;
46.56 -import java.util.Set;
46.57 -import java.util.TreeMap;
46.58 -import java.util.logging.Level;
46.59 -import java.util.logging.Logger;
46.60 -import java.util.prefs.BackingStoreException;
46.61 -import java.util.prefs.Preferences;
46.62 -import javax.swing.DefaultListModel;
46.63 -import javax.swing.SwingUtilities;
46.64 -import javax.swing.event.ChangeEvent;
46.65 -import javax.swing.event.ChangeListener;
46.66 -import javax.swing.event.DocumentEvent;
46.67 -import javax.swing.event.DocumentListener;
46.68 -import javax.swing.text.Document;
46.69 -import org.netbeans.api.java.classpath.ClassPath;
46.70 -import org.netbeans.api.java.classpath.GlobalPathRegistry;
46.71 -import org.netbeans.modules.editor.NbEditorUtilities;
46.72 -import org.netbeans.modules.jackpot30.impl.examples.Example;
46.73 -import org.netbeans.modules.jackpot30.impl.examples.Example.Option;
46.74 -import org.netbeans.modules.jackpot30.impl.examples.LoadExamples;
46.75 -import org.netbeans.modules.jackpot30.impl.refactoring.ExamplesList.DialogDescription;
46.76 -import org.netbeans.modules.java.hints.jackpot.impl.Utilities;
46.77 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.Scope;
46.78 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
46.79 -import org.openide.cookies.EditorCookie;
46.80 -import org.openide.cookies.SaveCookie;
46.81 -import org.openide.filesystems.FileObject;
46.82 -import org.openide.filesystems.FileUtil;
46.83 -import org.openide.loaders.DataObject;
46.84 -import org.openide.util.Exceptions;
46.85 -import org.openide.util.NbPreferences;
46.86 -import org.openide.util.Union2;
46.87 -
46.88 -/**
46.89 - *
46.90 - * @author lahvac
46.91 - */
46.92 -public class FindDuplicatesRefactoringPanel extends javax.swing.JPanel {
46.93 -
46.94 - private final Map<String, Collection<HintDescription>> displayName2Hints;
46.95 - private final ChangeListener changeListener;
46.96 - private final boolean query;
46.97 -
46.98 - public FindDuplicatesRefactoringPanel(final ChangeListener parent, boolean query) {
46.99 - this.changeListener = parent;
46.100 - this.query = query;
46.101 -
46.102 - Set<ClassPath> cps = new HashSet<ClassPath>();
46.103 -
46.104 - cps.addAll(GlobalPathRegistry.getDefault().getPaths(ClassPath.BOOT));
46.105 - cps.addAll(GlobalPathRegistry.getDefault().getPaths(ClassPath.COMPILE));
46.106 - cps.addAll(GlobalPathRegistry.getDefault().getPaths(ClassPath.SOURCE));
46.107 -
46.108 - Collection<? extends HintDescription> hints = Utilities.listAllHints(cps);
46.109 -
46.110 - displayName2Hints = Utilities.sortOutHints(hints, new TreeMap<String, Collection<HintDescription>>());
46.111 -
46.112 - initComponents();
46.113 -
46.114 - DefaultListModel all = new DefaultListModel();
46.115 - DefaultListModel selected = new DefaultListModel();
46.116 -
46.117 - for (String dn : displayName2Hints.keySet()) {
46.118 - all.addElement(dn);
46.119 - }
46.120 -
46.121 - allHints.setModel(all);
46.122 - selectedHints.setModel(selected);
46.123 - DocumentListener dl = new DocumentListener() {
46.124 - public void insertUpdate(DocumentEvent e) {
46.125 - stateChanged();
46.126 - }
46.127 - public void removeUpdate(DocumentEvent e) {
46.128 - stateChanged();
46.129 - }
46.130 - public void changedUpdate(DocumentEvent e) {}
46.131 - };
46.132 -
46.133 - try {
46.134 - FileObject dummy = FileUtil.createMemoryFileSystem().getRoot().createData("dummy.hint");
46.135 - DataObject od = DataObject.find(dummy);
46.136 - EditorCookie ec = od.getLookup().lookup(EditorCookie.class);
46.137 - Document doc = ec.openDocument();
46.138 - pattern.setContentType("text/x-javahints");
46.139 - pattern.setDocument(doc);
46.140 - } catch (Exception e) {
46.141 - Logger.getLogger(FindDuplicatesRefactoringPanel.class.getName()).log(Level.FINE, null, e);
46.142 - }
46.143 -
46.144 - pattern.getDocument().addDocumentListener(dl);
46.145 - //do not close the dialog on esc:
46.146 - pattern.addKeyListener(new KeyListener() {
46.147 - public void keyTyped(KeyEvent e) {}
46.148 - public void keyPressed(KeyEvent e) {
46.149 - keyReleased(e);
46.150 - }
46.151 - public void keyReleased(KeyEvent e) {
46.152 - if (e.getKeyCode() == KeyEvent.VK_ESCAPE && e.getModifiersEx() == 0) {
46.153 - e.consume();
46.154 - }
46.155 - }
46.156 - });
46.157 -
46.158 - if (!query) {
46.159 - verify.setVisible(false);
46.160 - }
46.161 -
46.162 - scopesPanel.setChangeListener(changeListener);
46.163 -
46.164 - enableDisable();
46.165 - }
46.166 -
46.167 - /** This method is called from within the constructor to
46.168 - * initialize the form.
46.169 - * WARNING: Do NOT modify this code. The content of this method is
46.170 - * always regenerated by the Form Editor.
46.171 - */
46.172 - @SuppressWarnings("unchecked")
46.173 - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
46.174 - private void initComponents() {
46.175 - java.awt.GridBagConstraints gridBagConstraints;
46.176 -
46.177 - main = new javax.swing.ButtonGroup();
46.178 - verify = new javax.swing.JCheckBox();
46.179 - patternSelection = new javax.swing.JPanel();
46.180 - knownPatternsPanel = new javax.swing.JPanel();
46.181 - allHintsLabel = new javax.swing.JLabel();
46.182 - jScrollPane2 = new javax.swing.JScrollPane();
46.183 - allHints = new javax.swing.JList();
46.184 - jScrollPane3 = new javax.swing.JScrollPane();
46.185 - selectedHints = new javax.swing.JList();
46.186 - selectedHintsLabel = new javax.swing.JLabel();
46.187 - jPanel2 = new javax.swing.JPanel();
46.188 - addHint = new javax.swing.JButton();
46.189 - addAllHints = new javax.swing.JButton();
46.190 - removeHint = new javax.swing.JButton();
46.191 - removeAllHints = new javax.swing.JButton();
46.192 - customPatternPanel = new javax.swing.JPanel();
46.193 - jPanel3 = new javax.swing.JPanel();
46.194 - recentButton = new javax.swing.JButton();
46.195 - examplesButton = new javax.swing.JButton();
46.196 - jScrollPane4 = new javax.swing.JScrollPane();
46.197 - pattern = new javax.swing.JEditorPane();
46.198 - patternTypeSelectionPanel = new javax.swing.JPanel();
46.199 - knowPatterns = new javax.swing.JRadioButton();
46.200 - customPattern = new javax.swing.JRadioButton();
46.201 - jPanel1 = new javax.swing.JPanel();
46.202 - scopesPanel = new org.netbeans.modules.jackpot30.impl.refactoring.ScopesPanel();
46.203 -
46.204 - setLayout(new java.awt.GridBagLayout());
46.205 -
46.206 - org.openide.awt.Mnemonics.setLocalizedText(verify, org.openide.util.NbBundle.getMessage(FindDuplicatesRefactoringPanel.class, "FindDuplicatesRefactoringPanel.verify.text")); // NOI18N
46.207 - gridBagConstraints = new java.awt.GridBagConstraints();
46.208 - gridBagConstraints.gridx = 0;
46.209 - gridBagConstraints.gridy = 3;
46.210 - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
46.211 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
46.212 - gridBagConstraints.weightx = 1.0;
46.213 - gridBagConstraints.insets = new java.awt.Insets(18, 0, 0, 0);
46.214 - add(verify, gridBagConstraints);
46.215 -
46.216 - patternSelection.setLayout(new java.awt.CardLayout());
46.217 -
46.218 - knownPatternsPanel.setLayout(new java.awt.GridBagLayout());
46.219 -
46.220 - org.openide.awt.Mnemonics.setLocalizedText(allHintsLabel, org.openide.util.NbBundle.getMessage(FindDuplicatesRefactoringPanel.class, "FindDuplicatesRefactoringPanel.allHintsLabel.text")); // NOI18N
46.221 - gridBagConstraints = new java.awt.GridBagConstraints();
46.222 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
46.223 - gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 6);
46.224 - knownPatternsPanel.add(allHintsLabel, gridBagConstraints);
46.225 -
46.226 - allHints.setModel(new javax.swing.AbstractListModel() {
46.227 - String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
46.228 - public int getSize() { return strings.length; }
46.229 - public Object getElementAt(int i) { return strings[i]; }
46.230 - });
46.231 - allHints.setPrototypeCellValue(HINTS_LIST_PROTOTYPE);
46.232 - allHints.setVisibleRowCount(24);
46.233 - jScrollPane2.setViewportView(allHints);
46.234 -
46.235 - gridBagConstraints = new java.awt.GridBagConstraints();
46.236 - gridBagConstraints.gridx = 0;
46.237 - gridBagConstraints.gridy = 1;
46.238 - gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
46.239 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
46.240 - gridBagConstraints.weightx = 0.5;
46.241 - gridBagConstraints.weighty = 1.0;
46.242 - gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 6);
46.243 - knownPatternsPanel.add(jScrollPane2, gridBagConstraints);
46.244 -
46.245 - selectedHints.setModel(new javax.swing.AbstractListModel() {
46.246 - String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
46.247 - public int getSize() { return strings.length; }
46.248 - public Object getElementAt(int i) { return strings[i]; }
46.249 - });
46.250 - selectedHints.setPrototypeCellValue(HINTS_LIST_PROTOTYPE);
46.251 - selectedHints.setVisibleRowCount(24);
46.252 - jScrollPane3.setViewportView(selectedHints);
46.253 -
46.254 - gridBagConstraints = new java.awt.GridBagConstraints();
46.255 - gridBagConstraints.gridx = 2;
46.256 - gridBagConstraints.gridy = 1;
46.257 - gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
46.258 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
46.259 - gridBagConstraints.weightx = 0.5;
46.260 - gridBagConstraints.weighty = 1.0;
46.261 - gridBagConstraints.insets = new java.awt.Insets(6, 6, 0, 0);
46.262 - knownPatternsPanel.add(jScrollPane3, gridBagConstraints);
46.263 -
46.264 - org.openide.awt.Mnemonics.setLocalizedText(selectedHintsLabel, org.openide.util.NbBundle.getMessage(FindDuplicatesRefactoringPanel.class, "FindDuplicatesRefactoringPanel.selectedHintsLabel.text")); // NOI18N
46.265 - gridBagConstraints = new java.awt.GridBagConstraints();
46.266 - gridBagConstraints.gridx = 2;
46.267 - gridBagConstraints.gridy = 0;
46.268 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
46.269 - gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0);
46.270 - knownPatternsPanel.add(selectedHintsLabel, gridBagConstraints);
46.271 -
46.272 - jPanel2.setLayout(new java.awt.GridBagLayout());
46.273 -
46.274 - org.openide.awt.Mnemonics.setLocalizedText(addHint, org.openide.util.NbBundle.getMessage(FindDuplicatesRefactoringPanel.class, "FindDuplicatesRefactoringPanel.addHint.text")); // NOI18N
46.275 - addHint.addActionListener(new java.awt.event.ActionListener() {
46.276 - public void actionPerformed(java.awt.event.ActionEvent evt) {
46.277 - addHintActionPerformed(evt);
46.278 - }
46.279 - });
46.280 - gridBagConstraints = new java.awt.GridBagConstraints();
46.281 - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
46.282 - gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 0);
46.283 - jPanel2.add(addHint, gridBagConstraints);
46.284 -
46.285 - org.openide.awt.Mnemonics.setLocalizedText(addAllHints, org.openide.util.NbBundle.getMessage(FindDuplicatesRefactoringPanel.class, "FindDuplicatesRefactoringPanel.addAllHints.text")); // NOI18N
46.286 - addAllHints.addActionListener(new java.awt.event.ActionListener() {
46.287 - public void actionPerformed(java.awt.event.ActionEvent evt) {
46.288 - addAllHintsActionPerformed(evt);
46.289 - }
46.290 - });
46.291 - gridBagConstraints = new java.awt.GridBagConstraints();
46.292 - gridBagConstraints.gridx = 0;
46.293 - gridBagConstraints.gridy = 1;
46.294 - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
46.295 - gridBagConstraints.insets = new java.awt.Insets(6, 0, 6, 0);
46.296 - jPanel2.add(addAllHints, gridBagConstraints);
46.297 -
46.298 - org.openide.awt.Mnemonics.setLocalizedText(removeHint, org.openide.util.NbBundle.getMessage(FindDuplicatesRefactoringPanel.class, "FindDuplicatesRefactoringPanel.removeHint.text")); // NOI18N
46.299 - removeHint.addActionListener(new java.awt.event.ActionListener() {
46.300 - public void actionPerformed(java.awt.event.ActionEvent evt) {
46.301 - removeHintActionPerformed(evt);
46.302 - }
46.303 - });
46.304 - gridBagConstraints = new java.awt.GridBagConstraints();
46.305 - gridBagConstraints.gridx = 0;
46.306 - gridBagConstraints.gridy = 2;
46.307 - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
46.308 - gridBagConstraints.insets = new java.awt.Insets(6, 0, 6, 0);
46.309 - jPanel2.add(removeHint, gridBagConstraints);
46.310 -
46.311 - org.openide.awt.Mnemonics.setLocalizedText(removeAllHints, org.openide.util.NbBundle.getMessage(FindDuplicatesRefactoringPanel.class, "FindDuplicatesRefactoringPanel.removeAllHints.text")); // NOI18N
46.312 - removeAllHints.addActionListener(new java.awt.event.ActionListener() {
46.313 - public void actionPerformed(java.awt.event.ActionEvent evt) {
46.314 - removeAllHintsActionPerformed(evt);
46.315 - }
46.316 - });
46.317 - gridBagConstraints = new java.awt.GridBagConstraints();
46.318 - gridBagConstraints.gridx = 0;
46.319 - gridBagConstraints.gridy = 3;
46.320 - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
46.321 - gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
46.322 - jPanel2.add(removeAllHints, gridBagConstraints);
46.323 -
46.324 - gridBagConstraints = new java.awt.GridBagConstraints();
46.325 - gridBagConstraints.gridx = 1;
46.326 - gridBagConstraints.gridy = 1;
46.327 - gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
46.328 - gridBagConstraints.weighty = 1.0;
46.329 - gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 5);
46.330 - knownPatternsPanel.add(jPanel2, gridBagConstraints);
46.331 -
46.332 - patternSelection.add(knownPatternsPanel, "knownPatterns");
46.333 -
46.334 - customPatternPanel.setLayout(new java.awt.GridBagLayout());
46.335 -
46.336 - jPanel3.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 5));
46.337 -
46.338 - recentButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/jackpot30/impl/resources/recent_icon.png"))); // NOI18N
46.339 - org.openide.awt.Mnemonics.setLocalizedText(recentButton, org.openide.util.NbBundle.getMessage(FindDuplicatesRefactoringPanel.class, "FindDuplicatesRefactoringPanel.recentButton.text")); // NOI18N
46.340 - recentButton.setToolTipText(org.openide.util.NbBundle.getMessage(FindDuplicatesRefactoringPanel.class, "FindDuplicatesRefactoringPanel.recentButton.toolTipText")); // NOI18N
46.341 - recentButton.setBorderPainted(false);
46.342 - recentButton.setContentAreaFilled(false);
46.343 - recentButton.addActionListener(new java.awt.event.ActionListener() {
46.344 - public void actionPerformed(java.awt.event.ActionEvent evt) {
46.345 - recentButtonActionPerformed(evt);
46.346 - }
46.347 - });
46.348 - jPanel3.add(recentButton);
46.349 -
46.350 - examplesButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/jackpot30/impl/resources/examples_icon.png"))); // NOI18N
46.351 - org.openide.awt.Mnemonics.setLocalizedText(examplesButton, org.openide.util.NbBundle.getMessage(FindDuplicatesRefactoringPanel.class, "FindDuplicatesRefactoringPanel.examplesButton.text")); // NOI18N
46.352 - examplesButton.setToolTipText(org.openide.util.NbBundle.getMessage(FindDuplicatesRefactoringPanel.class, "BTN_Examples")); // NOI18N
46.353 - examplesButton.setBorderPainted(false);
46.354 - examplesButton.setContentAreaFilled(false);
46.355 - examplesButton.addActionListener(new java.awt.event.ActionListener() {
46.356 - public void actionPerformed(java.awt.event.ActionEvent evt) {
46.357 - examplesButtonActionPerformed(evt);
46.358 - }
46.359 - });
46.360 - jPanel3.add(examplesButton);
46.361 -
46.362 - gridBagConstraints = new java.awt.GridBagConstraints();
46.363 - gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
46.364 - gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
46.365 - customPatternPanel.add(jPanel3, gridBagConstraints);
46.366 -
46.367 - jScrollPane4.setViewportView(pattern);
46.368 -
46.369 - gridBagConstraints = new java.awt.GridBagConstraints();
46.370 - gridBagConstraints.gridx = 0;
46.371 - gridBagConstraints.gridy = 1;
46.372 - gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
46.373 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
46.374 - gridBagConstraints.weightx = 1.0;
46.375 - gridBagConstraints.weighty = 1.0;
46.376 - customPatternPanel.add(jScrollPane4, gridBagConstraints);
46.377 -
46.378 - patternSelection.add(customPatternPanel, "customPattern");
46.379 -
46.380 - gridBagConstraints = new java.awt.GridBagConstraints();
46.381 - gridBagConstraints.gridx = 0;
46.382 - gridBagConstraints.gridy = 1;
46.383 - gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
46.384 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
46.385 - gridBagConstraints.weightx = 1.0;
46.386 - gridBagConstraints.weighty = 1.0;
46.387 - gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
46.388 - add(patternSelection, gridBagConstraints);
46.389 -
46.390 - patternTypeSelectionPanel.setLayout(new java.awt.GridBagLayout());
46.391 -
46.392 - main.add(knowPatterns);
46.393 - knowPatterns.setSelected(true);
46.394 - org.openide.awt.Mnemonics.setLocalizedText(knowPatterns, org.openide.util.NbBundle.getMessage(FindDuplicatesRefactoringPanel.class, "FindDuplicatesRefactoringPanel.knowPatterns.text")); // NOI18N
46.395 - knowPatterns.addActionListener(new java.awt.event.ActionListener() {
46.396 - public void actionPerformed(java.awt.event.ActionEvent evt) {
46.397 - knowPatternsActionPerformed(evt);
46.398 - }
46.399 - });
46.400 - gridBagConstraints = new java.awt.GridBagConstraints();
46.401 - gridBagConstraints.gridx = 0;
46.402 - gridBagConstraints.gridy = 0;
46.403 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
46.404 - patternTypeSelectionPanel.add(knowPatterns, gridBagConstraints);
46.405 -
46.406 - main.add(customPattern);
46.407 - org.openide.awt.Mnemonics.setLocalizedText(customPattern, org.openide.util.NbBundle.getMessage(FindDuplicatesRefactoringPanel.class, "FindDuplicatesRefactoringPanel.customPattern.text")); // NOI18N
46.408 - customPattern.addActionListener(new java.awt.event.ActionListener() {
46.409 - public void actionPerformed(java.awt.event.ActionEvent evt) {
46.410 - customPatternActionPerformed(evt);
46.411 - }
46.412 - });
46.413 - gridBagConstraints = new java.awt.GridBagConstraints();
46.414 - gridBagConstraints.gridx = 1;
46.415 - gridBagConstraints.gridy = 0;
46.416 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
46.417 - gridBagConstraints.insets = new java.awt.Insets(0, 24, 0, 0);
46.418 - patternTypeSelectionPanel.add(customPattern, gridBagConstraints);
46.419 - gridBagConstraints = new java.awt.GridBagConstraints();
46.420 - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
46.421 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
46.422 - gridBagConstraints.weightx = 1.0;
46.423 - patternTypeSelectionPanel.add(jPanel1, gridBagConstraints);
46.424 -
46.425 - gridBagConstraints = new java.awt.GridBagConstraints();
46.426 - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
46.427 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
46.428 - gridBagConstraints.weightx = 1.0;
46.429 - add(patternTypeSelectionPanel, gridBagConstraints);
46.430 - gridBagConstraints = new java.awt.GridBagConstraints();
46.431 - gridBagConstraints.gridx = 0;
46.432 - gridBagConstraints.gridy = 2;
46.433 - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
46.434 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
46.435 - gridBagConstraints.weightx = 1.0;
46.436 - gridBagConstraints.insets = new java.awt.Insets(18, 0, 0, 0);
46.437 - add(scopesPanel, gridBagConstraints);
46.438 - }// </editor-fold>//GEN-END:initComponents
46.439 -
46.440 - private void addHintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addHintActionPerformed
46.441 - for (Object selected : allHints.getSelectedValues()) {
46.442 - ((DefaultListModel) selectedHints.getModel()).addElement(selected);
46.443 - ((DefaultListModel) allHints.getModel()).removeElement(selected);
46.444 - }
46.445 - changeListener.stateChanged(new ChangeEvent(this));
46.446 -}//GEN-LAST:event_addHintActionPerformed
46.447 -
46.448 - private void addAllHintsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addAllHintsActionPerformed
46.449 - for (Object o : ((DefaultListModel) allHints.getModel()).toArray()) {
46.450 - ((DefaultListModel) selectedHints.getModel()).addElement(o);
46.451 - }
46.452 - ((DefaultListModel) allHints.getModel()).removeAllElements();
46.453 - changeListener.stateChanged(new ChangeEvent(this));
46.454 -}//GEN-LAST:event_addAllHintsActionPerformed
46.455 -
46.456 - private void removeHintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeHintActionPerformed
46.457 - for (Object selected : selectedHints.getSelectedValues()) {
46.458 - ((DefaultListModel) allHints.getModel()).addElement(selected);
46.459 - ((DefaultListModel) selectedHints.getModel()).removeElement(selected);
46.460 - }
46.461 - changeListener.stateChanged(new ChangeEvent(this));
46.462 -}//GEN-LAST:event_removeHintActionPerformed
46.463 -
46.464 - private void removeAllHintsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeAllHintsActionPerformed
46.465 - for (Object o : ((DefaultListModel) selectedHints.getModel()).toArray()) {
46.466 - ((DefaultListModel) allHints.getModel()).addElement(o);
46.467 - }
46.468 - ((DefaultListModel) selectedHints.getModel()).removeAllElements();
46.469 - changeListener.stateChanged(new ChangeEvent(this));
46.470 -}//GEN-LAST:event_removeAllHintsActionPerformed
46.471 -
46.472 - private void customPatternActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_customPatternActionPerformed
46.473 - enableDisable();
46.474 - }//GEN-LAST:event_customPatternActionPerformed
46.475 -
46.476 - private void knowPatternsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_knowPatternsActionPerformed
46.477 - enableDisable();
46.478 - }//GEN-LAST:event_knowPatternsActionPerformed
46.479 -
46.480 - private void examplesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_examplesButtonActionPerformed
46.481 - Example ex = ExamplesList.chooseExample(LoadExamples.loadExamples(), new ExamplesConvertor(), Example.class, query ? EnumSet.noneOf(Option.class) : EnumSet.of(Option.FIX), query ? EnumSet.of(Option.FIX) : EnumSet.noneOf(Option.class));
46.482 -
46.483 - if (ex != null) {
46.484 - pattern.setText(ex.getCode());
46.485 - }
46.486 - }//GEN-LAST:event_examplesButtonActionPerformed
46.487 -
46.488 - private void recentButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_recentButtonActionPerformed
46.489 - String cod = ExamplesList.chooseExample(loadRecent(),
46.490 - new DialogDescription<String>() {
46.491 - public String getDisplayName(String t) {
46.492 - return t;
46.493 - }
46.494 - public String getCode(String t) {
46.495 - return t;
46.496 - }
46.497 - public Set<Option> getOptions(String t) {
46.498 - return query ? EnumSet.noneOf(Option.class) : EnumSet.of(Option.FIX);
46.499 - }
46.500 - public String getCaption() {
46.501 - return "Recent patterns";
46.502 - }
46.503 - public String getHeader() {
46.504 - return "Patterns:";
46.505 - }
46.506 - },
46.507 - String.class,
46.508 - query ? EnumSet.noneOf(Option.class) : EnumSet.of(Option.FIX), query ? EnumSet.of(Option.FIX) : EnumSet.noneOf(Option.class));
46.509 -
46.510 - if (cod != null) {
46.511 - pattern.setText(cod);
46.512 - }
46.513 - }//GEN-LAST:event_recentButtonActionPerformed
46.514 -
46.515 - private void stateChanged() {
46.516 - if (SwingUtilities.isEventDispatchThread()) {
46.517 - changeListener.stateChanged(new ChangeEvent(this));
46.518 - } else {
46.519 - SwingUtilities.invokeLater(new Runnable() {
46.520 - public void run() {
46.521 - stateChanged();
46.522 - }
46.523 - });
46.524 - }
46.525 - }
46.526 -
46.527 - private void enableDisable() {
46.528 - String toSelect = knowPatterns.isSelected() ? "knownPatterns" : "customPattern";
46.529 -
46.530 - ((CardLayout) patternSelection.getLayout()).show(patternSelection, toSelect);
46.531 - stateChanged();
46.532 - }
46.533 -
46.534 - public void setPattern(Union2<String, Iterable<? extends HintDescription>> pattern) {
46.535 - if (pattern.hasFirst()) {
46.536 - customPattern.setSelected(true);
46.537 - this.pattern.setText(pattern.first() != null ? pattern.first() : "");
46.538 - } else {
46.539 - knowPatterns.setSelected(true);
46.540 -
46.541 - Set<String> selected = new HashSet<String>();
46.542 -
46.543 - for (HintDescription d : pattern.second()) {
46.544 - selected.add(d.getMetadata().displayName);
46.545 - }
46.546 -
46.547 - DefaultListModel allModel = (DefaultListModel) allHints.getModel();
46.548 - DefaultListModel selectedModel = (DefaultListModel) selectedHints.getModel();
46.549 -
46.550 - allModel.clear();
46.551 - selectedModel.clear();
46.552 -
46.553 - for (String dn : displayName2Hints.keySet()) {
46.554 - if (selected.contains(dn)) {
46.555 - selectedModel.addElement(dn);
46.556 - } else {
46.557 - allModel.addElement(dn);
46.558 - }
46.559 - }
46.560 - }
46.561 -
46.562 - enableDisable();
46.563 - }
46.564 -
46.565 - public Union2<String, Iterable<? extends HintDescription>> getPattern() {
46.566 - if (customPattern.isSelected()) {
46.567 - return Union2.createFirst(this.pattern.getText());
46.568 - } else {
46.569 - List<HintDescription> hints = new LinkedList<HintDescription>();
46.570 -
46.571 - for (Object dn : ((DefaultListModel) selectedHints.getModel()).toArray()) {
46.572 - hints.addAll(displayName2Hints.get((String) dn));
46.573 - }
46.574 -
46.575 - return Union2.<String, Iterable<? extends HintDescription>>createSecond(hints);
46.576 - }
46.577 - }
46.578 -
46.579 - public void setScope(Scope scope) {
46.580 - scopesPanel.setScope(scope);
46.581 - }
46.582 -
46.583 - public Scope getScope() {
46.584 - return scopesPanel.getScope();
46.585 - }
46.586 -
46.587 - public boolean getVerify() {
46.588 - return verify.isSelected();
46.589 - }
46.590 -
46.591 - public void setVerify(boolean verify) {
46.592 - this.verify.setSelected(verify);
46.593 - }
46.594 -
46.595 - void fillInFromSettings() {
46.596 - scopesPanel.fillInFromSettings();
46.597 -
46.598 - List<String> recent = loadRecent();
46.599 -
46.600 - if (!recent.isEmpty()) {
46.601 - pattern.setText(recent.get(0));
46.602 - }
46.603 - }
46.604 -
46.605 - void saveScopesCombo() {
46.606 - scopesPanel.saveScopesCombo();
46.607 -
46.608 - String currentPattern = pattern.getText().trim();
46.609 - List<String> recent = loadRecent();
46.610 -
46.611 - recent.remove(currentPattern);
46.612 - recent.add(0, currentPattern);
46.613 -
46.614 - while (recent.size() > MAX_RECENT) {
46.615 - recent.remove(recent.size() - 1);
46.616 - }
46.617 -
46.618 - Preferences prefs = NbPreferences.forModule(FindDuplicatesRefactoringPanel.class);
46.619 - Preferences recentPatterns = prefs.node(query ? RECENT_PATTERNS_QUERY : RECENT_PATTERNS_APPLY);
46.620 - int i = 0;
46.621 -
46.622 - for (String r : recent) {
46.623 - recentPatterns.put("pattern_" + i++, r);
46.624 - }
46.625 - }
46.626 -
46.627 - private static final int MAX_RECENT = 50;
46.628 - private static final String RECENT_PATTERNS_QUERY = "recentPatternsQuery";
46.629 - private static final String RECENT_PATTERNS_APPLY = "recentPatternsApply";
46.630 -
46.631 - private List<String> loadRecent() {
46.632 - Preferences prefs = NbPreferences.forModule(FindDuplicatesRefactoringPanel.class);
46.633 -
46.634 - if (prefs == null) return Collections.emptyList();
46.635 -
46.636 - List<String> recent = new LinkedList<String>();
46.637 - Preferences recentPatterns = prefs.node(query ? RECENT_PATTERNS_QUERY : RECENT_PATTERNS_APPLY);
46.638 -
46.639 - if (recentPatterns != null) {
46.640 - try {
46.641 - for (String k : recentPatterns.keys()) {
46.642 - if (k.startsWith("pattern_")) {
46.643 - recent.add(recentPatterns.get(k, null));
46.644 - }
46.645 - }
46.646 - } catch (BackingStoreException ex) {
46.647 - Exceptions.printStackTrace(ex);
46.648 - }
46.649 - }
46.650 -
46.651 - return recent;
46.652 - }
46.653 -
46.654 - @Override
46.655 - public void removeNotify() {
46.656 - super.removeNotify();
46.657 - DataObject od = NbEditorUtilities.getDataObject(pattern.getDocument());
46.658 -
46.659 - if (od != null) {
46.660 - SaveCookie sc = od.getLookup().lookup(SaveCookie.class);
46.661 -
46.662 - if (sc != null) {
46.663 - try {
46.664 - sc.save();
46.665 - } catch (IOException ex) {
46.666 - Logger.getLogger(FindDuplicatesRefactoringPanel.class.getName()).log(Level.FINE, null, ex);
46.667 - }
46.668 - }
46.669 - }
46.670 - }
46.671 -
46.672 - // Variables declaration - do not modify//GEN-BEGIN:variables
46.673 - private javax.swing.JButton addAllHints;
46.674 - private javax.swing.JButton addHint;
46.675 - private javax.swing.JList allHints;
46.676 - private javax.swing.JLabel allHintsLabel;
46.677 - private javax.swing.JRadioButton customPattern;
46.678 - private javax.swing.JPanel customPatternPanel;
46.679 - private javax.swing.JButton examplesButton;
46.680 - private javax.swing.JPanel jPanel1;
46.681 - private javax.swing.JPanel jPanel2;
46.682 - private javax.swing.JPanel jPanel3;
46.683 - private javax.swing.JScrollPane jScrollPane2;
46.684 - private javax.swing.JScrollPane jScrollPane3;
46.685 - private javax.swing.JScrollPane jScrollPane4;
46.686 - private javax.swing.JRadioButton knowPatterns;
46.687 - private javax.swing.JPanel knownPatternsPanel;
46.688 - private javax.swing.ButtonGroup main;
46.689 - private javax.swing.JEditorPane pattern;
46.690 - private javax.swing.JPanel patternSelection;
46.691 - private javax.swing.JPanel patternTypeSelectionPanel;
46.692 - private javax.swing.JButton recentButton;
46.693 - private javax.swing.JButton removeAllHints;
46.694 - private javax.swing.JButton removeHint;
46.695 - private org.netbeans.modules.jackpot30.impl.refactoring.ScopesPanel scopesPanel;
46.696 - private javax.swing.JList selectedHints;
46.697 - private javax.swing.JLabel selectedHintsLabel;
46.698 - private javax.swing.JCheckBox verify;
46.699 - // End of variables declaration//GEN-END:variables
46.700 -
46.701 - private static final String HINTS_LIST_PROTOTYPE = "012345678901234567890123456789";
46.702 -
46.703 - private static final class ExamplesConvertor implements DialogDescription<Example> {
46.704 -
46.705 - public String getDisplayName(Example t) {
46.706 - return t.getDisplayName();
46.707 - }
46.708 -
46.709 - public String getCode(Example t) {
46.710 - return t.getCode();
46.711 - }
46.712 -
46.713 - public Set<Option> getOptions(Example t) {
46.714 - return t.getOptions();
46.715 - }
46.716 -
46.717 - public String getCaption() {
46.718 - return "Choose Example";
46.719 - }
46.720 -
46.721 - public String getHeader() {
46.722 - return "Examples:";
46.723 - }
46.724 -
46.725 - }
46.726 -}
47.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/FindDuplicatesRefactoringPlugin.java Fri Jan 27 13:35:56 2012 +0100
47.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
47.3 @@ -1,107 +0,0 @@
47.4 -/*
47.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
47.6 - *
47.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
47.8 - *
47.9 - * The contents of this file are subject to the terms of either the GNU
47.10 - * General Public License Version 2 only ("GPL") or the Common
47.11 - * Development and Distribution License("CDDL") (collectively, the
47.12 - * "License"). You may not use this file except in compliance with the
47.13 - * License. You can obtain a copy of the License at
47.14 - * http://www.netbeans.org/cddl-gplv2.html
47.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
47.16 - * specific language governing permissions and limitations under the
47.17 - * License. When distributing the software, include this License Header
47.18 - * Notice in each file and include the License file at
47.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
47.20 - * particular file as subject to the "Classpath" exception as provided
47.21 - * by Sun in the GPL Version 2 section of the License file that
47.22 - * accompanied this code. If applicable, add the following below the
47.23 - * License Header, with the fields enclosed by brackets [] replaced by
47.24 - * your own identifying information:
47.25 - * "Portions Copyrighted [year] [name of copyright owner]"
47.26 - *
47.27 - * If you wish your version of this file to be governed by only the CDDL
47.28 - * or only the GPL Version 2, indicate your decision by adding
47.29 - * "[Contributor] elects to include this software in this distribution
47.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
47.31 - * single choice of license, a recipient has the option to distribute
47.32 - * your version of this file under either the CDDL, the GPL Version 2 or
47.33 - * to extend the choice of license to its licensees as provided above.
47.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
47.35 - * Version 2 license, then the option applies only if the new code is
47.36 - * made subject to such option by the copyright holder.
47.37 - *
47.38 - * Contributor(s):
47.39 - *
47.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
47.41 - */
47.42 -
47.43 -package org.netbeans.modules.jackpot30.impl.refactoring;
47.44 -
47.45 -import java.util.Collection;
47.46 -import java.util.LinkedList;
47.47 -import java.util.List;
47.48 -import org.netbeans.modules.java.hints.jackpot.impl.MessageImpl;
47.49 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch;
47.50 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.BatchResult;
47.51 -import org.netbeans.modules.java.hints.jackpot.impl.batch.ProgressHandleWrapper;
47.52 -import org.netbeans.modules.java.hints.jackpot.spi.HintContext.MessageKind;
47.53 -import org.netbeans.modules.refactoring.api.Problem;
47.54 -import org.netbeans.modules.refactoring.spi.RefactoringElementsBag;
47.55 -
47.56 -public class FindDuplicatesRefactoringPlugin extends AbstractApplyHintsRefactoringPlugin {
47.57 -
47.58 - private final FindDuplicatesRefactoring refactoring;
47.59 -
47.60 - public FindDuplicatesRefactoringPlugin(FindDuplicatesRefactoring refactoring) {
47.61 - super(refactoring);
47.62 - this.refactoring = refactoring;
47.63 - }
47.64 -
47.65 - public Problem preCheck() {
47.66 - return null;
47.67 - }
47.68 -
47.69 - public Problem checkParameters() {
47.70 - return null;
47.71 - }
47.72 -
47.73 - public Problem fastCheckParameters() {
47.74 - return null;
47.75 - }
47.76 -
47.77 - public Problem prepare(RefactoringElementsBag refactoringElements) {
47.78 - cancel.set(false);
47.79 -
47.80 - Collection<MessageImpl> problems = refactoring.isQuery() ? performSearchForPattern(refactoringElements) : performApplyPattern(refactoringElements);
47.81 - Problem current = null;
47.82 -
47.83 - for (MessageImpl problem : problems) {
47.84 - Problem p = new Problem(problem.kind == MessageKind.ERROR, problem.text);
47.85 -
47.86 - if (current != null)
47.87 - p.setNext(current);
47.88 - current = p;
47.89 - }
47.90 -
47.91 - return current;
47.92 - }
47.93 -
47.94 - private List<MessageImpl> performSearchForPattern(final RefactoringElementsBag refactoringElements) {
47.95 - ProgressHandleWrapper w = new ProgressHandleWrapper(this, 50, 50);
47.96 - BatchResult candidates = BatchSearch.findOccurrences(refactoring.getPattern(), refactoring.getScope(), w);
47.97 - List<MessageImpl> problems = new LinkedList<MessageImpl>(candidates.problems);
47.98 -
47.99 - prepareElements(candidates, w, refactoringElements, refactoring.isVerify(), problems);
47.100 -
47.101 - w.finish();
47.102 -
47.103 - return problems;
47.104 - }
47.105 -
47.106 - private Collection<MessageImpl> performApplyPattern(RefactoringElementsBag refactoringElements) {
47.107 - return performApplyPattern(refactoring.getPattern(), refactoring.getScope(), refactoringElements);
47.108 - }
47.109 -
47.110 -}
47.111 \ No newline at end of file
48.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/FindDuplicatesRefactoringUI.java Fri Jan 27 13:35:56 2012 +0100
48.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
48.3 @@ -1,193 +0,0 @@
48.4 -/*
48.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
48.6 - *
48.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
48.8 - *
48.9 - * The contents of this file are subject to the terms of either the GNU
48.10 - * General Public License Version 2 only ("GPL") or the Common
48.11 - * Development and Distribution License("CDDL") (collectively, the
48.12 - * "License"). You may not use this file except in compliance with the
48.13 - * License. You can obtain a copy of the License at
48.14 - * http://www.netbeans.org/cddl-gplv2.html
48.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
48.16 - * specific language governing permissions and limitations under the
48.17 - * License. When distributing the software, include this License Header
48.18 - * Notice in each file and include the License file at
48.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
48.20 - * particular file as subject to the "Classpath" exception as provided
48.21 - * by Sun in the GPL Version 2 section of the License file that
48.22 - * accompanied this code. If applicable, add the following below the
48.23 - * License Header, with the fields enclosed by brackets [] replaced by
48.24 - * your own identifying information:
48.25 - * "Portions Copyrighted [year] [name of copyright owner]"
48.26 - *
48.27 - * If you wish your version of this file to be governed by only the CDDL
48.28 - * or only the GPL Version 2, indicate your decision by adding
48.29 - * "[Contributor] elects to include this software in this distribution
48.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
48.31 - * single choice of license, a recipient has the option to distribute
48.32 - * your version of this file under either the CDDL, the GPL Version 2 or
48.33 - * to extend the choice of license to its licensees as provided above.
48.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
48.35 - * Version 2 license, then the option applies only if the new code is
48.36 - * made subject to such option by the copyright holder.
48.37 - *
48.38 - * Contributor(s):
48.39 - *
48.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
48.41 - */
48.42 -
48.43 -package org.netbeans.modules.jackpot30.impl.refactoring;
48.44 -
48.45 -import java.awt.Component;
48.46 -import java.io.File;
48.47 -import java.util.Collections;
48.48 -import javax.swing.event.ChangeListener;
48.49 -import org.netbeans.api.annotations.common.NonNull;
48.50 -import org.netbeans.api.annotations.common.NullAllowed;
48.51 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.Scope;
48.52 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
48.53 -import org.netbeans.modules.java.hints.jackpot.spi.PatternConvertor;
48.54 -import org.netbeans.modules.refactoring.api.AbstractRefactoring;
48.55 -import org.netbeans.modules.refactoring.api.Problem;
48.56 -import org.netbeans.modules.refactoring.spi.ui.CustomRefactoringPanel;
48.57 -import org.netbeans.modules.refactoring.spi.ui.RefactoringUI;
48.58 -import org.openide.filesystems.FileObject;
48.59 -import org.openide.filesystems.FileUtil;
48.60 -import org.openide.util.HelpCtx;
48.61 -import org.openide.util.Union2;
48.62 -
48.63 -public class FindDuplicatesRefactoringUI implements RefactoringUI {
48.64 -
48.65 - private final boolean explicitPattern;
48.66 - private volatile @NonNull Union2<String, Iterable<? extends HintDescription>> pattern;
48.67 - private volatile @NonNull Scope scope;
48.68 - private volatile boolean verify;
48.69 -
48.70 - private final boolean query;
48.71 - private final FindDuplicatesRefactoring refactoring;
48.72 -
48.73 - public FindDuplicatesRefactoringUI(@NullAllowed String pattern, Scope scope) {
48.74 - this(pattern, scope, true);
48.75 - }
48.76 -
48.77 - public FindDuplicatesRefactoringUI(@NullAllowed String pattern, Scope scope, boolean verify) {
48.78 - this(pattern, scope, verify, true);
48.79 - }
48.80 -
48.81 - public FindDuplicatesRefactoringUI(@NullAllowed String pattern, Scope scope, boolean verify, boolean query) {
48.82 - if (!query && !verify) {
48.83 - throw new UnsupportedOperationException();
48.84 - }
48.85 -
48.86 - this.explicitPattern = pattern != null;
48.87 - this.pattern = pattern != null ? Union2.<String, Iterable<? extends HintDescription>>createFirst(pattern) : Union2.<String, Iterable<? extends HintDescription>>createSecond(Collections.<HintDescription>emptyList());
48.88 - this.scope = scope;
48.89 - this.verify = verify;
48.90 - this.query = query;
48.91 - this.refactoring = new FindDuplicatesRefactoring(query);
48.92 - }
48.93 -
48.94 - public String getName() {
48.95 - return query ? "Find Pattern Occurrences" : "Apply Pattern";
48.96 - }
48.97 -
48.98 - public String getDescription() {
48.99 - return query ? "Find Pattern Occurrences" : "Apply Pattern";
48.100 - }
48.101 -
48.102 - public boolean isQuery() {
48.103 - return query;
48.104 - }
48.105 -
48.106 - private FindDuplicatesRefactoringPanel panel;
48.107 -
48.108 - public CustomRefactoringPanel getPanel(final ChangeListener parent) {
48.109 - return new CustomRefactoringPanel() {
48.110 - public void initialize() {
48.111 - panel.fillInFromSettings();
48.112 - panel.setPattern(FindDuplicatesRefactoringUI.this.pattern);
48.113 - panel.setScope(scope);
48.114 - panel.setVerify(verify);
48.115 - }
48.116 - public Component getComponent() {
48.117 - if (panel == null) {
48.118 - panel = new FindDuplicatesRefactoringPanel(parent, query);
48.119 - }
48.120 -
48.121 - return panel;
48.122 - }
48.123 - };
48.124 - }
48.125 -
48.126 - public Problem setParameters() {
48.127 - pattern = panel.getPattern();
48.128 - scope = panel.getScope();
48.129 - verify = panel.getVerify();
48.130 - panel.saveScopesCombo();
48.131 - return null;
48.132 - }
48.133 -
48.134 - public Problem checkParameters() {
48.135 - Union2<String, Iterable<? extends HintDescription>> pattern = panel != null ? panel.getPattern() : this.pattern;
48.136 - Scope scope = panel != null ? panel.getScope() : this.scope;
48.137 -
48.138 - if (pattern.hasFirst()) {
48.139 - if (pattern.first() == null) {
48.140 - return new Problem(true, "No pattern specified");
48.141 - }
48.142 - if (PatternConvertor.create(pattern.first()) == null) {
48.143 - return new Problem(true, "The pattern cannot be parsed");
48.144 - }
48.145 - } else {
48.146 - if (!pattern.second().iterator().hasNext()) {
48.147 - return new Problem(true, "No pattern specified");
48.148 - }
48.149 - }
48.150 -
48.151 -// if (scope.scopeType == ScopeType.GIVEN_FOLDER && findFolderFileObject(scope.folder) == null) {
48.152 -// return new Problem(true, "Specified folder not found");
48.153 -// }
48.154 - return null;
48.155 - }
48.156 -
48.157 - public boolean hasParameters() {
48.158 - return true;
48.159 - }
48.160 -
48.161 - public AbstractRefactoring getRefactoring() {
48.162 - Iterable<? extends HintDescription> hints;
48.163 -
48.164 - if (pattern.hasFirst()) {
48.165 - if (pattern.first() != null) {
48.166 - hints = PatternConvertor.create(pattern.first());
48.167 - } else {
48.168 - hints = Collections.<HintDescription>emptyList();
48.169 - }
48.170 - } else {
48.171 - hints = pattern.second();
48.172 - }
48.173 -
48.174 - FindDuplicatesRefactoring r = refactoring;
48.175 - r.setPattern(hints);
48.176 - r.setScope(scope);
48.177 - r.setVerify(verify);
48.178 -
48.179 - return r;
48.180 - }
48.181 -
48.182 - public HelpCtx getHelpCtx() {
48.183 - return new HelpCtx("jackpot30.pattern.format");
48.184 - }
48.185 -
48.186 - private FileObject findFolderFileObject(String folder) {
48.187 - if (folder == null) return null;
48.188 -
48.189 - File file = new File(folder);
48.190 -
48.191 - if (!file.exists()) return null;
48.192 -
48.193 - return FileUtil.toFileObject(FileUtil.normalizeFile(file));
48.194 - }
48.195 -
48.196 -}
48.197 \ No newline at end of file
49.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/FindOccurrencesAction.java Fri Jan 27 13:35:56 2012 +0100
49.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
49.3 @@ -1,52 +0,0 @@
49.4 -/*
49.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
49.6 - *
49.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
49.8 - *
49.9 - * The contents of this file are subject to the terms of either the GNU
49.10 - * General Public License Version 2 only ("GPL") or the Common
49.11 - * Development and Distribution License("CDDL") (collectively, the
49.12 - * "License"). You may not use this file except in compliance with the
49.13 - * License. You can obtain a copy of the License at
49.14 - * http://www.netbeans.org/cddl-gplv2.html
49.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
49.16 - * specific language governing permissions and limitations under the
49.17 - * License. When distributing the software, include this License Header
49.18 - * Notice in each file and include the License file at
49.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
49.20 - * particular file as subject to the "Classpath" exception as provided
49.21 - * by Sun in the GPL Version 2 section of the License file that
49.22 - * accompanied this code. If applicable, add the following below the
49.23 - * License Header, with the fields enclosed by brackets [] replaced by
49.24 - * your own identifying information:
49.25 - * "Portions Copyrighted [year] [name of copyright owner]"
49.26 - *
49.27 - * If you wish your version of this file to be governed by only the CDDL
49.28 - * or only the GPL Version 2, indicate your decision by adding
49.29 - * "[Contributor] elects to include this software in this distribution
49.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
49.31 - * single choice of license, a recipient has the option to distribute
49.32 - * your version of this file under either the CDDL, the GPL Version 2 or
49.33 - * to extend the choice of license to its licensees as provided above.
49.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
49.35 - * Version 2 license, then the option applies only if the new code is
49.36 - * made subject to such option by the copyright holder.
49.37 - *
49.38 - * Contributor(s):
49.39 - *
49.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
49.41 - */
49.42 -
49.43 -package org.netbeans.modules.jackpot30.impl.refactoring;
49.44 -
49.45 -import java.awt.event.ActionEvent;
49.46 -import java.awt.event.ActionListener;
49.47 -import org.netbeans.modules.java.hints.jackpot.impl.batch.Scopes;
49.48 -import org.netbeans.modules.refactoring.spi.ui.UI;
49.49 -
49.50 -public final class FindOccurrencesAction implements ActionListener {
49.51 -
49.52 - public void actionPerformed(ActionEvent e) {
49.53 - UI.openRefactoringUI(new FindDuplicatesRefactoringUI(null, Scopes.allOpenedProjectsScope()));
49.54 - }
49.55 -}
50.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/RefactoringPluginFactoryImpl.java Fri Jan 27 13:35:56 2012 +0100
50.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
50.3 @@ -1,58 +0,0 @@
50.4 -/*
50.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
50.6 - *
50.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
50.8 - *
50.9 - * The contents of this file are subject to the terms of either the GNU
50.10 - * General Public License Version 2 only ("GPL") or the Common
50.11 - * Development and Distribution License("CDDL") (collectively, the
50.12 - * "License"). You may not use this file except in compliance with the
50.13 - * License. You can obtain a copy of the License at
50.14 - * http://www.netbeans.org/cddl-gplv2.html
50.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
50.16 - * specific language governing permissions and limitations under the
50.17 - * License. When distributing the software, include this License Header
50.18 - * Notice in each file and include the License file at
50.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
50.20 - * particular file as subject to the "Classpath" exception as provided
50.21 - * by Sun in the GPL Version 2 section of the License file that
50.22 - * accompanied this code. If applicable, add the following below the
50.23 - * License Header, with the fields enclosed by brackets [] replaced by
50.24 - * your own identifying information:
50.25 - * "Portions Copyrighted [year] [name of copyright owner]"
50.26 - *
50.27 - * If you wish your version of this file to be governed by only the CDDL
50.28 - * or only the GPL Version 2, indicate your decision by adding
50.29 - * "[Contributor] elects to include this software in this distribution
50.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
50.31 - * single choice of license, a recipient has the option to distribute
50.32 - * your version of this file under either the CDDL, the GPL Version 2 or
50.33 - * to extend the choice of license to its licensees as provided above.
50.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
50.35 - * Version 2 license, then the option applies only if the new code is
50.36 - * made subject to such option by the copyright holder.
50.37 - *
50.38 - * Contributor(s):
50.39 - *
50.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
50.41 - */
50.42 -
50.43 -package org.netbeans.modules.jackpot30.impl.refactoring;
50.44 -
50.45 -import org.netbeans.modules.refactoring.api.AbstractRefactoring;
50.46 -import org.netbeans.modules.refactoring.spi.RefactoringPlugin;
50.47 -import org.netbeans.modules.refactoring.spi.RefactoringPluginFactory;
50.48 -import org.openide.util.lookup.ServiceProvider;
50.49 -
50.50 -@ServiceProvider(service=RefactoringPluginFactory.class)
50.51 -public class RefactoringPluginFactoryImpl implements RefactoringPluginFactory {
50.52 -
50.53 - public RefactoringPlugin createInstance(AbstractRefactoring refactoring) {
50.54 - if (refactoring instanceof FindDuplicatesRefactoring) {
50.55 - return new FindDuplicatesRefactoringPlugin((FindDuplicatesRefactoring) refactoring);
50.56 - }
50.57 -
50.58 - return null;
50.59 - }
50.60 -
50.61 -}
51.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/RetoucheCommit.java Fri Jan 27 13:35:56 2012 +0100
51.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
51.3 @@ -1,128 +0,0 @@
51.4 -/*
51.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
51.6 - *
51.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
51.8 - *
51.9 - * The contents of this file are subject to the terms of either the GNU
51.10 - * General Public License Version 2 only ("GPL") or the Common
51.11 - * Development and Distribution License("CDDL") (collectively, the
51.12 - * "License"). You may not use this file except in compliance with the
51.13 - * License. You can obtain a copy of the License at
51.14 - * http://www.netbeans.org/cddl-gplv2.html
51.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
51.16 - * specific language governing permissions and limitations under the
51.17 - * License. When distributing the software, include this License Header
51.18 - * Notice in each file and include the License file at
51.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
51.20 - * particular file as subject to the "Classpath" exception as provided
51.21 - * by Sun in the GPL Version 2 section of the License file that
51.22 - * accompanied this code. If applicable, add the following below the
51.23 - * License Header, with the fields enclosed by brackets [] replaced by
51.24 - * your own identifying information:
51.25 - * "Portions Copyrighted [year] [name of copyright owner]"
51.26 - *
51.27 - * Contributor(s):
51.28 - *
51.29 - * The Original Software is NetBeans. The Initial Developer of the Original
51.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
51.31 - * Microsystems, Inc. All Rights Reserved.
51.32 - *
51.33 - * If you wish your version of this file to be governed by only the CDDL
51.34 - * or only the GPL Version 2, indicate your decision by adding
51.35 - * "[Contributor] elects to include this software in this distribution
51.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
51.37 - * single choice of license, a recipient has the option to distribute
51.38 - * your version of this file under either the CDDL, the GPL Version 2 or
51.39 - * to extend the choice of license to its licensees as provided above.
51.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
51.41 - * Version 2 license, then the option applies only if the new code is
51.42 - * made subject to such option by the copyright holder.
51.43 - */
51.44 -package org.netbeans.modules.jackpot30.impl.refactoring;
51.45 -
51.46 -import java.io.File;
51.47 -import java.io.IOException;
51.48 -import java.util.ArrayList;
51.49 -import java.util.Collection;
51.50 -import java.util.LinkedList;
51.51 -import java.util.Set;
51.52 -import org.netbeans.api.java.source.ModificationResult;
51.53 -import org.netbeans.modules.refactoring.spi.BackupFacility;
51.54 -import org.netbeans.modules.refactoring.spi.Transaction;
51.55 -import org.openide.filesystems.FileObject;
51.56 -import org.openide.filesystems.FileUtil;
51.57 -import org.openide.util.Exceptions;
51.58 -
51.59 -/**TODO: Copied from refactoring.java:
51.60 - *
51.61 - * @author Jan Becicka
51.62 - */
51.63 -
51.64 -public class RetoucheCommit implements Transaction {
51.65 - ArrayList<BackupFacility.Handle> ids = new ArrayList<BackupFacility.Handle>();
51.66 - private boolean commited = false;
51.67 - Collection<ModificationResult> results;
51.68 - private Set<File> newFiles;
51.69 -
51.70 - public RetoucheCommit(Collection<ModificationResult> results) {
51.71 - this.results = results;
51.72 - }
51.73 -
51.74 - public void commit() {
51.75 - try {
51.76 - if (commited) {
51.77 - for (BackupFacility.Handle id:ids) {
51.78 - try {
51.79 - id.restore();
51.80 - } catch (IOException ex) {
51.81 - throw (RuntimeException) new RuntimeException().initCause(ex);
51.82 - }
51.83 - }
51.84 - } else {
51.85 - commited = true;
51.86 - for (ModificationResult result:results) {
51.87 - Collection<FileObject> toBackup = new LinkedList<FileObject>();
51.88 - for (FileObject file : result.getModifiedFileObjects()) {
51.89 - if (file != null && file.isData()) {
51.90 - toBackup.add(file);
51.91 - }
51.92 - }
51.93 - ids.add(BackupFacility.getDefault().backup(toBackup));
51.94 - newFiles = result.getNewFiles();
51.95 - result.commit();
51.96 - }
51.97 - }
51.98 -
51.99 - } catch (IOException ex) {
51.100 - throw (RuntimeException) new RuntimeException().initCause(ex);
51.101 - }
51.102 - }
51.103 -
51.104 - private boolean newFilesStored = false;
51.105 - public void rollback() {
51.106 - for (BackupFacility.Handle id:ids) {
51.107 - try {
51.108 - id.restore();
51.109 - } catch (IOException ex) {
51.110 - throw (RuntimeException) new RuntimeException().initCause(ex);
51.111 - }
51.112 - }
51.113 - boolean localStored = false;
51.114 - if (newFiles!=null) {
51.115 - for (File f:newFiles) {
51.116 - try {
51.117 - FileObject fo = FileUtil.toFileObject(f);
51.118 - if (!newFilesStored) {
51.119 - ids.add(BackupFacility.getDefault().backup(fo));
51.120 - localStored = true;
51.121 - }
51.122 - fo.delete();
51.123 - } catch (IOException ex) {
51.124 - Exceptions.printStackTrace(ex);
51.125 - }
51.126 - }
51.127 - newFilesStored |= localStored;
51.128 - }
51.129 - }
51.130 -}
51.131 -
51.132 \ No newline at end of file
52.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/ScopesPanel.form Fri Jan 27 13:35:56 2012 +0100
52.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
52.3 @@ -1,115 +0,0 @@
52.4 -<?xml version="1.1" encoding="UTF-8" ?>
52.5 -
52.6 -<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
52.7 - <NonVisualComponents>
52.8 - <Component class="javax.swing.ButtonGroup" name="main">
52.9 - </Component>
52.10 - </NonVisualComponents>
52.11 - <AuxValues>
52.12 - <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
52.13 - <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
52.14 - <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
52.15 - <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
52.16 - <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
52.17 - <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
52.18 - <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
52.19 - <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
52.20 - <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
52.21 - </AuxValues>
52.22 -
52.23 - <Layout>
52.24 - <DimensionLayout dim="0">
52.25 - <Group type="103" groupAlignment="0" attributes="0">
52.26 - <Component id="scopePanel" min="-2" pref="576" max="-2" attributes="0"/>
52.27 - <Group type="102" alignment="0" attributes="0">
52.28 - <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
52.29 - <EmptySpace min="-2" max="-2" attributes="0"/>
52.30 - <Component id="scope" pref="334" max="32767" attributes="0"/>
52.31 - <EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
52.32 - <Component id="add" min="-2" max="-2" attributes="0"/>
52.33 - <EmptySpace min="-2" max="-2" attributes="0"/>
52.34 - <Component id="edit" min="-2" max="-2" attributes="0"/>
52.35 - <EmptySpace min="-2" max="-2" attributes="0"/>
52.36 - <Component id="removeButton" min="-2" max="-2" attributes="0"/>
52.37 - </Group>
52.38 - </Group>
52.39 - </DimensionLayout>
52.40 - <DimensionLayout dim="1">
52.41 - <Group type="103" groupAlignment="0" attributes="0">
52.42 - <Group type="102" attributes="0">
52.43 - <EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
52.44 - <Group type="103" groupAlignment="3" attributes="0">
52.45 - <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
52.46 - <Component id="scope" alignment="3" min="-2" max="-2" attributes="0"/>
52.47 - <Component id="add" alignment="3" min="-2" max="-2" attributes="0"/>
52.48 - <Component id="edit" alignment="3" min="-2" max="-2" attributes="0"/>
52.49 - <Component id="removeButton" alignment="3" min="-2" max="-2" attributes="0"/>
52.50 - </Group>
52.51 - <EmptySpace type="separate" max="-2" attributes="0"/>
52.52 - <Component id="scopePanel" min="-2" max="-2" attributes="0"/>
52.53 - </Group>
52.54 - </Group>
52.55 - </DimensionLayout>
52.56 - </Layout>
52.57 - <SubComponents>
52.58 - <Container class="javax.swing.JPanel" name="scopePanel">
52.59 -
52.60 - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
52.61 - </Container>
52.62 - <Component class="javax.swing.JLabel" name="jLabel2">
52.63 - <Properties>
52.64 - <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
52.65 - <ComponentRef name="scope"/>
52.66 - </Property>
52.67 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
52.68 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="ScopesPanel.jLabel2.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
52.69 - </Property>
52.70 - </Properties>
52.71 - </Component>
52.72 - <Component class="javax.swing.JComboBox" name="scope">
52.73 - <Properties>
52.74 - <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
52.75 - <StringArray count="4">
52.76 - <StringItem index="0" value="Item 1"/>
52.77 - <StringItem index="1" value="Item 2"/>
52.78 - <StringItem index="2" value="Item 3"/>
52.79 - <StringItem index="3" value="Item 4"/>
52.80 - </StringArray>
52.81 - </Property>
52.82 - <Property name="prototypeDisplayValue" type="java.lang.Object" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
52.83 - <Connection code="SCOPE_COMBO_PROTOTYPE" type="code"/>
52.84 - </Property>
52.85 - </Properties>
52.86 - </Component>
52.87 - <Component class="javax.swing.JButton" name="add">
52.88 - <Properties>
52.89 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
52.90 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="ScopesPanel.add.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
52.91 - </Property>
52.92 - </Properties>
52.93 - <Events>
52.94 - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addActionPerformed"/>
52.95 - </Events>
52.96 - </Component>
52.97 - <Component class="javax.swing.JButton" name="edit">
52.98 - <Properties>
52.99 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
52.100 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="ScopesPanel.edit.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
52.101 - </Property>
52.102 - </Properties>
52.103 - <Events>
52.104 - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="editActionPerformed"/>
52.105 - </Events>
52.106 - </Component>
52.107 - <Component class="javax.swing.JButton" name="removeButton">
52.108 - <Properties>
52.109 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
52.110 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="ScopesPanel.removeButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
52.111 - </Property>
52.112 - </Properties>
52.113 - <Events>
52.114 - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="removeButtonActionPerformed"/>
52.115 - </Events>
52.116 - </Component>
52.117 - </SubComponents>
52.118 -</Form>
53.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/ScopesPanel.java Fri Jan 27 13:35:56 2012 +0100
53.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
53.3 @@ -1,321 +0,0 @@
53.4 -/*
53.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
53.6 - *
53.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
53.8 - *
53.9 - * The contents of this file are subject to the terms of either the GNU
53.10 - * General Public License Version 2 only ("GPL") or the Common
53.11 - * Development and Distribution License("CDDL") (collectively, the
53.12 - * "License"). You may not use this file except in compliance with the
53.13 - * License. You can obtain a copy of the License at
53.14 - * http://www.netbeans.org/cddl-gplv2.html
53.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
53.16 - * specific language governing permissions and limitations under the
53.17 - * License. When distributing the software, include this License Header
53.18 - * Notice in each file and include the License file at
53.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
53.20 - * particular file as subject to the "Classpath" exception as provided
53.21 - * by Sun in the GPL Version 2 section of the License file that
53.22 - * accompanied this code. If applicable, add the following below the
53.23 - * License Header, with the fields enclosed by brackets [] replaced by
53.24 - * your own identifying information:
53.25 - * "Portions Copyrighted [year] [name of copyright owner]"
53.26 - *
53.27 - * If you wish your version of this file to be governed by only the CDDL
53.28 - * or only the GPL Version 2, indicate your decision by adding
53.29 - * "[Contributor] elects to include this software in this distribution
53.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
53.31 - * single choice of license, a recipient has the option to distribute
53.32 - * your version of this file under either the CDDL, the GPL Version 2 or
53.33 - * to extend the choice of license to its licensees as provided above.
53.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
53.35 - * Version 2 license, then the option applies only if the new code is
53.36 - * made subject to such option by the copyright holder.
53.37 - *
53.38 - * Contributor(s):
53.39 - *
53.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
53.41 - */
53.42 -
53.43 -package org.netbeans.modules.jackpot30.impl.refactoring;
53.44 -
53.45 -import java.awt.Component;
53.46 -import java.awt.event.ItemEvent;
53.47 -import java.awt.event.ItemListener;
53.48 -import java.util.prefs.Preferences;
53.49 -import javax.swing.DefaultComboBoxModel;
53.50 -import javax.swing.DefaultListCellRenderer;
53.51 -import javax.swing.JButton;
53.52 -import javax.swing.JList;
53.53 -import javax.swing.event.ChangeEvent;
53.54 -import javax.swing.event.ChangeListener;
53.55 -import org.netbeans.modules.jackpot30.impl.batch.EnhancedScopes.GivenFolderScope;
53.56 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.Scope;
53.57 -import org.netbeans.modules.java.hints.jackpot.impl.batch.Scopes;
53.58 -import org.openide.DialogDescriptor;
53.59 -import org.openide.DialogDisplayer;
53.60 -import org.openide.util.NbPreferences;
53.61 -
53.62 -/**
53.63 - *
53.64 - * @author lahvac
53.65 - */
53.66 -public class ScopesPanel extends javax.swing.JPanel {
53.67 -
53.68 - private ChangeListener changeListener;
53.69 -
53.70 - public ScopesPanel() {
53.71 - initComponents();
53.72 -
53.73 - ItemListener ilImpl = new ItemListener() {
53.74 - public void itemStateChanged(ItemEvent e) {
53.75 - stateChanged();
53.76 - enableDisableEditRemove();
53.77 - }
53.78 - };
53.79 -
53.80 - scope.addItemListener(ilImpl);
53.81 -
53.82 - scope.setModel(new DefaultComboBoxModel());//XXX
53.83 - scope.setRenderer(new RendererImpl());
53.84 - }
53.85 -
53.86 - public void setChangeListener(ChangeListener changeListener) {
53.87 - this.changeListener = changeListener;
53.88 - }
53.89 -
53.90 - /** This method is called from within the constructor to
53.91 - * initialize the form.
53.92 - * WARNING: Do NOT modify this code. The content of this method is
53.93 - * always regenerated by the Form Editor.
53.94 - */
53.95 - @SuppressWarnings("unchecked")
53.96 - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
53.97 - private void initComponents() {
53.98 - java.awt.GridBagConstraints gridBagConstraints;
53.99 -
53.100 - main = new javax.swing.ButtonGroup();
53.101 - scopePanel = new javax.swing.JPanel();
53.102 - jLabel2 = new javax.swing.JLabel();
53.103 - scope = new javax.swing.JComboBox();
53.104 - add = new javax.swing.JButton();
53.105 - edit = new javax.swing.JButton();
53.106 - removeButton = new javax.swing.JButton();
53.107 -
53.108 - scopePanel.setLayout(new java.awt.GridBagLayout());
53.109 -
53.110 - jLabel2.setLabelFor(scope);
53.111 - org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(ScopesPanel.class, "ScopesPanel.jLabel2.text")); // NOI18N
53.112 -
53.113 - scope.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
53.114 - scope.setPrototypeDisplayValue(SCOPE_COMBO_PROTOTYPE);
53.115 -
53.116 - org.openide.awt.Mnemonics.setLocalizedText(add, org.openide.util.NbBundle.getMessage(ScopesPanel.class, "ScopesPanel.add.text")); // NOI18N
53.117 - add.addActionListener(new java.awt.event.ActionListener() {
53.118 - public void actionPerformed(java.awt.event.ActionEvent evt) {
53.119 - addActionPerformed(evt);
53.120 - }
53.121 - });
53.122 -
53.123 - org.openide.awt.Mnemonics.setLocalizedText(edit, org.openide.util.NbBundle.getMessage(ScopesPanel.class, "ScopesPanel.edit.text")); // NOI18N
53.124 - edit.addActionListener(new java.awt.event.ActionListener() {
53.125 - public void actionPerformed(java.awt.event.ActionEvent evt) {
53.126 - editActionPerformed(evt);
53.127 - }
53.128 - });
53.129 -
53.130 - org.openide.awt.Mnemonics.setLocalizedText(removeButton, org.openide.util.NbBundle.getMessage(ScopesPanel.class, "ScopesPanel.removeButton.text")); // NOI18N
53.131 - removeButton.addActionListener(new java.awt.event.ActionListener() {
53.132 - public void actionPerformed(java.awt.event.ActionEvent evt) {
53.133 - removeButtonActionPerformed(evt);
53.134 - }
53.135 - });
53.136 -
53.137 - org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
53.138 - this.setLayout(layout);
53.139 - layout.setHorizontalGroup(
53.140 - layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
53.141 - .add(scopePanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 576, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
53.142 - .add(layout.createSequentialGroup()
53.143 - .add(jLabel2)
53.144 - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
53.145 - .add(scope, 0, 334, Short.MAX_VALUE)
53.146 - .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
53.147 - .add(add)
53.148 - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
53.149 - .add(edit)
53.150 - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
53.151 - .add(removeButton))
53.152 - );
53.153 - layout.setVerticalGroup(
53.154 - layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
53.155 - .add(layout.createSequentialGroup()
53.156 - .add(11, 11, 11)
53.157 - .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
53.158 - .add(jLabel2)
53.159 - .add(scope, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
53.160 - .add(add)
53.161 - .add(edit)
53.162 - .add(removeButton))
53.163 - .add(18, 18, 18)
53.164 - .add(scopePanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
53.165 - );
53.166 - }// </editor-fold>//GEN-END:initComponents
53.167 -
53.168 - private void addActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addActionPerformed
53.169 - addEditScope(false);
53.170 - }//GEN-LAST:event_addActionPerformed
53.171 -
53.172 - private void editActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editActionPerformed
53.173 - addEditScope(true);
53.174 - }//GEN-LAST:event_editActionPerformed
53.175 -
53.176 - private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed
53.177 - DefaultComboBoxModel model = (DefaultComboBoxModel) scope.getModel();
53.178 - int index = model.getIndexOf(model.getSelectedItem());
53.179 -
53.180 - model.removeElementAt(index);
53.181 - }//GEN-LAST:event_removeButtonActionPerformed
53.182 -
53.183 - private void stateChanged() {
53.184 - changeListener.stateChanged(new ChangeEvent(this));
53.185 - }
53.186 -
53.187 - private void enableDisableEditRemove() {
53.188 - boolean enableEditRemove = scope.getSelectedItem() instanceof GivenFolderScope;
53.189 -
53.190 - edit.setEnabled(enableEditRemove);
53.191 - removeButton.setEnabled(enableEditRemove);
53.192 - }
53.193 -
53.194 - public void setScope(Scope scope) {
53.195 - this.scope.setSelectedItem(scope);
53.196 - stateChanged();
53.197 - }
53.198 -
53.199 - public Scope getScope() {
53.200 - return (Scope) this.scope.getSelectedItem();
53.201 - }
53.202 -
53.203 - private static final String SCOPES_KEY = ScopesPanel.class.getSimpleName() + "/scopes";
53.204 - private static final String LAST_SELECTED_SCOPE_KEY = "lastSelected";
53.205 -
53.206 - public void fillInFromSettings() {
53.207 - Preferences prefs = NbPreferences.forModule(ScopesPanel.class).node(SCOPES_KEY);
53.208 - DefaultComboBoxModel dcbm = new DefaultComboBoxModel();
53.209 -
53.210 - dcbm.addElement(Scopes.allOpenedProjectsScope());
53.211 -
53.212 -// String lastSelectedFolder = prefs.get(LAST_SELECTED_SCOPE_KEY, null);
53.213 -// Scope lastSelectedScope = null;
53.214 -//
53.215 -// if (prefs != null) {
53.216 -// try {
53.217 -// for (String key : prefs.keys()) {
53.218 -// if (key.startsWith("scope")) {
53.219 -// Scope scope = Scope.deserialize(prefs.get(key, null));
53.220 -//
53.221 -// if (scope.folder.equals(lastSelectedFolder)) {
53.222 -// lastSelectedScope = scope;
53.223 -// }
53.224 -//
53.225 -// dcbm.addElement(scope);
53.226 -// }
53.227 -// }
53.228 -// } catch (BackingStoreException ex) {
53.229 -// Exceptions.printStackTrace(ex);
53.230 -// }
53.231 -// }
53.232 -//
53.233 - scope.setModel(dcbm);
53.234 -// if (lastSelectedScope != null) {
53.235 -// scope.setSelectedItem(lastSelectedScope);
53.236 -// } else {
53.237 - scope.setSelectedIndex(0);
53.238 -// }
53.239 -
53.240 - enableDisableEditRemove();
53.241 - }
53.242 -
53.243 - public void saveScopesCombo() {
53.244 -// Preferences prefs = NbPreferences.forModule(ScopesPanel.class).node(SCOPES_KEY);
53.245 -//
53.246 -// try {
53.247 -// prefs.clear();
53.248 -// } catch (BackingStoreException ex) {
53.249 -// Exceptions.printStackTrace(ex);
53.250 -// }
53.251 -//
53.252 -// for (int i = 0; i < scope.getModel().getSize(); i++) {
53.253 -// Scope currentScope = (Scope) scope.getModel().getElementAt(i);
53.254 -//
53.255 -// if (currentScope.scopeType == ScopeType.ALL_OPENED_PROJECTS) continue;
53.256 -//
53.257 -// prefs.put("scope" + i, currentScope.serialize());
53.258 -// }
53.259 -//
53.260 -// Scope selected = (Scope) scope.getModel().getSelectedItem();
53.261 -//
53.262 -// if (selected.scopeType == ScopeType.GIVEN_FOLDER) {
53.263 -// prefs.put(LAST_SELECTED_SCOPE_KEY, selected.folder);
53.264 -// }
53.265 - }
53.266 -
53.267 - // Variables declaration - do not modify//GEN-BEGIN:variables
53.268 - private javax.swing.JButton add;
53.269 - private javax.swing.JButton edit;
53.270 - private javax.swing.JLabel jLabel2;
53.271 - private javax.swing.ButtonGroup main;
53.272 - private javax.swing.JButton removeButton;
53.273 - private javax.swing.JComboBox scope;
53.274 - private javax.swing.JPanel scopePanel;
53.275 - // End of variables declaration//GEN-END:variables
53.276 -
53.277 - private static final class RendererImpl extends DefaultListCellRenderer {
53.278 -
53.279 - @Override
53.280 - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
53.281 - Object displayName;
53.282 -
53.283 - if (value instanceof Scope) {
53.284 - displayName = ((Scope) value).getDisplayName();
53.285 - } else {
53.286 - displayName = value;
53.287 - }
53.288 -
53.289 - return super.getListCellRendererComponent(list, displayName, index, isSelected, cellHasFocus);
53.290 - }
53.291 -
53.292 - }
53.293 -
53.294 - private void addEditScope(boolean edit) {
53.295 - JButton okButton = new JButton("OK");
53.296 - AddScopePanel panel = new AddScopePanel(okButton);
53.297 - DialogDescriptor dd = new DialogDescriptor(panel, "Add Scope", true, new Object[] {okButton, DialogDescriptor.CANCEL_OPTION}, okButton, DialogDescriptor.DEFAULT_ALIGN, null, null);
53.298 -
53.299 - dd.setClosingOptions(null);
53.300 - panel.setNotificationSupport(dd.createNotificationLineSupport());
53.301 -
53.302 - if (edit) {
53.303 - panel.setScope((GivenFolderScope) scope.getModel().getSelectedItem());
53.304 - }
53.305 -
53.306 - if (DialogDisplayer.getDefault().notify(dd) == okButton) {
53.307 - DefaultComboBoxModel model = (DefaultComboBoxModel) scope.getModel();
53.308 - Scope scope = panel.getScope();
53.309 -
53.310 - if (edit) {
53.311 - int index = model.getIndexOf(model.getSelectedItem());
53.312 -
53.313 - model.removeElementAt(index);
53.314 - model.insertElementAt(scope, index);
53.315 - } else {
53.316 - model.addElement(scope);
53.317 - }
53.318 -
53.319 - model.setSelectedItem(scope);
53.320 - }
53.321 - }
53.322 -
53.323 - private static final String SCOPE_COMBO_PROTOTYPE = "0123456789012345678901234567890123456789012345";
53.324 -}
54.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/Utilities.java Fri Jan 27 13:35:56 2012 +0100
54.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
54.3 @@ -1,185 +0,0 @@
54.4 -/*
54.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
54.6 - *
54.7 - * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
54.8 - *
54.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
54.10 - * Other names may be trademarks of their respective owners.
54.11 - *
54.12 - * The contents of this file are subject to the terms of either the GNU
54.13 - * General Public License Version 2 only ("GPL") or the Common
54.14 - * Development and Distribution License("CDDL") (collectively, the
54.15 - * "License"). You may not use this file except in compliance with the
54.16 - * License. You can obtain a copy of the License at
54.17 - * http://www.netbeans.org/cddl-gplv2.html
54.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
54.19 - * specific language governing permissions and limitations under the
54.20 - * License. When distributing the software, include this License Header
54.21 - * Notice in each file and include the License file at
54.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
54.23 - * particular file as subject to the "Classpath" exception as provided
54.24 - * by Oracle in the GPL Version 2 section of the License file that
54.25 - * accompanied this code. If applicable, add the following below the
54.26 - * License Header, with the fields enclosed by brackets [] replaced by
54.27 - * your own identifying information:
54.28 - * "Portions Copyrighted [year] [name of copyright owner]"
54.29 - *
54.30 - * If you wish your version of this file to be governed by only the CDDL
54.31 - * or only the GPL Version 2, indicate your decision by adding
54.32 - * "[Contributor] elects to include this software in this distribution
54.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
54.34 - * single choice of license, a recipient has the option to distribute
54.35 - * your version of this file under either the CDDL, the GPL Version 2 or
54.36 - * to extend the choice of license to its licensees as provided above.
54.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
54.38 - * Version 2 license, then the option applies only if the new code is
54.39 - * made subject to such option by the copyright holder.
54.40 - *
54.41 - * Contributor(s):
54.42 - *
54.43 - * Portions Copyrighted 2011 Sun Microsystems, Inc.
54.44 - */
54.45 -
54.46 -package org.netbeans.modules.jackpot30.impl.refactoring;
54.47 -
54.48 -import java.io.CharConversionException;
54.49 -import java.io.IOException;
54.50 -import java.util.ArrayList;
54.51 -import java.util.Collection;
54.52 -import java.util.LinkedList;
54.53 -import java.util.List;
54.54 -import javax.swing.text.Position.Bias;
54.55 -import org.netbeans.modules.refactoring.spi.RefactoringElementImplementation;
54.56 -import org.netbeans.modules.refactoring.spi.SimpleRefactoringElementImplementation;
54.57 -import org.openide.cookies.EditorCookie;
54.58 -import org.openide.cookies.LineCookie;
54.59 -import org.openide.filesystems.FileObject;
54.60 -import org.openide.loaders.DataObject;
54.61 -import org.openide.loaders.DataObjectNotFoundException;
54.62 -import org.openide.text.CloneableEditorSupport;
54.63 -import org.openide.text.Line;
54.64 -import org.openide.text.PositionBounds;
54.65 -import org.openide.text.PositionRef;
54.66 -import org.openide.util.Exceptions;
54.67 -import org.openide.util.Lookup;
54.68 -import org.openide.util.lookup.Lookups;
54.69 -import org.openide.xml.XMLUtil;
54.70 -
54.71 -/**
54.72 - *
54.73 - * @author lahvac
54.74 - */
54.75 -public class Utilities {
54.76 - public static List<PositionBounds> prepareSpansFor(FileObject file, Iterable<? extends int[]> spans) {
54.77 - List<PositionBounds> result = new ArrayList<PositionBounds>();
54.78 -
54.79 - try {
54.80 - DataObject d = DataObject.find(file);
54.81 - EditorCookie ec = d.getLookup().lookup(EditorCookie.class);
54.82 - CloneableEditorSupport ces = (CloneableEditorSupport) ec;
54.83 -
54.84 - result = new LinkedList<PositionBounds>();
54.85 -
54.86 - for (int[] span : spans) {
54.87 - PositionRef start = ces.createPositionRef(span[0], Bias.Forward);
54.88 - PositionRef end = ces.createPositionRef(span[1], Bias.Forward);
54.89 -
54.90 - result.add(new PositionBounds(start, end));
54.91 - }
54.92 - } catch (DataObjectNotFoundException ex) {
54.93 - Exceptions.printStackTrace(ex);
54.94 - }
54.95 -
54.96 - return result;
54.97 - }
54.98 -
54.99 - public static Collection<RefactoringElementImplementation> createRefactoringElementImplementation(FileObject file, List<PositionBounds> spans, boolean verified) {
54.100 - List<RefactoringElementImplementation> result = new LinkedList<RefactoringElementImplementation>();
54.101 -
54.102 - try {
54.103 - DataObject d = DataObject.find(file);
54.104 - LineCookie lc = d.getLookup().lookup(LineCookie.class);
54.105 -
54.106 - for (PositionBounds bound : spans) {
54.107 - PositionRef start = bound.getBegin();
54.108 - PositionRef end = bound.getEnd();
54.109 - Line l = lc.getLineSet().getCurrent(start.getLine());
54.110 - String lineText = l.getText();
54.111 -
54.112 - int boldStart = start.getColumn();
54.113 - int boldEnd = end.getLine() == start.getLine() ? end.getColumn() : lineText.length();
54.114 -
54.115 - StringBuilder displayName = new StringBuilder();
54.116 -
54.117 - if (!verified) {
54.118 - displayName.append("(not verified) ");
54.119 - }
54.120 -
54.121 - displayName.append(escapedSubstring(lineText, 0, boldStart).replaceAll("^[ ]*", ""));
54.122 - displayName.append("<b>");
54.123 - displayName.append(escapedSubstring(lineText, boldStart, boldEnd));
54.124 - displayName.append("</b>");
54.125 - displayName.append(escapedSubstring(lineText, boldEnd, lineText.length()));
54.126 -
54.127 - result.add(new RefactoringElementImpl(file, bound, displayName.toString()));
54.128 - }
54.129 - } catch (IOException ex) {
54.130 - Exceptions.printStackTrace(ex);
54.131 - }
54.132 -
54.133 - return result;
54.134 - }
54.135 -
54.136 - private static String escapedSubstring(String str, int start, int end) {
54.137 - String substring = str.substring(start, end);
54.138 -
54.139 - try {
54.140 - return XMLUtil.toElementContent(substring);
54.141 - } catch (CharConversionException ex) {
54.142 - Exceptions.printStackTrace(ex);
54.143 - return substring;
54.144 - }
54.145 - }
54.146 -
54.147 - private static final class RefactoringElementImpl extends SimpleRefactoringElementImplementation {
54.148 -
54.149 - private final FileObject file;
54.150 - private final PositionBounds span;
54.151 - private final String displayName;
54.152 -
54.153 - private final Lookup lookup;
54.154 -
54.155 - public RefactoringElementImpl(FileObject file, PositionBounds span, String displayName) {
54.156 - this.file = file;
54.157 - this.span = span;
54.158 - this.lookup = Lookups.fixed(file);
54.159 - this.displayName = displayName;
54.160 - }
54.161 -
54.162 - public String getText() {
54.163 - return getDisplayText();
54.164 - }
54.165 -
54.166 - public String getDisplayText() {
54.167 - return displayName;
54.168 - }
54.169 -
54.170 - public void performChange() {
54.171 - throw new IllegalStateException();
54.172 - }
54.173 -
54.174 - public Lookup getLookup() {
54.175 - return lookup;
54.176 - }
54.177 -
54.178 - public FileObject getParentFile() {
54.179 - return file;
54.180 - }
54.181 -
54.182 - public PositionBounds getPosition() {
54.183 - return span;
54.184 - }
54.185 -
54.186 - }
54.187 -
54.188 -}
55.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/findusages/PatternGenerator.java Fri Jan 27 13:35:56 2012 +0100
55.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
55.3 @@ -1,146 +0,0 @@
55.4 -/*
55.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
55.6 - *
55.7 - * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
55.8 - *
55.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
55.10 - * Other names may be trademarks of their respective owners.
55.11 - *
55.12 - * The contents of this file are subject to the terms of either the GNU
55.13 - * General Public License Version 2 only ("GPL") or the Common
55.14 - * Development and Distribution License("CDDL") (collectively, the
55.15 - * "License"). You may not use this file except in compliance with the
55.16 - * License. You can obtain a copy of the License at
55.17 - * http://www.netbeans.org/cddl-gplv2.html
55.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
55.19 - * specific language governing permissions and limitations under the
55.20 - * License. When distributing the software, include this License Header
55.21 - * Notice in each file and include the License file at
55.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
55.23 - * particular file as subject to the "Classpath" exception as provided
55.24 - * by Oracle in the GPL Version 2 section of the License file that
55.25 - * accompanied this code. If applicable, add the following below the
55.26 - * License Header, with the fields enclosed by brackets [] replaced by
55.27 - * your own identifying information:
55.28 - * "Portions Copyrighted [year] [name of copyright owner]"
55.29 - *
55.30 - * If you wish your version of this file to be governed by only the CDDL
55.31 - * or only the GPL Version 2, indicate your decision by adding
55.32 - * "[Contributor] elects to include this software in this distribution
55.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
55.34 - * single choice of license, a recipient has the option to distribute
55.35 - * your version of this file under either the CDDL, the GPL Version 2 or
55.36 - * to extend the choice of license to its licensees as provided above.
55.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
55.38 - * Version 2 license, then the option applies only if the new code is
55.39 - * made subject to such option by the copyright holder.
55.40 - *
55.41 - * Contributor(s):
55.42 - *
55.43 - * Portions Copyrighted 2011 Sun Microsystems, Inc.
55.44 - */
55.45 -
55.46 -package org.netbeans.modules.jackpot30.impl.refactoring.findusages;
55.47 -
55.48 -import javax.lang.model.element.Element;
55.49 -import javax.lang.model.element.ExecutableElement;
55.50 -import javax.lang.model.element.Modifier;
55.51 -import javax.lang.model.element.TypeElement;
55.52 -import javax.lang.model.element.VariableElement;
55.53 -import org.netbeans.api.annotations.common.CheckForNull;
55.54 -import org.netbeans.api.annotations.common.NonNull;
55.55 -import org.netbeans.api.java.source.CompilationInfo;
55.56 -
55.57 -/**
55.58 - *
55.59 - * @author lahvac
55.60 - */
55.61 -public class PatternGenerator {
55.62 -
55.63 - public static @CheckForNull String generateFindUsagesScript(CompilationInfo info, Element usagesOf) {
55.64 - switch (usagesOf.getKind()) {
55.65 - case METHOD: return generateMethodFindUsagesScript(info, (ExecutableElement) usagesOf);
55.66 - case ENUM_CONSTANT:
55.67 - case FIELD: return generateFieldFindUsagesScript(info, (VariableElement) usagesOf);
55.68 - case ANNOTATION_TYPE:
55.69 - case CLASS:
55.70 - case ENUM:
55.71 - case INTERFACE: return generateClassFindUsagesScript(info, (TypeElement) usagesOf);
55.72 - default: return null;
55.73 - }
55.74 - }
55.75 -
55.76 - private static @NonNull String generateMethodFindUsagesScript(CompilationInfo info, ExecutableElement usagesOf) {
55.77 - StringBuilder script = new StringBuilder();
55.78 - StringBuilder parameters = new StringBuilder();
55.79 - StringBuilder constraints = new StringBuilder();
55.80 - String enclosingType = info.getTypes().erasure(usagesOf.getEnclosingElement().asType()).toString();
55.81 - int count = 1;
55.82 -
55.83 - if (usagesOf.getModifiers().contains(Modifier.STATIC)) {
55.84 - script.append(enclosingType);
55.85 - } else {
55.86 - script.append("$this");
55.87 - constraints.append("$this instanceof ").append(enclosingType);
55.88 - }
55.89 -
55.90 - script.append(".").append(usagesOf.getSimpleName()).append("(");
55.91 -
55.92 - for (VariableElement p : usagesOf.getParameters()) {
55.93 - if (count > 1) {
55.94 - parameters.append(", ");
55.95 - }
55.96 -
55.97 - if (constraints.length() > 0) {
55.98 - constraints.append(" && ");
55.99 - }
55.100 - parameters.append("$").append(count);
55.101 - constraints.append("$").append(count).append(" instanceof ").append(info.getTypes().erasure(p.asType()));
55.102 - count++;
55.103 - }
55.104 -
55.105 - script.append(parameters).append(")");
55.106 -
55.107 - if (constraints.length() > 0) {
55.108 - script.append(" :: ").append(constraints);
55.109 - }
55.110 -
55.111 - script.append(";;");
55.112 -
55.113 - return script.toString();
55.114 - }
55.115 -
55.116 - private static @NonNull String generateFieldFindUsagesScript(CompilationInfo info, VariableElement usagesOf) {
55.117 - StringBuilder script = new StringBuilder();
55.118 - StringBuilder constraints = new StringBuilder();
55.119 - String enclosingType = info.getTypes().erasure(usagesOf.getEnclosingElement().asType()).toString();
55.120 - int count = 1;
55.121 -
55.122 - if (usagesOf.getModifiers().contains(Modifier.STATIC)) {
55.123 - script.append(enclosingType);
55.124 - } else {
55.125 - script.append("$this");
55.126 - constraints.append("$this instanceof ").append(enclosingType);
55.127 - }
55.128 -
55.129 - script.append(".").append(usagesOf.getSimpleName());
55.130 -
55.131 - if (constraints.length() > 0) {
55.132 - script.append(" :: ").append(constraints);
55.133 - }
55.134 -
55.135 - script.append(";;");
55.136 -
55.137 - return script.toString();
55.138 - }
55.139 -
55.140 - private static @NonNull String generateClassFindUsagesScript(CompilationInfo info, TypeElement usagesOf) {
55.141 - StringBuilder script = new StringBuilder();
55.142 -
55.143 - script.append(usagesOf.getQualifiedName());
55.144 - script.append(";;");
55.145 -
55.146 - return script.toString();
55.147 - }
55.148 -
55.149 -}
56.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/resources/Bundle.properties Fri Jan 27 13:35:56 2012 +0100
56.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
56.3 @@ -1,40 +0,0 @@
56.4 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
56.5 -#
56.6 -# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
56.7 -#
56.8 -# The contents of this file are subject to the terms of either the GNU
56.9 -# General Public License Version 2 only ("GPL") or the Common
56.10 -# Development and Distribution License("CDDL") (collectively, the
56.11 -# "License"). You may not use this file except in compliance with the
56.12 -# License. You can obtain a copy of the License at
56.13 -# http://www.netbeans.org/cddl-gplv2.html
56.14 -# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
56.15 -# specific language governing permissions and limitations under the
56.16 -# License. When distributing the software, include this License Header
56.17 -# Notice in each file and include the License file at
56.18 -# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
56.19 -# particular file as subject to the "Classpath" exception as provided
56.20 -# by Sun in the GPL Version 2 section of the License file that
56.21 -# accompanied this code. If applicable, add the following below the
56.22 -# License Header, with the fields enclosed by brackets [] replaced by
56.23 -# your own identifying information:
56.24 -# "Portions Copyrighted [year] [name of copyright owner]"
56.25 -#
56.26 -# If you wish your version of this file to be governed by only the CDDL
56.27 -# or only the GPL Version 2, indicate your decision by adding
56.28 -# "[Contributor] elects to include this software in this distribution
56.29 -# under the [CDDL or GPL Version 2] license." If you do not indicate a
56.30 -# single choice of license, a recipient has the option to distribute
56.31 -# your version of this file under either the CDDL, the GPL Version 2 or
56.32 -# to extend the choice of license to its licensees as provided above.
56.33 -# However, if you add GPL Version 2 code and therefore, elected the GPL
56.34 -# Version 2 license, then the option applies only if the new code is
56.35 -# made subject to such option by the copyright holder.
56.36 -#
56.37 -# Contributor(s):
56.38 -#
56.39 -# Portions Copyrighted 2009 Sun Microsystems, Inc.
56.40 -
56.41 -Actions/Refactoring/org-netbeans-modules-jackpot30-impl-refactoring-ApplyPatternAction.instance=Apply Pattern
56.42 -Actions/Refactoring/org-netbeans-modules-jackpot30-impl-refactoring-FindOccurrencesAction.instance=Find Pattern Occurrences
56.43 -OpenIDE-Module-Name=Jackpot 3.0 API
57.1 Binary file api/src/org/netbeans/modules/jackpot30/impl/resources/examples_icon.png has changed
58.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/resources/layer.xml Fri Jan 27 13:35:56 2012 +0100
58.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
58.3 @@ -1,68 +0,0 @@
58.4 -<?xml version="1.0" encoding="UTF-8"?>
58.5 -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
58.6 -<filesystem>
58.7 - <folder name="Actions">
58.8 - <folder name="Refactoring">
58.9 - <file name="org-netbeans-modules-jackpot30-impl-duplicates-GlobalFindDuplicates.instance">
58.10 - <attr name="delegate" newvalue="org.netbeans.modules.jackpot30.impl.duplicates.GlobalFindDuplicates"/>
58.11 - <attr name="displayName" bundlevalue="org.netbeans.modules.jackpot30.impl.duplicates.Bundle#CTL_GlobalFindDuplicates"/>
58.12 - <attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/>
58.13 - <attr name="noIconInMenu" boolvalue="false"/>
58.14 - </file>
58.15 - <file name="org-netbeans-modules-jackpot30-impl-refactoring-ApplyPatternAction.instance">
58.16 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.jackpot30.impl.resources.Bundle"/>
58.17 - <attr name="delegate" newvalue="org.netbeans.modules.jackpot30.impl.refactoring.ApplyPatternAction"/>
58.18 - <attr name="displayName" bundlevalue="org.netbeans.modules.jackpot30.impl.refactoring.Bundle#CTL_ApplyPatternAction"/>
58.19 - <attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/>
58.20 - <attr name="noIconInMenu" boolvalue="false"/>
58.21 - </file>
58.22 - <file name="org-netbeans-modules-jackpot30-impl-refactoring-FindOccurrencesAction.instance">
58.23 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.jackpot30.impl.resources.Bundle"/>
58.24 - <attr name="delegate" newvalue="org.netbeans.modules.jackpot30.impl.refactoring.FindOccurrencesAction"/>
58.25 - <attr name="displayName" bundlevalue="org.netbeans.modules.jackpot30.impl.refactoring.Bundle#CTL_FindOccurrencesAction"/>
58.26 - <attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/>
58.27 - <attr name="noIconInMenu" boolvalue="false"/>
58.28 - </file>
58.29 - <file name="org-netbeans-modules-jackpot30-impl-refactoring-upgrade-UpgradeAction.instance">
58.30 - <attr name="delegate" newvalue="org.netbeans.modules.jackpot30.impl.refactoring.upgrade.UpgradeAction"/>
58.31 - <attr name="displayName" bundlevalue="org.netbeans.modules.jackpot30.impl.refactoring.upgrade.Bundle#CTL_UpgradeAction"/>
58.32 - <attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/>
58.33 - <attr name="noIconInMenu" boolvalue="false"/>
58.34 - </file>
58.35 - </folder>
58.36 - </folder>
58.37 -
58.38 - <!--XXX:-->
58.39 - <folder name="Menu">
58.40 - <folder name="Edit">
58.41 - <file name="org-netbeans-modules-jackpot30-impl-refactoring-FindOccurrencesAction.shadow">
58.42 - <attr name="originalFile" stringvalue="Actions/Refactoring/org-netbeans-modules-jackpot30-impl-refactoring-FindOccurrencesAction.instance"/>
58.43 - <attr name="position" intvalue="2250"/>
58.44 - </file>
58.45 - </folder>
58.46 - <folder name="Refactoring">
58.47 - <file name="org-netbeans-modules-jackpot30-impl-duplicates-GlobalFindDuplicates.shadow">
58.48 - <attr name="originalFile" stringvalue="Actions/Refactoring/org-netbeans-modules-jackpot30-impl-duplicates-GlobalFindDuplicates.instance"/>
58.49 - <attr name="position" intvalue="2300"/>
58.50 - </file>
58.51 - <file name="org-netbeans-modules-jackpot30-impl-refactoring-ApplyPatternAction.shadow">
58.52 - <attr name="originalFile" stringvalue="Actions/Refactoring/org-netbeans-modules-jackpot30-impl-refactoring-ApplyPatternAction.instance"/>
58.53 - <attr name="position" intvalue="2200"/>
58.54 - </file>
58.55 - <file name="org-netbeans-modules-jackpot30-impl-refactoring-upgrade-UpgradeAction.shadow">
58.56 - <attr name="originalFile" stringvalue="Actions/Refactoring/org-netbeans-modules-jackpot30-impl-refactoring-upgrade-UpgradeAction.instance"/>
58.57 - <attr name="position" intvalue="2187"/>
58.58 - </file>
58.59 - </folder>
58.60 - </folder>
58.61 -
58.62 - <folder name="Editors">
58.63 - <folder name="text">
58.64 - <folder name="x-java">
58.65 - <file name="org-netbeans-modules-jackpot30-impl-hints-HintsInvoker$FactoryImpl.instance"/>
58.66 - <file name="org-netbeans-modules-jackpot30-impl-indexing-CustomIndexerImpl$CustomIndexerFactoryImpl.instance"/>
58.67 - <file name="org-netbeans-modules-jackpot30-impl-duplicates-indexing-DuplicatesCustomIndexerImpl$FactoryImpl.instance"/>
58.68 - </folder>
58.69 - </folder>
58.70 - </folder>
58.71 -</filesystem>
59.1 Binary file api/src/org/netbeans/modules/jackpot30/impl/resources/recent_icon.png has changed
60.1 --- a/api/src/org/netbeans/modules/jackpot30/spi/Hacks.java Fri Jan 27 13:35:56 2012 +0100
60.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
60.3 @@ -1,89 +0,0 @@
60.4 -/*
60.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
60.6 - *
60.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
60.8 - *
60.9 - * The contents of this file are subject to the terms of either the GNU
60.10 - * General Public License Version 2 only ("GPL") or the Common
60.11 - * Development and Distribution License("CDDL") (collectively, the
60.12 - * "License"). You may not use this file except in compliance with the
60.13 - * License. You can obtain a copy of the License at
60.14 - * http://www.netbeans.org/cddl-gplv2.html
60.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
60.16 - * specific language governing permissions and limitations under the
60.17 - * License. When distributing the software, include this License Header
60.18 - * Notice in each file and include the License file at
60.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
60.20 - * particular file as subject to the "Classpath" exception as provided
60.21 - * by Sun in the GPL Version 2 section of the License file that
60.22 - * accompanied this code. If applicable, add the following below the
60.23 - * License Header, with the fields enclosed by brackets [] replaced by
60.24 - * your own identifying information:
60.25 - * "Portions Copyrighted [year] [name of copyright owner]"
60.26 - *
60.27 - * If you wish your version of this file to be governed by only the CDDL
60.28 - * or only the GPL Version 2, indicate your decision by adding
60.29 - * "[Contributor] elects to include this software in this distribution
60.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
60.31 - * single choice of license, a recipient has the option to distribute
60.32 - * your version of this file under either the CDDL, the GPL Version 2 or
60.33 - * to extend the choice of license to its licensees as provided above.
60.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
60.35 - * Version 2 license, then the option applies only if the new code is
60.36 - * made subject to such option by the copyright holder.
60.37 - *
60.38 - * Contributor(s):
60.39 - *
60.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
60.41 - */
60.42 -
60.43 -package org.netbeans.modules.jackpot30.spi;
60.44 -
60.45 -import com.sun.source.util.TreePath;
60.46 -import java.util.ArrayList;
60.47 -import java.util.Collections;
60.48 -import java.util.LinkedList;
60.49 -import java.util.List;
60.50 -import java.util.Set;
60.51 -import java.util.concurrent.atomic.AtomicBoolean;
60.52 -import java.util.prefs.Preferences;
60.53 -import org.netbeans.api.java.source.WorkingCopy;
60.54 -import org.netbeans.api.project.Project;
60.55 -import org.netbeans.modules.java.hints.jackpot.impl.MessageImpl;
60.56 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchUtilities;
60.57 -import org.netbeans.modules.java.hints.jackpot.impl.hints.HintsInvoker;
60.58 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
60.59 -import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata;
60.60 -import org.netbeans.spi.editor.hints.ErrorDescription;
60.61 -import org.openide.util.Exceptions;
60.62 -
60.63 -/**
60.64 - *
60.65 - * @author lahvac
60.66 - */
60.67 -public class Hacks {
60.68 -
60.69 - public static interface HintPreferencesProvider {
60.70 - public Preferences findPreferences(HintMetadata hm);
60.71 - }
60.72 -
60.73 - public static void findHintsAndApplyFixes(WorkingCopy copy, Iterable<? extends HintDescription> hints, TreePath on, AtomicBoolean cancel) {
60.74 - HintsInvoker inv = new HintsInvoker(copy, cancel);
60.75 - List<ErrorDescription> errs = new ArrayList<ErrorDescription>(inv.computeHints(copy, hints));
60.76 - List<MessageImpl> problems = new LinkedList<MessageImpl>();
60.77 -
60.78 - try {
60.79 - if (BatchUtilities.applyFixes(copy, Collections.<Project, Set<String>>emptyMap(), errs, problems)) {
60.80 - throw new IllegalStateException();
60.81 - }
60.82 - } catch (IllegalStateException ex) {
60.83 - Exceptions.printStackTrace(ex);
60.84 - } catch (Exception ex) {
60.85 - Exceptions.printStackTrace(ex);
60.86 - }
60.87 -
60.88 - if (!problems.isEmpty()) {
60.89 - throw new IllegalStateException(problems.get(0).text);
60.90 - }
60.91 - }
60.92 -}
61.1 --- a/api/src/org/netbeans/modules/jackpot30/spi/refactoring/JackpotBasedRefactoring.java Fri Jan 27 13:35:56 2012 +0100
61.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
61.3 @@ -1,210 +0,0 @@
61.4 -/*
61.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
61.6 - *
61.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
61.8 - *
61.9 - * The contents of this file are subject to the terms of either the GNU
61.10 - * General Public License Version 2 only ("GPL") or the Common
61.11 - * Development and Distribution License("CDDL") (collectively, the
61.12 - * "License"). You may not use this file except in compliance with the
61.13 - * License. You can obtain a copy of the License at
61.14 - * http://www.netbeans.org/cddl-gplv2.html
61.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
61.16 - * specific language governing permissions and limitations under the
61.17 - * License. When distributing the software, include this License Header
61.18 - * Notice in each file and include the License file at
61.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
61.20 - * particular file as subject to the "Classpath" exception as provided
61.21 - * by Sun in the GPL Version 2 section of the License file that
61.22 - * accompanied this code. If applicable, add the following below the
61.23 - * License Header, with the fields enclosed by brackets [] replaced by
61.24 - * your own identifying information:
61.25 - * "Portions Copyrighted [year] [name of copyright owner]"
61.26 - *
61.27 - * If you wish your version of this file to be governed by only the CDDL
61.28 - * or only the GPL Version 2, indicate your decision by adding
61.29 - * "[Contributor] elects to include this software in this distribution
61.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
61.31 - * single choice of license, a recipient has the option to distribute
61.32 - * your version of this file under either the CDDL, the GPL Version 2 or
61.33 - * to extend the choice of license to its licensees as provided above.
61.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
61.35 - * Version 2 license, then the option applies only if the new code is
61.36 - * made subject to such option by the copyright holder.
61.37 - *
61.38 - * Contributor(s):
61.39 - *
61.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
61.41 - */
61.42 -
61.43 -package org.netbeans.modules.jackpot30.spi.refactoring;
61.44 -
61.45 -import java.io.File;
61.46 -import java.io.IOException;
61.47 -import java.util.Arrays;
61.48 -import java.util.Collection;
61.49 -import java.util.Collections;
61.50 -import java.util.EnumSet;
61.51 -import java.util.HashMap;
61.52 -import java.util.LinkedList;
61.53 -import java.util.List;
61.54 -import java.util.Map;
61.55 -import java.util.Set;
61.56 -import java.util.concurrent.atomic.AtomicBoolean;
61.57 -import javax.swing.text.Document;
61.58 -import javax.swing.text.Position.Bias;
61.59 -import javax.tools.JavaFileObject;
61.60 -import org.netbeans.api.java.classpath.ClassPath;
61.61 -import org.netbeans.api.java.source.ModificationResult;
61.62 -import org.netbeans.api.java.source.ModificationResult.Difference;
61.63 -import org.netbeans.api.java.source.TreePathHandle;
61.64 -import org.netbeans.api.queries.FileEncodingQuery;
61.65 -import org.netbeans.modules.jackpot30.impl.refactoring.RetoucheCommit;
61.66 -import org.netbeans.modules.java.hints.jackpot.impl.MessageImpl;
61.67 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch;
61.68 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.BatchResult;
61.69 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchUtilities;
61.70 -import org.netbeans.modules.java.hints.jackpot.impl.batch.ProgressHandleWrapper;
61.71 -import org.netbeans.modules.java.hints.jackpot.impl.batch.Scopes;
61.72 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
61.73 -import org.netbeans.modules.java.hints.jackpot.spi.PatternConvertor;
61.74 -import org.netbeans.modules.java.source.JavaSourceAccessor;
61.75 -import org.netbeans.modules.java.source.parsing.FileObjects;
61.76 -import org.netbeans.modules.refactoring.api.AbstractRefactoring;
61.77 -import org.netbeans.modules.refactoring.api.Problem;
61.78 -import org.netbeans.modules.refactoring.java.spi.DiffElement;
61.79 -import org.netbeans.modules.refactoring.spi.RefactoringElementsBag;
61.80 -import org.netbeans.modules.refactoring.spi.RefactoringPlugin;
61.81 -import org.openide.filesystems.FileObject;
61.82 -import org.openide.filesystems.FileUtil;
61.83 -import org.openide.loaders.DataObject;
61.84 -import org.openide.text.CloneableEditorSupport;
61.85 -import org.openide.text.PositionRef;
61.86 -import org.openide.util.Exceptions;
61.87 -
61.88 -/**
61.89 - *
61.90 - * @author lahvac
61.91 - */
61.92 -public abstract class JackpotBasedRefactoring implements RefactoringPlugin {
61.93 -
61.94 - protected final AtomicBoolean cancel = new AtomicBoolean();
61.95 -
61.96 - private final AbstractRefactoring refactoring;
61.97 -
61.98 - protected JackpotBasedRefactoring(AbstractRefactoring refactoring) {
61.99 - this.refactoring = refactoring;
61.100 - }
61.101 -
61.102 - public final void cancelRequest() {
61.103 - cancel.set(true);
61.104 - }
61.105 -
61.106 - public final Problem prepare(RefactoringElementsBag refactoringElements) {
61.107 - TreePathHandle tph = refactoring.getRefactoringSource().lookup(TreePathHandle.class);
61.108 - FileObject file = tph.getFileObject();
61.109 - ClassPath source = ClassPath.getClassPath(file, ClassPath.SOURCE);
61.110 - FileObject sourceRoot = source.findOwnerRoot(file);
61.111 -
61.112 - Collection<MessageImpl> problems = new LinkedList<MessageImpl>();
61.113 - Context result = new Context();
61.114 - prepareAndConstructRule(result);
61.115 - Collection<ModificationResult> modifications = new LinkedList<ModificationResult>(result.modifications);
61.116 - Collection<HintDescription> hints = new LinkedList<HintDescription>();
61.117 - Map<FileObject, List<Difference>> scriptDifferences = new HashMap<FileObject, List<Difference>>();
61.118 - for (ScriptDescription s : result.scripts) {
61.119 - if (s.options.contains(ScriptOptions.RUN)) {
61.120 - for (HintDescription c : PatternConvertor.create(s.code)) {
61.121 - hints.add(c);
61.122 - }
61.123 - }
61.124 - if (s.options.contains(ScriptOptions.STORE)) {
61.125 - createDifference(sourceRoot, file, s, scriptDifferences);
61.126 - }
61.127 - }
61.128 - if (!scriptDifferences.isEmpty()) {
61.129 - modifications.add(JavaSourceAccessor.getINSTANCE().createModificationResult(scriptDifferences, Collections.<Object, int[]>emptyMap()));
61.130 - }
61.131 - BatchResult batchResult = BatchSearch.findOccurrences(hints, Scopes.allOpenedProjectsScope());
61.132 - modifications.addAll(BatchUtilities.applyFixes(batchResult, new ProgressHandleWrapper(1, 1), cancel, problems));
61.133 -
61.134 - createAndAddElements(refactoringElements, modifications);
61.135 -
61.136 - return null;//XXX
61.137 - }
61.138 -
61.139 - protected abstract void prepareAndConstructRule(Context result);
61.140 -
61.141 - private void createAndAddElements(RefactoringElementsBag elements, Collection<ModificationResult> results) {
61.142 - elements.registerTransaction(new RetoucheCommit(results));
61.143 - for (ModificationResult result:results) {
61.144 - for (FileObject jfo : result.getModifiedFileObjects()) {
61.145 - for (Difference diff: result.getDifferences(jfo)) {
61.146 - elements.add(refactoring,DiffElement.create(diff, jfo, result));
61.147 - }
61.148 - }
61.149 - }
61.150 - }
61.151 -
61.152 - private static void createDifference(FileObject sourceRoot, FileObject origFile, ScriptDescription sd, Map<FileObject, List<Difference>> scriptDifferences) {
61.153 - String relPath = "META-INF/upgrade/" + sd.name + ".hint";
61.154 - FileObject hintFile = sourceRoot.getFileObject(relPath);
61.155 - List<Difference> diffs = scriptDifferences.get(hintFile != null ? hintFile : origFile);
61.156 -
61.157 - if (diffs == null) {
61.158 - scriptDifferences.put(hintFile != null ? hintFile : origFile, diffs = new LinkedList<Difference>());
61.159 - }
61.160 -
61.161 - if (hintFile != null) {
61.162 - //append:
61.163 - try {
61.164 - CloneableEditorSupport ces = DataObject.find(hintFile).getLookup().lookup(CloneableEditorSupport.class);
61.165 - Document doc = ces.openDocument();
61.166 - PositionRef pos = ces.createPositionRef(doc.getLength(), Bias.Forward);
61.167 -
61.168 - diffs.add(JavaSourceAccessor.getINSTANCE().createDifference(Difference.Kind.INSERT, pos, pos, "", sd.code, null));
61.169 - } catch (IOException ex) {
61.170 - //XXX:
61.171 - Exceptions.printStackTrace(ex);
61.172 - }
61.173 - } else {
61.174 - File root = FileUtil.toFile(sourceRoot);
61.175 - JavaFileObject jfo = FileObjects.fileFileObject(new File(root, relPath), root, null, FileEncodingQuery.getEncoding(sourceRoot));
61.176 -
61.177 - diffs.add(JavaSourceAccessor.getINSTANCE().createNewFileDifference(jfo, sd.code));
61.178 - }
61.179 - }
61.180 -
61.181 - public static final class Context {
61.182 - private final Collection<ModificationResult> modifications = new LinkedList<ModificationResult>();
61.183 - private final Collection<ScriptDescription> scripts = new LinkedList<ScriptDescription>();
61.184 -
61.185 - public void addModificationResult(ModificationResult r) {
61.186 - modifications.add(r);
61.187 - }
61.188 -
61.189 - public void addScript(String name, String code, ScriptOptions... options) {
61.190 - Set<ScriptOptions> optionsSet = EnumSet.noneOf(ScriptOptions.class);
61.191 - optionsSet.addAll(Arrays.asList(options));
61.192 - scripts.add(new ScriptDescription(name, code, optionsSet));
61.193 - }
61.194 - }
61.195 -
61.196 - private static final class ScriptDescription {
61.197 - private final String name;
61.198 - private final String code;
61.199 - private final Set<ScriptOptions> options;
61.200 -
61.201 - public ScriptDescription(String name, String code, Set<ScriptOptions> run) {
61.202 - this.name = name;
61.203 - this.code = code;
61.204 - this.options = run;
61.205 - }
61.206 -
61.207 - }
61.208 -
61.209 - public enum ScriptOptions {
61.210 - STORE,
61.211 - RUN;
61.212 - }
61.213 -}
62.1 --- a/api/test/unit/src/org/netbeans/modules/jackpot30/impl/TestBase.java Fri Jan 27 13:35:56 2012 +0100
62.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
62.3 @@ -1,120 +0,0 @@
62.4 -/*
62.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
62.6 - *
62.7 - * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
62.8 - *
62.9 - * The contents of this file are subject to the terms of either the GNU
62.10 - * General Public License Version 2 only ("GPL") or the Common
62.11 - * Development and Distribution License("CDDL") (collectively, the
62.12 - * "License"). You may not use this file except in compliance with the
62.13 - * License. You can obtain a copy of the License at
62.14 - * http://www.netbeans.org/cddl-gplv2.html
62.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
62.16 - * specific language governing permissions and limitations under the
62.17 - * License. When distributing the software, include this License Header
62.18 - * Notice in each file and include the License file at
62.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
62.20 - * particular file as subject to the "Classpath" exception as provided
62.21 - * by Sun in the GPL Version 2 section of the License file that
62.22 - * accompanied this code. If applicable, add the following below the
62.23 - * License Header, with the fields enclosed by brackets [] replaced by
62.24 - * your own identifying information:
62.25 - * "Portions Copyrighted [year] [name of copyright owner]"
62.26 - *
62.27 - * If you wish your version of this file to be governed by only the CDDL
62.28 - * or only the GPL Version 2, indicate your decision by adding
62.29 - * "[Contributor] elects to include this software in this distribution
62.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
62.31 - * single choice of license, a recipient has the option to distribute
62.32 - * your version of this file under either the CDDL, the GPL Version 2 or
62.33 - * to extend the choice of license to its licensees as provided above.
62.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
62.35 - * Version 2 license, then the option applies only if the new code is
62.36 - * made subject to such option by the copyright holder.
62.37 - *
62.38 - * Contributor(s):
62.39 - *
62.40 - * Portions Copyrighted 2008-2009 Sun Microsystems, Inc.
62.41 - */
62.42 -
62.43 -package org.netbeans.modules.jackpot30.impl;
62.44 -
62.45 -import java.io.File;
62.46 -import javax.swing.text.Document;
62.47 -import org.netbeans.api.java.lexer.JavaTokenId;
62.48 -import org.netbeans.api.java.source.CompilationInfo;
62.49 -import org.netbeans.api.java.source.JavaSource;
62.50 -import org.netbeans.api.java.source.JavaSource.Phase;
62.51 -import org.netbeans.api.java.source.SourceUtilsTestUtil;
62.52 -import org.netbeans.api.java.source.TestUtilities;
62.53 -import org.netbeans.api.lexer.Language;
62.54 -import org.netbeans.junit.NbTestCase;
62.55 -import org.netbeans.modules.java.source.TreeLoader;
62.56 -import org.openide.cookies.EditorCookie;
62.57 -import org.openide.filesystems.FileObject;
62.58 -import org.openide.filesystems.FileUtil;
62.59 -import org.openide.loaders.DataObject;
62.60 -
62.61 -/**
62.62 - *
62.63 - * @author Jan Lahoda
62.64 - */
62.65 -public class TestBase extends NbTestCase {
62.66 -
62.67 - public TestBase(String name) {
62.68 - super(name);
62.69 - }
62.70 -
62.71 - @Override
62.72 - protected void setUp() throws Exception {
62.73 - super.setUp();
62.74 - SourceUtilsTestUtil.prepareTest(new String[0], new Object[0]);
62.75 - TreeLoader.DISABLE_CONFINEMENT_TEST = true;
62.76 - }
62.77 -
62.78 - protected void prepareTest(String fileName, String code) throws Exception {
62.79 - clearWorkDir();
62.80 -
62.81 - FileUtil.refreshFor(File.listRoots());
62.82 -
62.83 - FileObject workFO = FileUtil.toFileObject(getWorkDir());
62.84 -
62.85 - assertNotNull(workFO);
62.86 -
62.87 - workFO.refresh();
62.88 -
62.89 - sourceRoot = workFO.createFolder("src");
62.90 - FileObject buildRoot = workFO.createFolder("build");
62.91 - FileObject cache = workFO.createFolder("cache");
62.92 -
62.93 - FileObject data = FileUtil.createData(sourceRoot, fileName);
62.94 - File dataFile = FileUtil.toFile(data);
62.95 -
62.96 - assertNotNull(dataFile);
62.97 -
62.98 - TestUtilities.copyStringToFile(dataFile, code);
62.99 -
62.100 - SourceUtilsTestUtil.prepareTest(sourceRoot, buildRoot, cache);
62.101 -
62.102 - DataObject od = DataObject.find(data);
62.103 - EditorCookie ec = od.getLookup().lookup(EditorCookie.class);
62.104 -
62.105 - assertNotNull(ec);
62.106 -
62.107 - doc = ec.openDocument();
62.108 - doc.putProperty(Language.class, JavaTokenId.language());
62.109 -
62.110 - JavaSource js = JavaSource.forFileObject(data);
62.111 -
62.112 - assertNotNull(js);
62.113 -
62.114 - info = SourceUtilsTestUtil.getCompilationInfo(js, Phase.RESOLVED);
62.115 -
62.116 - assertNotNull(info);
62.117 - }
62.118 -
62.119 - protected FileObject sourceRoot;
62.120 - protected CompilationInfo info;
62.121 - protected Document doc;
62.122 -
62.123 -}
63.1 --- a/api/test/unit/src/org/netbeans/modules/jackpot30/impl/duplicates/ComputeDuplicatesTest.java Fri Jan 27 13:35:56 2012 +0100
63.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
63.3 @@ -1,118 +0,0 @@
63.4 -/*
63.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
63.6 - *
63.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
63.8 - *
63.9 - * The contents of this file are subject to the terms of either the GNU
63.10 - * General Public License Version 2 only ("GPL") or the Common
63.11 - * Development and Distribution License("CDDL") (collectively, the
63.12 - * "License"). You may not use this file except in compliance with the
63.13 - * License. You can obtain a copy of the License at
63.14 - * http://www.netbeans.org/cddl-gplv2.html
63.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
63.16 - * specific language governing permissions and limitations under the
63.17 - * License. When distributing the software, include this License Header
63.18 - * Notice in each file and include the License file at
63.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
63.20 - * particular file as subject to the "Classpath" exception as provided
63.21 - * by Sun in the GPL Version 2 section of the License file that
63.22 - * accompanied this code. If applicable, add the following below the
63.23 - * License Header, with the fields enclosed by brackets [] replaced by
63.24 - * your own identifying information:
63.25 - * "Portions Copyrighted [year] [name of copyright owner]"
63.26 - *
63.27 - * If you wish your version of this file to be governed by only the CDDL
63.28 - * or only the GPL Version 2, indicate your decision by adding
63.29 - * "[Contributor] elects to include this software in this distribution
63.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
63.31 - * single choice of license, a recipient has the option to distribute
63.32 - * your version of this file under either the CDDL, the GPL Version 2 or
63.33 - * to extend the choice of license to its licensees as provided above.
63.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
63.35 - * Version 2 license, then the option applies only if the new code is
63.36 - * made subject to such option by the copyright holder.
63.37 - *
63.38 - * Contributor(s):
63.39 - *
63.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
63.41 - */
63.42 -
63.43 -package org.netbeans.modules.jackpot30.impl.duplicates;
63.44 -
63.45 -import org.netbeans.api.progress.ProgressHandle;
63.46 -import org.openide.filesystems.FileObject;
63.47 -import java.util.HashMap;
63.48 -import java.util.LinkedList;
63.49 -import java.util.Map;
63.50 -import java.util.concurrent.atomic.AtomicBoolean;
63.51 -import org.netbeans.api.java.source.TestUtilities;
63.52 -import org.netbeans.api.progress.ProgressHandleFactory;
63.53 -import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.DuplicateDescription;
63.54 -import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.Span;
63.55 -import org.netbeans.modules.jackpot30.impl.indexing.IndexTestBase;
63.56 -import org.netbeans.modules.jackpot30.impl.indexing.IndexingTestUtils.File;
63.57 -import org.openide.filesystems.FileUtil;
63.58 -import org.openide.util.NbCollections;
63.59 -import static org.junit.Assert.*;
63.60 -
63.61 -import static org.netbeans.modules.jackpot30.impl.indexing.IndexingTestUtils.writeFilesAndWaitForScan;
63.62 -
63.63 -/**
63.64 - *
63.65 - * @author lahvac
63.66 - */
63.67 -public class ComputeDuplicatesTest extends IndexTestBase {
63.68 -
63.69 - public ComputeDuplicatesTest(String name) {
63.70 - super(name);
63.71 - }
63.72 -
63.73 - public void testDuplicateDuplicates() throws Exception {
63.74 - writeFilesAndWaitForScan(src,
63.75 - new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }"),
63.76 - new File("test/Test2.java", "package test; public class Test2 { private int a; private void test() { java.io.File f = null; f.isDirectory(); } }"));
63.77 -
63.78 - verifyDuplicates("test/Test1.java",
63.79 - "private void test() { java.io.File f = null; f.isDirectory(); }",
63.80 - "test/Test2.java",
63.81 - "private void test() { java.io.File f = null; f.isDirectory(); }");
63.82 - }
63.83 -
63.84 - public void testCrossIndex() throws Exception {
63.85 - writeFilesAndWaitForScan(src,
63.86 - new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }"));
63.87 -
63.88 - writeFilesAndWaitForScan(src2,
63.89 - new File("test/Test2.java", "package test; public class Test2 { private int a; private void test() { java.io.File f = null; f.isDirectory(); } }"));
63.90 -
63.91 - verifyDuplicates("test/Test1.java",
63.92 - "private void test() { java.io.File f = null; f.isDirectory(); }",
63.93 - "test/Test2.java",
63.94 - "private void test() { java.io.File f = null; f.isDirectory(); }");
63.95 - }
63.96 -
63.97 - private void verifyDuplicates(String... fileAndDuplicateCode) throws Exception {
63.98 - Map<String, String> duplicatesGolden = new HashMap<String, String>();
63.99 -
63.100 - for (int cntr = 0; cntr < fileAndDuplicateCode.length; cntr += 2) {
63.101 - duplicatesGolden.put(fileAndDuplicateCode[cntr], fileAndDuplicateCode[cntr + 1]);
63.102 - }
63.103 -
63.104 - Map<String, String> duplicatesReal = new HashMap<String, String>();
63.105 - ProgressHandle handle = ProgressHandleFactory.createHandle("test");
63.106 -
63.107 - handle.start();
63.108 -
63.109 - for (DuplicateDescription dd : NbCollections.iterable(new ComputeDuplicates().computeDuplicatesForAllOpenedProjects(handle, new AtomicBoolean()))) {
63.110 - for (Span s : dd.dupes) {
63.111 - duplicatesReal.put(relativePath(s.file), TestUtilities.copyFileToString(FileUtil.toFile(s.file)).substring(s.startOff, s.endOff));
63.112 - }
63.113 - }
63.114 -
63.115 - assertEquals(duplicatesGolden, duplicatesReal);
63.116 - }
63.117 -
63.118 - private String relativePath(FileObject file) {
63.119 - return FileUtil.isParentOf(src, file) ? FileUtil.getRelativePath(src, file) : FileUtil.getRelativePath(src2, file);
63.120 - }
63.121 -}
63.122 \ No newline at end of file
64.1 --- a/api/test/unit/src/org/netbeans/modules/jackpot30/impl/duplicates/indexing/RemoteDuplicatesIndexTest.java Fri Jan 27 13:35:56 2012 +0100
64.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
64.3 @@ -1,133 +0,0 @@
64.4 -/*
64.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
64.6 - *
64.7 - * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
64.8 - *
64.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
64.10 - * Other names may be trademarks of their respective owners.
64.11 - *
64.12 - * The contents of this file are subject to the terms of either the GNU
64.13 - * General Public License Version 2 only ("GPL") or the Common
64.14 - * Development and Distribution License("CDDL") (collectively, the
64.15 - * "License"). You may not use this file except in compliance with the
64.16 - * License. You can obtain a copy of the License at
64.17 - * http://www.netbeans.org/cddl-gplv2.html
64.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
64.19 - * specific language governing permissions and limitations under the
64.20 - * License. When distributing the software, include this License Header
64.21 - * Notice in each file and include the License file at
64.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
64.23 - * particular file as subject to the "Classpath" exception as provided
64.24 - * by Oracle in the GPL Version 2 section of the License file that
64.25 - * accompanied this code. If applicable, add the following below the
64.26 - * License Header, with the fields enclosed by brackets [] replaced by
64.27 - * your own identifying information:
64.28 - * "Portions Copyrighted [year] [name of copyright owner]"
64.29 - *
64.30 - * If you wish your version of this file to be governed by only the CDDL
64.31 - * or only the GPL Version 2, indicate your decision by adding
64.32 - * "[Contributor] elects to include this software in this distribution
64.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
64.34 - * single choice of license, a recipient has the option to distribute
64.35 - * your version of this file under either the CDDL, the GPL Version 2 or
64.36 - * to extend the choice of license to its licensees as provided above.
64.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
64.38 - * Version 2 license, then the option applies only if the new code is
64.39 - * made subject to such option by the copyright holder.
64.40 - *
64.41 - * Contributor(s):
64.42 - *
64.43 - * Portions Copyrighted 2011 Sun Microsystems, Inc.
64.44 - */
64.45 -package org.netbeans.modules.jackpot30.impl.duplicates.indexing;
64.46 -
64.47 -import java.io.File;
64.48 -import java.net.URL;
64.49 -import java.util.ArrayList;
64.50 -import java.util.Arrays;
64.51 -import java.util.HashMap;
64.52 -import java.util.List;
64.53 -import java.util.Map;
64.54 -import org.netbeans.api.java.source.TestUtilities;
64.55 -import static org.junit.Assert.*;
64.56 -import org.netbeans.api.java.source.SourceUtilsTestUtil;
64.57 -import org.netbeans.core.startup.Main;
64.58 -import org.netbeans.junit.NbTestCase;
64.59 -import org.netbeans.modules.jackpot30.impl.TestUtils;
64.60 -import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.DuplicateDescription;
64.61 -import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.Span;
64.62 -import org.netbeans.modules.jackpot30.impl.indexing.Cache;
64.63 -import org.netbeans.modules.jackpot30.remoting.api.RemoteIndex;
64.64 -import org.openide.filesystems.FileObject;
64.65 -import org.openide.filesystems.FileUtil;
64.66 -
64.67 -/**
64.68 - *
64.69 - * @author lahvac
64.70 - */
64.71 -public class RemoteDuplicatesIndexTest extends NbTestCase {
64.72 -
64.73 - public RemoteDuplicatesIndexTest(String name) {
64.74 - super(name);
64.75 - }
64.76 -
64.77 - public void setUp() throws Exception {
64.78 - SourceUtilsTestUtil.prepareTest(new String[0], new Object[0]);
64.79 - Main.initializeURLFactory();
64.80 - TestUtils.clearRemoteContent();
64.81 - super.setUp();
64.82 - }
64.83 -
64.84 - public void testFindHashOccurrences() throws Exception {
64.85 - clearWorkDir();
64.86 - File cacheDir = new File(getWorkDir(), "cache");
64.87 - File dataDir = new File(getWorkDir(), "data");
64.88 -
64.89 - Cache.setStandaloneCacheRoot(cacheDir);
64.90 -
64.91 - FileObject data1 = FileUtil.createFolder(new File(dataDir, "data1"));
64.92 - FileObject data2 = FileUtil.createFolder(new File(dataDir, "data2"));
64.93 - FileObject source = FileUtil.createData(new File(dataDir, "src/Test.java"));
64.94 -
64.95 - TestUtilities.copyStringToFile(data1.createData("T1.java"), "0123456789");
64.96 - TestUtilities.copyStringToFile(data1.createData("T2.java"), "0123456789");
64.97 - TestUtilities.copyStringToFile(data2.createData("T3.java"), "0123456789");
64.98 - TestUtilities.copyStringToFile(data2.createData("T4.java"), "0123456789");
64.99 -
64.100 - TestUtils.addRemoteContent(new URL("test://test/index/findDuplicates?hashes=[%0A%20%20%20%20%2200%22,%0A%20%20%20%20%2201%22,%0A%20%20%20%20%2202%22%0A]"), "{ \"00\": { \"foo1\": [ \"T1.java\", \"T2.java\" ], \"foo2\": [ \"T3.java\", \"T4.java\" ] } }");
64.101 - RemoteIndex.saveIndices(Arrays.asList(RemoteIndex.create(FileUtil.toFile(data1).toURI().toURL(), new URL("test://test/index"), "foo1"),
64.102 - RemoteIndex.create(FileUtil.toFile(data2).toURI().toURL(), new URL("test://test/index"), "foo2")));
64.103 -
64.104 - TestUtilities.copyStringToFile(source, "01234567890123456789");
64.105 -
64.106 - Map<String, long[]> hashes = new HashMap<String, long[]>();
64.107 -
64.108 - hashes.put("00", new long[] {1, 2, 5, 6});
64.109 - hashes.put("01", new long[] {8, 9});
64.110 - hashes.put("02", new long[] {3, 4});
64.111 -
64.112 - List<DuplicateDescription> duplicates = RemoteDuplicatesIndex.findDuplicates(hashes, source);
64.113 - List<String> duplicatesReal = new ArrayList<String>();
64.114 -
64.115 - for (DuplicateDescription dd : duplicates) {
64.116 - for (Span s : dd.dupes) {
64.117 - duplicatesReal.add(s.file.getName());
64.118 - }
64.119 - }
64.120 -
64.121 - assertEquals(Arrays.asList("T2", "T1", "T4", "T3"), duplicatesReal);
64.122 -
64.123 - //check local cache:
64.124 - duplicates = RemoteDuplicatesIndex.findDuplicates(hashes, source);
64.125 - duplicatesReal = new ArrayList<String>();
64.126 -
64.127 - for (DuplicateDescription dd : duplicates) {
64.128 - for (Span s : dd.dupes) {
64.129 - duplicatesReal.add(s.file.getName());
64.130 - }
64.131 - }
64.132 -
64.133 - assertEquals(Arrays.asList("T2", "T1", "T4", "T3"), duplicatesReal);
64.134 - }
64.135 -
64.136 -}
65.1 --- a/api/test/unit/src/org/netbeans/modules/jackpot30/impl/examples/LoadExamplesTest.java Fri Jan 27 13:35:56 2012 +0100
65.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
65.3 @@ -1,71 +0,0 @@
65.4 -/*
65.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
65.6 - *
65.7 - * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
65.8 - *
65.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
65.10 - * Other names may be trademarks of their respective owners.
65.11 - *
65.12 - * The contents of this file are subject to the terms of either the GNU
65.13 - * General Public License Version 2 only ("GPL") or the Common
65.14 - * Development and Distribution License("CDDL") (collectively, the
65.15 - * "License"). You may not use this file except in compliance with the
65.16 - * License. You can obtain a copy of the License at
65.17 - * http://www.netbeans.org/cddl-gplv2.html
65.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
65.19 - * specific language governing permissions and limitations under the
65.20 - * License. When distributing the software, include this License Header
65.21 - * Notice in each file and include the License file at
65.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
65.23 - * particular file as subject to the "Classpath" exception as provided
65.24 - * by Oracle in the GPL Version 2 section of the License file that
65.25 - * accompanied this code. If applicable, add the following below the
65.26 - * License Header, with the fields enclosed by brackets [] replaced by
65.27 - * your own identifying information:
65.28 - * "Portions Copyrighted [year] [name of copyright owner]"
65.29 - *
65.30 - * If you wish your version of this file to be governed by only the CDDL
65.31 - * or only the GPL Version 2, indicate your decision by adding
65.32 - * "[Contributor] elects to include this software in this distribution
65.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
65.34 - * single choice of license, a recipient has the option to distribute
65.35 - * your version of this file under either the CDDL, the GPL Version 2 or
65.36 - * to extend the choice of license to its licensees as provided above.
65.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
65.38 - * Version 2 license, then the option applies only if the new code is
65.39 - * made subject to such option by the copyright holder.
65.40 - *
65.41 - * Contributor(s):
65.42 - *
65.43 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
65.44 - */
65.45 -
65.46 -package org.netbeans.modules.jackpot30.impl.examples;
65.47 -
65.48 -import java.util.Arrays;
65.49 -import java.util.LinkedList;
65.50 -import java.util.List;
65.51 -import org.netbeans.junit.NbTestCase;
65.52 -import static org.junit.Assert.*;
65.53 -
65.54 -/**
65.55 - *
65.56 - * @author lahvac
65.57 - */
65.58 -public class LoadExamplesTest extends NbTestCase {
65.59 -
65.60 - public LoadExamplesTest(String name) {
65.61 - super(name);
65.62 - }
65.63 -
65.64 - public void testLoadExamples() {
65.65 - List<String> actual = new LinkedList<String>();
65.66 -
65.67 - for (Example e : LoadExamples.loadExamples("test-examples.list")) {
65.68 - actual.add("" + e.getKey() + ":" + e.getOptions() + ":" + e.getCode());
65.69 - }
65.70 -
65.71 - assertEquals(Arrays.asList("key1:[]:EX1\n", "key2:[VERIFY, FIX]:EX2\n", "key3:[FIX]:EX3\n"), actual);
65.72 - }
65.73 -
65.74 -}
65.75 \ No newline at end of file
66.1 --- a/api/test/unit/src/org/netbeans/modules/jackpot30/impl/examples/test-example1.example Fri Jan 27 13:35:56 2012 +0100
66.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
66.3 @@ -1,6 +0,0 @@
66.4 -%%example=key1
66.5 -EX1
66.6 -%%example=key2,verify,fix
66.7 -EX2
66.8 -%%example=key3,fix
66.9 -EX3
67.1 --- a/api/test/unit/src/org/netbeans/modules/jackpot30/impl/examples/test-examples.list Fri Jan 27 13:35:56 2012 +0100
67.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
67.3 @@ -1,1 +0,0 @@
67.4 -test-example1.example
68.1 --- a/api/test/unit/src/org/netbeans/modules/jackpot30/impl/hints/ExplicitFindDuplicatesTest.java Fri Jan 27 13:35:56 2012 +0100
68.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
68.3 @@ -1,138 +0,0 @@
68.4 -/*
68.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
68.6 - *
68.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
68.8 - *
68.9 - * The contents of this file are subject to the terms of either the GNU
68.10 - * General Public License Version 2 only ("GPL") or the Common
68.11 - * Development and Distribution License("CDDL") (collectively, the
68.12 - * "License"). You may not use this file except in compliance with the
68.13 - * License. You can obtain a copy of the License at
68.14 - * http://www.netbeans.org/cddl-gplv2.html
68.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
68.16 - * specific language governing permissions and limitations under the
68.17 - * License. When distributing the software, include this License Header
68.18 - * Notice in each file and include the License file at
68.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
68.20 - * particular file as subject to the "Classpath" exception as provided
68.21 - * by Sun in the GPL Version 2 section of the License file that
68.22 - * accompanied this code. If applicable, add the following below the
68.23 - * License Header, with the fields enclosed by brackets [] replaced by
68.24 - * your own identifying information:
68.25 - * "Portions Copyrighted [year] [name of copyright owner]"
68.26 - *
68.27 - * If you wish your version of this file to be governed by only the CDDL
68.28 - * or only the GPL Version 2, indicate your decision by adding
68.29 - * "[Contributor] elects to include this software in this distribution
68.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
68.31 - * single choice of license, a recipient has the option to distribute
68.32 - * your version of this file under either the CDDL, the GPL Version 2 or
68.33 - * to extend the choice of license to its licensees as provided above.
68.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
68.35 - * Version 2 license, then the option applies only if the new code is
68.36 - * made subject to such option by the copyright holder.
68.37 - *
68.38 - * Contributor(s):
68.39 - *
68.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
68.41 - */
68.42 -
68.43 -package org.netbeans.modules.jackpot30.impl.hints;
68.44 -
68.45 -import com.sun.source.tree.Tree;
68.46 -import com.sun.tools.javac.tree.JCTree;
68.47 -import java.util.regex.Pattern;
68.48 -import org.netbeans.modules.jackpot30.impl.TestBase;
68.49 -import org.netbeans.modules.java.source.pretty.VeryPretty;
68.50 -import org.netbeans.modules.java.source.save.DiffContext;
68.51 -
68.52 -/**
68.53 - *
68.54 - * @author lahvac
68.55 - */
68.56 -public class ExplicitFindDuplicatesTest extends TestBase {
68.57 -
68.58 - public ExplicitFindDuplicatesTest(String name) {
68.59 - super(name);
68.60 - }
68.61 -
68.62 - public void testLocalVariablesGeneralization() throws Exception {
68.63 - performGeneralizationTest("package test;\n" +
68.64 - "public class Test {\n" +
68.65 - " private void test() {\n" +
68.66 - " |int i = 0;\n" +
68.67 - " i++;\n" +
68.68 - " int j = i;|\n" +
68.69 - " }\n" +
68.70 - "}\n" +
68.71 - "",
68.72 - "{\n" +
68.73 - " $s0$;\n" +
68.74 - " int $0 = 0;\n" +
68.75 - " $0++;\n" +
68.76 - " int $1 = $0;\n" +
68.77 - " $s1$;\n" +
68.78 - "}");
68.79 - }
68.80 -
68.81 - public void testSingleStatementPattern() throws Exception {
68.82 - performGeneralizationTest("package test;\n" +
68.83 - "public class Test {\n" +
68.84 - " private void test() {\n" +
68.85 - " int i = 0;\n" +
68.86 - " |i++;|\n" +
68.87 - " int j = i;\n" +
68.88 - " }\n" +
68.89 - "}\n" +
68.90 - "",
68.91 - "$0++;");
68.92 - }
68.93 -
68.94 - public void testExpressionPattern() throws Exception {
68.95 - performGeneralizationTest("package test;\n" +
68.96 - "public class Test {\n" +
68.97 - " private void test() {\n" +
68.98 - " int i = 0;\n" +
68.99 - " i++;\n" +
68.100 - " int j = |i|;\n" +
68.101 - " }\n" +
68.102 - "}\n" +
68.103 - "",
68.104 - "$0");
68.105 - }
68.106 -
68.107 - public void testVoidMethod() throws Exception {
68.108 - performGeneralizationTest("package test;\n" +
68.109 - "public class Test {\n" +
68.110 - " private void test() {\n" +
68.111 - " |System.err.println()|;\n" +
68.112 - " }\n" +
68.113 - "}\n" +
68.114 - "",
68.115 - "System.err.println()");
68.116 - }
68.117 -
68.118 - private void performGeneralizationTest(String code, String generalized) throws Exception {
68.119 - String[] split = code.split(Pattern.quote("|"));
68.120 -
68.121 - assertEquals(3, split.length);
68.122 -
68.123 - int start = split[0].length();
68.124 - int end = split[1].length() + start;
68.125 -
68.126 - code = split[0] + split[1] + split[2];
68.127 -
68.128 - prepareTest("test/Test.java", code);
68.129 -
68.130 - Tree generalizedTree = ExplicitFindDuplicates.resolveAndGeneralizePattern(info, start, end);
68.131 - VeryPretty vp = new VeryPretty(new DiffContext(info));
68.132 -
68.133 - vp.print((JCTree) generalizedTree);
68.134 -
68.135 - String repr = vp.toString();
68.136 -
68.137 - assertEquals(generalized.replaceAll("[ \n\t]+", " "),
68.138 - repr.replaceAll("[ \n\t]+", " "));
68.139 - }
68.140 -
68.141 -}
68.142 \ No newline at end of file
69.1 --- a/api/test/unit/src/org/netbeans/modules/jackpot30/impl/indexing/CustomIndexerImplTest.java Fri Jan 27 13:35:56 2012 +0100
69.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
69.3 @@ -1,111 +0,0 @@
69.4 -/*
69.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
69.6 - *
69.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
69.8 - *
69.9 - * The contents of this file are subject to the terms of either the GNU
69.10 - * General Public License Version 2 only ("GPL") or the Common
69.11 - * Development and Distribution License("CDDL") (collectively, the
69.12 - * "License"). You may not use this file except in compliance with the
69.13 - * License. You can obtain a copy of the License at
69.14 - * http://www.netbeans.org/cddl-gplv2.html
69.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
69.16 - * specific language governing permissions and limitations under the
69.17 - * License. When distributing the software, include this License Header
69.18 - * Notice in each file and include the License file at
69.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
69.20 - * particular file as subject to the "Classpath" exception as provided
69.21 - * by Sun in the GPL Version 2 section of the License file that
69.22 - * accompanied this code. If applicable, add the following below the
69.23 - * License Header, with the fields enclosed by brackets [] replaced by
69.24 - * your own identifying information:
69.25 - * "Portions Copyrighted [year] [name of copyright owner]"
69.26 - *
69.27 - * If you wish your version of this file to be governed by only the CDDL
69.28 - * or only the GPL Version 2, indicate your decision by adding
69.29 - * "[Contributor] elects to include this software in this distribution
69.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
69.31 - * single choice of license, a recipient has the option to distribute
69.32 - * your version of this file under either the CDDL, the GPL Version 2 or
69.33 - * to extend the choice of license to its licensees as provided above.
69.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
69.35 - * Version 2 license, then the option applies only if the new code is
69.36 - * made subject to such option by the copyright holder.
69.37 - *
69.38 - * Contributor(s):
69.39 - *
69.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
69.41 - */
69.42 -
69.43 -package org.netbeans.modules.jackpot30.impl.indexing;
69.44 -
69.45 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch;
69.46 -import java.net.URL;
69.47 -import java.util.Arrays;
69.48 -import java.util.HashSet;
69.49 -import java.util.Set;
69.50 -import org.netbeans.api.java.classpath.ClassPath;
69.51 -import org.netbeans.api.java.source.ClasspathInfo;
69.52 -import org.netbeans.api.java.source.CompilationController;
69.53 -import org.netbeans.api.java.source.JavaSource;
69.54 -import org.netbeans.api.java.source.SourceUtilsTestUtil;
69.55 -import org.netbeans.api.java.source.Task;
69.56 -import org.netbeans.modules.jackpot30.impl.indexing.IndexingTestUtils.File;
69.57 -import org.netbeans.spi.java.classpath.support.ClassPathSupport;
69.58 -import org.openide.filesystems.FileObject;
69.59 -
69.60 -import static org.netbeans.modules.jackpot30.impl.indexing.IndexingTestUtils.writeFilesAndWaitForScan;
69.61 -
69.62 -/**
69.63 - *
69.64 - * @author lahvac
69.65 - */
69.66 -public class CustomIndexerImplTest extends IndexTestBase {
69.67 -
69.68 - public CustomIndexerImplTest(String name) {
69.69 - super(name);
69.70 - }
69.71 -
69.72 - public void testIndexing() throws Exception {
69.73 - writeFilesAndWaitForScan(src,
69.74 - new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }"),
69.75 - new File("test/Test2.java", "package test; public class Test2 { private void test() { new javax.swing.ImageIcon(null); } }"));
69.76 -
69.77 - verifyIndex("$1.isDirectory()", "test/Test1.java");
69.78 - verifyIndex("new ImageIcon($1)", "test/Test2.java");
69.79 -
69.80 - writeFilesAndWaitForScan(src,
69.81 - new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); new javax.swing.ImageIcon(null); } }"),
69.82 - new File("test/Test2.java", "package test; public class Test2 { private void test() { new javax.swing.ImageIcon(null); } }"));
69.83 -
69.84 - verifyIndex("$1.isDirectory()", "test/Test1.java");
69.85 - verifyIndex("new ImageIcon($1)", "test/Test1.java", "test/Test2.java");
69.86 -
69.87 - writeFilesAndWaitForScan(src,
69.88 - new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); new javax.swing.ImageIcon(null); } }"),
69.89 - new File("test/Test2.java", "package test; public class Test2 { }"));
69.90 -
69.91 - verifyIndex("$1.isDirectory()", "test/Test1.java");
69.92 - verifyIndex("new ImageIcon($1)", "test/Test1.java");
69.93 - }
69.94 -
69.95 - private void verifyIndex(final String pattern, String... containedIn) throws Exception {
69.96 - ClassPath EMPTY = ClassPathSupport.createClassPath(new FileObject[0]);
69.97 - ClasspathInfo cpInfo = ClasspathInfo.create(ClassPathSupport.createClassPath(SourceUtilsTestUtil.getBootClassPath().toArray(new URL[0])),
69.98 - EMPTY,
69.99 - EMPTY);
69.100 -
69.101 - final Set<String> real = new HashSet<String>();
69.102 -
69.103 - JavaSource.create(cpInfo).runUserActionTask(new Task<CompilationController>() {
69.104 - public void run(CompilationController parameter) throws Exception {
69.105 - real.addAll(FileBasedIndex.get(src.getURL()).findCandidates(BulkSearch.getDefault().create(parameter, pattern)));
69.106 - }
69.107 - }, true);
69.108 -
69.109 - Set<String> golden = new HashSet<String>(Arrays.asList(containedIn));
69.110 -
69.111 - assertEquals(golden, real);
69.112 - }
69.113 -
69.114 -}
69.115 \ No newline at end of file
70.1 --- a/api/test/unit/src/org/netbeans/modules/jackpot30/impl/indexing/IndexTest.java Fri Jan 27 13:35:56 2012 +0100
70.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
70.3 @@ -1,249 +0,0 @@
70.4 -/*
70.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
70.6 - *
70.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
70.8 - *
70.9 - * The contents of this file are subject to the terms of either the GNU
70.10 - * General Public License Version 2 only ("GPL") or the Common
70.11 - * Development and Distribution License("CDDL") (collectively, the
70.12 - * "License"). You may not use this file except in compliance with the
70.13 - * License. You can obtain a copy of the License at
70.14 - * http://www.netbeans.org/cddl-gplv2.html
70.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
70.16 - * specific language governing permissions and limitations under the
70.17 - * License. When distributing the software, include this License Header
70.18 - * Notice in each file and include the License file at
70.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
70.20 - * particular file as subject to the "Classpath" exception as provided
70.21 - * by Sun in the GPL Version 2 section of the License file that
70.22 - * accompanied this code. If applicable, add the following below the
70.23 - * License Header, with the fields enclosed by brackets [] replaced by
70.24 - * your own identifying information:
70.25 - * "Portions Copyrighted [year] [name of copyright owner]"
70.26 - *
70.27 - * If you wish your version of this file to be governed by only the CDDL
70.28 - * or only the GPL Version 2, indicate your decision by adding
70.29 - * "[Contributor] elects to include this software in this distribution
70.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
70.31 - * single choice of license, a recipient has the option to distribute
70.32 - * your version of this file under either the CDDL, the GPL Version 2 or
70.33 - * to extend the choice of license to its licensees as provided above.
70.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
70.35 - * Version 2 license, then the option applies only if the new code is
70.36 - * made subject to such option by the copyright holder.
70.37 - *
70.38 - * Contributor(s):
70.39 - *
70.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
70.41 - */
70.42 -
70.43 -package org.netbeans.modules.jackpot30.impl.indexing;
70.44 -
70.45 -import org.netbeans.modules.java.hints.jackpot.impl.Utilities;
70.46 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch;
70.47 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch.BulkPattern;
70.48 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription.AdditionalQueryConstraints;
70.49 -import java.util.Map;
70.50 -import java.util.Collections;
70.51 -import java.net.URL;
70.52 -import java.util.Arrays;
70.53 -import java.util.HashMap;
70.54 -import java.util.HashSet;
70.55 -import java.util.Set;
70.56 -import org.netbeans.api.java.classpath.ClassPath;
70.57 -import org.netbeans.api.java.source.ClasspathInfo;
70.58 -import org.netbeans.api.java.source.CompilationController;
70.59 -import org.netbeans.api.java.source.JavaSource;
70.60 -import org.netbeans.api.java.source.SourceUtilsTestUtil;
70.61 -import org.netbeans.api.java.source.Task;
70.62 -import org.netbeans.api.java.source.TestUtilities;
70.63 -import org.netbeans.modules.jackpot30.impl.indexing.IndexingTestUtils.File;
70.64 -import org.netbeans.modules.parsing.api.indexing.IndexingManager;
70.65 -import org.netbeans.spi.java.classpath.support.ClassPathSupport;
70.66 -import org.openide.filesystems.FileObject;
70.67 -import org.openide.filesystems.FileUtil;
70.68 -
70.69 -import static org.netbeans.modules.jackpot30.impl.indexing.IndexingTestUtils.indexFiles;
70.70 -import static org.netbeans.modules.jackpot30.impl.indexing.IndexingTestUtils.writeFilesAndWaitForScan;
70.71 -
70.72 -/**
70.73 - *
70.74 - * @author lahvac
70.75 - */
70.76 -public class IndexTest extends IndexTestBase {
70.77 -
70.78 - public IndexTest(String name) {
70.79 - super(name);
70.80 - }
70.81 -
70.82 - public void testMultiplePatternsIndexing() throws Exception {
70.83 - writeFilesAndWaitForScan(src,
70.84 - new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }"),
70.85 - new File("test/Test2.java", "package test; public class Test2 { private void test() { new javax.swing.ImageIcon(null); } }"));
70.86 -
70.87 - String[] patterns = new String[] {
70.88 - "$1.isDirectory()",
70.89 - "new ImageIcon($1)"
70.90 - };
70.91 -
70.92 - verifyIndex(patterns, "test/Test1.java", "test/Test2.java");
70.93 - }
70.94 -
70.95 - public void testLambdaPattern() throws Exception {
70.96 - writeFilesAndWaitForScan(src,
70.97 - new File("test/Test1.java", "package test; public class Test1 { private void test() { Runnable r = new Runnable() { public void run() { System.err.println(); } } } }"));
70.98 -
70.99 - String[] patterns = new String[] {
70.100 - "new $type() {\n $mods$ $resultType $methodName($args$) {\n $statements$;\n }\n }\n",
70.101 - };
70.102 -
70.103 - verifyIndex(patterns, "test/Test1.java");
70.104 - }
70.105 -
70.106 - public void testUpdates() throws Exception {
70.107 - String[] patterns = new String[] {
70.108 - "$1.isDirectory()",
70.109 - "new ImageIcon($1)"
70.110 - };
70.111 -
70.112 - writeFilesAndWaitForScan(src,
70.113 - new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }"),
70.114 - new File("test/Test2.java", "package test; public class Test2 { private void test() { new javax.swing.ImageIcon(null); } }"));
70.115 -
70.116 - verifyIndex(patterns, "test/Test1.java", "test/Test2.java");
70.117 - assertEquals(2, FileBasedIndex.get(src.getURL()).getIndexInfo().totalFiles);
70.118 -
70.119 - src.getFileObject("test/Test1.java").delete();
70.120 -
70.121 - assertNull(src.getFileObject("test/Test1.java"));
70.122 -
70.123 - IndexingManager.getDefault().refreshIndexAndWait(src.getURL(), null, true);
70.124 -
70.125 - verifyIndex(patterns, "test/Test2.java");
70.126 - assertEquals(1, FileBasedIndex.get(src.getURL()).getIndexInfo().totalFiles);
70.127 -
70.128 - FileObject test3 = FileUtil.createData(src, "test/Test3.java");
70.129 - TestUtilities.copyStringToFile(test3, "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }");
70.130 -
70.131 - IndexingManager.getDefault().refreshIndexAndWait(src.getURL(), null, true);
70.132 -
70.133 - verifyIndex(patterns, "test/Test2.java", "test/Test3.java");
70.134 - assertEquals(2, FileBasedIndex.get(src.getURL()).getIndexInfo().totalFiles);
70.135 - }
70.136 -
70.137 - public void testPartiallyAttributed1() throws Exception {
70.138 - Index index = FileBasedIndex.get(src.getURL());
70.139 - indexFiles(src.getURL().toURI(),
70.140 - index,
70.141 - new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }", true),
70.142 - new File("test/Test2.java", "package test; public class Test2 { private void isDirectory() { this.isDirectory(); } }", true),
70.143 - new File("test/Test3.java", "package test; public class Test3 { private void isDirectory() { this.isDirectory(); } }", false));
70.144 -
70.145 - verifyIndex("$1.isDirectory()", new AdditionalQueryConstraints(Collections.singleton("java.io.File")), "test/Test1.java", "test/Test3.java");
70.146 - }
70.147 -
70.148 - public void testPartiallyAttributed2() throws Exception {
70.149 - Index index = FileBasedIndex.get(src.getURL());
70.150 - indexFiles(src.getURL().toURI(),
70.151 - index,
70.152 - new File("test/Test1.java", "package test; public class Test1 { private void test() { String str = null; int l = str.length(); } }", true));
70.153 -
70.154 - verifyIndex("$1.length()", new AdditionalQueryConstraints(Collections.singleton("java.lang.CharSequence")), "test/Test1.java");
70.155 - }
70.156 -
70.157 - public void testFrequencies() throws Exception {
70.158 - writeFilesAndWaitForScan(src,
70.159 - new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); f.isDirectory(); } }"),
70.160 - new File("test/Test2.java", "package test; public class Test2 { private void test() { new javax.swing.ImageIcon(null); java.io.File f = null; f.isDirectory(); } }"),
70.161 - new File("test/Test3.java", "package test; public class Test3 { private void test() { new javax.swing.ImageIcon(null); new javax.swing.ImageIcon(null); } }")
70.162 - );
70.163 -
70.164 - String[] patterns = new String[] {
70.165 - "$1.isDirectory()",
70.166 - "new ImageIcon($1)"
70.167 - };
70.168 -
70.169 - Map<String, Map<String, Integer>> golden = new HashMap<String, Map<String, Integer>>();
70.170 -
70.171 - golden.put("test/Test3.java", Collections.singletonMap("new ImageIcon($1)", 2));
70.172 - golden.put("test/Test1.java", Collections.singletonMap("$1.isDirectory()", 2));
70.173 -
70.174 - Map<String, Integer> freqsTest2 = new HashMap<String, Integer>();
70.175 -
70.176 - freqsTest2.put("$1.isDirectory()", 1);
70.177 - freqsTest2.put("new ImageIcon($1)", 1);
70.178 -
70.179 - golden.put("test/Test2.java", freqsTest2);
70.180 -
70.181 - verifyIndexWithFrequencies(patterns, golden);
70.182 - }
70.183 -
70.184 - public void testInnerClass() throws Exception {
70.185 - Index index = FileBasedIndex.get(src.getURL());
70.186 - indexFiles(src.getURL().toURI(),
70.187 - index,
70.188 - new File("test/Test1.java", "package test; public class Test1 { private static final class O implements Iterable<String> { private String next; private String computeNext() { return null; } public String hasNext() { next = computeNext(); return next != null; } } }", true));
70.189 -
70.190 - verifyIndex("$this.computeNext()", new AdditionalQueryConstraints(Collections.singleton("test.Test1.O")), "test/Test1.java");
70.191 - }
70.192 -
70.193 - private void verifyIndex(final String[] patterns, String... containedIn) throws Exception {
70.194 - ClassPath EMPTY = ClassPathSupport.createClassPath(new FileObject[0]);
70.195 - ClasspathInfo cpInfo = ClasspathInfo.create(ClassPathSupport.createClassPath(SourceUtilsTestUtil.getBootClassPath().toArray(new URL[0])),
70.196 - EMPTY,
70.197 - EMPTY);
70.198 -
70.199 - final Set<String> real = new HashSet<String>();
70.200 -
70.201 - JavaSource.create(cpInfo).runUserActionTask(new Task<CompilationController>() {
70.202 - public void run(CompilationController parameter) throws Exception {
70.203 - real.addAll(FileBasedIndex.get(src.getURL()).findCandidates(BulkSearch.getDefault().create(parameter, patterns)));
70.204 - }
70.205 - }, true);
70.206 -
70.207 - Set<String> golden = new HashSet<String>(Arrays.asList(containedIn));
70.208 -
70.209 - assertEquals(golden, real);
70.210 - }
70.211 -
70.212 - private void verifyIndex(final String pattern, final AdditionalQueryConstraints additionalConstraints, String... containedIn) throws Exception {
70.213 - ClassPath EMPTY = ClassPathSupport.createClassPath(new FileObject[0]);
70.214 - ClasspathInfo cpInfo = ClasspathInfo.create(ClassPathSupport.createClassPath(SourceUtilsTestUtil.getBootClassPath().toArray(new URL[0])),
70.215 - EMPTY,
70.216 - EMPTY);
70.217 -
70.218 - final Set<String> real = new HashSet<String>();
70.219 -
70.220 - JavaSource.create(cpInfo).runUserActionTask(new Task<CompilationController>() {
70.221 - public void run(CompilationController parameter) throws Exception {
70.222 - BulkPattern bulkPattern = BulkSearch.getDefault().create(Collections.singletonList(pattern),
70.223 - Collections.singletonList(Utilities.parseAndAttribute(parameter, pattern, null)),
70.224 - Collections.singletonList(additionalConstraints));
70.225 -
70.226 - real.addAll(FileBasedIndex.get(src.getURL()).findCandidates(bulkPattern));
70.227 - }
70.228 - }, true);
70.229 -
70.230 - Set<String> golden = new HashSet<String>(Arrays.asList(containedIn));
70.231 -
70.232 - assertEquals(golden, real);
70.233 - }
70.234 -
70.235 - private void verifyIndexWithFrequencies(final String[] patterns, Map<String, Map<String, Integer>> golden) throws Exception {
70.236 - ClassPath EMPTY = ClassPathSupport.createClassPath(new FileObject[0]);
70.237 - ClasspathInfo cpInfo = ClasspathInfo.create(ClassPathSupport.createClassPath(SourceUtilsTestUtil.getBootClassPath().toArray(new URL[0])),
70.238 - EMPTY,
70.239 - EMPTY);
70.240 -
70.241 - final Map<String, Map<String, Integer>> real = new HashMap<String, Map<String, Integer>>();
70.242 -
70.243 - JavaSource.create(cpInfo).runUserActionTask(new Task<CompilationController>() {
70.244 - public void run(CompilationController parameter) throws Exception {
70.245 - real.putAll(FileBasedIndex.get(src.getURL()).findCandidatesWithFrequencies(BulkSearch.getDefault().create(parameter, patterns)));
70.246 - }
70.247 - }, true);
70.248 -
70.249 - assertEquals(golden, real);
70.250 - }
70.251 -
70.252 -}
70.253 \ No newline at end of file
71.1 --- a/api/test/unit/src/org/netbeans/modules/jackpot30/impl/indexing/IndexTestBase.java Fri Jan 27 13:35:56 2012 +0100
71.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
71.3 @@ -1,103 +0,0 @@
71.4 -/*
71.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
71.6 - *
71.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
71.8 - *
71.9 - * The contents of this file are subject to the terms of either the GNU
71.10 - * General Public License Version 2 only ("GPL") or the Common
71.11 - * Development and Distribution License("CDDL") (collectively, the
71.12 - * "License"). You may not use this file except in compliance with the
71.13 - * License. You can obtain a copy of the License at
71.14 - * http://www.netbeans.org/cddl-gplv2.html
71.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
71.16 - * specific language governing permissions and limitations under the
71.17 - * License. When distributing the software, include this License Header
71.18 - * Notice in each file and include the License file at
71.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
71.20 - * particular file as subject to the "Classpath" exception as provided
71.21 - * by Sun in the GPL Version 2 section of the License file that
71.22 - * accompanied this code. If applicable, add the following below the
71.23 - * License Header, with the fields enclosed by brackets [] replaced by
71.24 - * your own identifying information:
71.25 - * "Portions Copyrighted [year] [name of copyright owner]"
71.26 - *
71.27 - * If you wish your version of this file to be governed by only the CDDL
71.28 - * or only the GPL Version 2, indicate your decision by adding
71.29 - * "[Contributor] elects to include this software in this distribution
71.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
71.31 - * single choice of license, a recipient has the option to distribute
71.32 - * your version of this file under either the CDDL, the GPL Version 2 or
71.33 - * to extend the choice of license to its licensees as provided above.
71.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
71.35 - * Version 2 license, then the option applies only if the new code is
71.36 - * made subject to such option by the copyright holder.
71.37 - *
71.38 - * Contributor(s):
71.39 - *
71.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
71.41 - */
71.42 -
71.43 -package org.netbeans.modules.jackpot30.impl.indexing;
71.44 -
71.45 -import java.util.Collections;
71.46 -import org.netbeans.api.java.classpath.ClassPath;
71.47 -import org.netbeans.api.java.classpath.GlobalPathRegistry;
71.48 -import org.netbeans.api.java.source.SourceUtilsTestUtil;
71.49 -import org.netbeans.core.startup.Main;
71.50 -import org.netbeans.junit.NbTestCase;
71.51 -import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
71.52 -import org.netbeans.modules.parsing.impl.indexing.MimeTypes;
71.53 -import org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater;
71.54 -import org.netbeans.spi.java.classpath.support.ClassPathSupport;
71.55 -import org.openide.filesystems.FileObject;
71.56 -import org.openide.filesystems.FileUtil;
71.57 -
71.58 -/**
71.59 - *
71.60 - * @author lahvac
71.61 - */
71.62 -public abstract class IndexTestBase extends NbTestCase {
71.63 -
71.64 - public IndexTestBase(String name) {
71.65 - super(name);
71.66 - }
71.67 -
71.68 - @Override
71.69 - protected void setUp() throws Exception {
71.70 - SourceUtilsTestUtil.prepareTest(new String[0], new Object[0]);
71.71 - Main.initializeURLFactory();
71.72 - org.netbeans.api.project.ui.OpenProjects.getDefault().getOpenProjects();
71.73 - prepareTest();
71.74 - MimeTypes.setAllMimeTypes(Collections.singleton("text/x-java"));
71.75 - GlobalPathRegistry.getDefault().register(ClassPath.SOURCE, new ClassPath[] {sourceCP});
71.76 - RepositoryUpdater.getDefault().start(true);
71.77 - super.setUp();
71.78 - }
71.79 -
71.80 - @Override
71.81 - protected void tearDown() throws Exception {
71.82 - super.tearDown();
71.83 - GlobalPathRegistry.getDefault().unregister(ClassPath.SOURCE, new ClassPath[] {sourceCP});
71.84 - }
71.85 -
71.86 - protected FileObject sources;
71.87 - protected FileObject src;
71.88 - protected FileObject src2;
71.89 -
71.90 - private ClassPath sourceCP;
71.91 -
71.92 - private void prepareTest() throws Exception {
71.93 - FileObject workdir = SourceUtilsTestUtil.makeScratchDir(this);
71.94 -
71.95 - sources = FileUtil.createFolder(workdir, "sources");
71.96 - src = FileUtil.createFolder(sources, "src");
71.97 - src2 = FileUtil.createFolder(sources, "src2");
71.98 -
71.99 - FileObject cache = FileUtil.createFolder(workdir, "cache");
71.100 -
71.101 - CacheFolder.setCacheFolder(cache);
71.102 -
71.103 - sourceCP = ClassPathSupport.createClassPath(src, src2);
71.104 - }
71.105 -
71.106 -}
71.107 \ No newline at end of file
72.1 --- a/api/test/unit/src/org/netbeans/modules/jackpot30/impl/indexing/IndexingTestUtils.java Fri Jan 27 13:35:56 2012 +0100
72.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
72.3 @@ -1,171 +0,0 @@
72.4 -/*
72.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
72.6 - *
72.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
72.8 - *
72.9 - * The contents of this file are subject to the terms of either the GNU
72.10 - * General Public License Version 2 only ("GPL") or the Common
72.11 - * Development and Distribution License("CDDL") (collectively, the
72.12 - * "License"). You may not use this file except in compliance with the
72.13 - * License. You can obtain a copy of the License at
72.14 - * http://www.netbeans.org/cddl-gplv2.html
72.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
72.16 - * specific language governing permissions and limitations under the
72.17 - * License. When distributing the software, include this License Header
72.18 - * Notice in each file and include the License file at
72.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
72.20 - * particular file as subject to the "Classpath" exception as provided
72.21 - * by Sun in the GPL Version 2 section of the License file that
72.22 - * accompanied this content. If applicable, add the following below the
72.23 - * License Header, with the fields enclosed by brackets [] replaced by
72.24 - * your own identifying information:
72.25 - * "Portions Copyrighted [year] [name of copyright owner]"
72.26 - *
72.27 - * If you wish your version of this file to be governed by only the CDDL
72.28 - * or only the GPL Version 2, indicate your decision by adding
72.29 - * "[Contributor] elects to include this software in this distribution
72.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
72.31 - * single choice of license, a recipient has the option to distribute
72.32 - * your version of this file under either the CDDL, the GPL Version 2 or
72.33 - * to extend the choice of license to its licensees as provided above.
72.34 - * However, if you add GPL Version 2 content and therefore, elected the GPL
72.35 - * Version 2 license, then the option applies only if the new content is
72.36 - * made subject to such option by the copyright holder.
72.37 - *
72.38 - * Contributor(s):
72.39 - *
72.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
72.41 - */
72.42 -
72.43 -package org.netbeans.modules.jackpot30.impl.indexing;
72.44 -
72.45 -import com.sun.source.tree.CompilationUnitTree;
72.46 -import com.sun.source.util.Trees;
72.47 -import com.sun.tools.javac.api.JavacTaskImpl;
72.48 -import com.sun.tools.javac.model.JavacTypes;
72.49 -import java.io.IOException;
72.50 -import java.net.URI;
72.51 -import java.net.URL;
72.52 -import java.util.Arrays;
72.53 -import java.util.Collections;
72.54 -import javax.tools.Diagnostic;
72.55 -import javax.tools.DiagnosticListener;
72.56 -import javax.tools.JavaCompiler;
72.57 -import javax.tools.JavaFileObject;
72.58 -import javax.tools.SimpleJavaFileObject;
72.59 -import javax.tools.StandardJavaFileManager;
72.60 -import javax.tools.StandardLocation;
72.61 -import javax.tools.ToolProvider;
72.62 -import org.netbeans.api.editor.mimelookup.MimePath;
72.63 -import org.netbeans.api.java.source.SourceUtils;
72.64 -import org.netbeans.api.java.source.TestUtilities;
72.65 -import org.netbeans.modules.jackpot30.impl.duplicates.indexing.DuplicatesCustomIndexerImpl.FactoryImpl;
72.66 -import org.netbeans.modules.jackpot30.impl.duplicates.indexing.DuplicatesIndex;
72.67 -import org.netbeans.modules.jackpot30.impl.indexing.CustomIndexerImpl.CustomIndexerFactoryImpl;
72.68 -import org.netbeans.modules.jackpot30.impl.indexing.Index.IndexWriter;
72.69 -import org.netbeans.spi.editor.mimelookup.MimeDataProvider;
72.70 -import org.openide.filesystems.FileObject;
72.71 -import org.openide.filesystems.FileUtil;
72.72 -import org.openide.util.Lookup;
72.73 -import org.openide.util.lookup.Lookups;
72.74 -import org.openide.util.lookup.ServiceProvider;
72.75 -
72.76 -public class IndexingTestUtils {
72.77 -
72.78 - public static void writeFiles(FileObject sourceRoot, File... files) throws Exception {
72.79 - for (FileObject c : sourceRoot.getChildren()) {
72.80 - c.delete();
72.81 - }
72.82 -
72.83 - for (File f : files) {
72.84 - FileObject fo = FileUtil.createData(sourceRoot, f.filename);
72.85 - TestUtilities.copyStringToFile(fo, f.content);
72.86 - }
72.87 - }
72.88 -
72.89 - public static void writeFilesAndWaitForScan(FileObject sourceRoot, File... files) throws Exception {
72.90 - writeFiles(sourceRoot, files);
72.91 - SourceUtils.waitScanFinished();
72.92 - }
72.93 -
72.94 - public static void indexFiles(URI root, Index idx, File... files) throws Exception {
72.95 - IndexWriter iw = idx.openForWriting();
72.96 -
72.97 - try {
72.98 - iw.clear();
72.99 -
72.100 - for (File f : files) {
72.101 - indexFile(root, iw, null, f);
72.102 - }
72.103 - } finally {
72.104 - iw.close();
72.105 - }
72.106 - }
72.107 -
72.108 - public static final class File {
72.109 - public final String filename;
72.110 - public final String content;
72.111 - public final boolean index;
72.112 -
72.113 - public File(String filename, String content) {
72.114 - this(filename, content, true);
72.115 - }
72.116 -
72.117 - public File(String filename, String content, boolean index) {
72.118 - this.filename = filename;
72.119 - this.content = content;
72.120 - this.index = index;
72.121 - }
72.122 - }
72.123 -
72.124 - @ServiceProvider(service=MimeDataProvider.class)
72.125 - public static final class MimeDataProviderImpl implements MimeDataProvider {
72.126 -
72.127 - private static final Lookup INDEXER = Lookups.fixed(new CustomIndexerFactoryImpl(), new FactoryImpl());
72.128 -
72.129 - public Lookup getLookup(MimePath mimePath) {
72.130 - if ("text/x-java".equals(mimePath.getPath())) {
72.131 - return INDEXER;
72.132 - }
72.133 - return null;
72.134 - }
72.135 -
72.136 - }
72.137 -
72.138 - //copied from StandaloneIndexer:
72.139 - private static void indexFile(URI root, IndexWriter w, DuplicatesIndex.IndexWriter dw, File source) throws IOException {
72.140 - if (!source.filename.endsWith(".java"))
72.141 - return ;
72.142 -
72.143 - final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
72.144 - final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
72.145 - assert tool != null;
72.146 -
72.147 - DiagnosticListener<JavaFileObject> devNull = new DiagnosticListener<JavaFileObject>() {
72.148 - public void report(Diagnostic<? extends JavaFileObject> diagnostic) {}
72.149 - };
72.150 - StandardJavaFileManager m = tool.getStandardFileManager(devNull, null, null);
72.151 -
72.152 - m.setLocation(StandardLocation.CLASS_PATH, Collections.<java.io.File>emptyList());
72.153 - m.setLocation(StandardLocation.SOURCE_PATH, Collections.<java.io.File>emptyList());
72.154 -
72.155 - JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, null, devNull, Arrays.asList("-bootclasspath", bootPath), null, Collections.singleton(new JFOImpl(source.filename, source.content)));
72.156 - CompilationUnitTree cut = ct.parse().iterator().next();
72.157 -
72.158 - ct.analyze(ct.enter(Collections.singletonList(cut)));
72.159 -
72.160 - w.record(root.resolve(source.filename).toURL(), cut, source.index ? new Index.AttributionWrapper(Trees.instance(ct), JavacTypes.instance(ct.getContext())) : null);
72.161 - }
72.162 -
72.163 - private static final class JFOImpl extends SimpleJavaFileObject {
72.164 - private final String content;
72.165 - public JFOImpl(String filename, String content) {
72.166 - super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE);
72.167 - this.content = content;
72.168 - }
72.169 - public CharSequence getCharContent(boolean ignoreEncodingErrors) {
72.170 - return content;
72.171 - }
72.172 - }
72.173 -
72.174 -}
72.175 \ No newline at end of file
73.1 --- a/api/test/unit/src/org/netbeans/modules/jackpot30/impl/pm/BulkSearchPerformance.java Fri Jan 27 13:35:56 2012 +0100
73.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
73.3 @@ -1,226 +0,0 @@
73.4 -/*
73.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
73.6 - *
73.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
73.8 - *
73.9 - * The contents of this file are subject to the terms of either the GNU
73.10 - * General Public License Version 2 only ("GPL") or the Common
73.11 - * Development and Distribution License("CDDL") (collectively, the
73.12 - * "License"). You may not use this file except in compliance with the
73.13 - * License. You can obtain a copy of the License at
73.14 - * http://www.netbeans.org/cddl-gplv2.html
73.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
73.16 - * specific language governing permissions and limitations under the
73.17 - * License. When distributing the software, include this License Header
73.18 - * Notice in each file and include the License file at
73.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
73.20 - * particular file as subject to the "Classpath" exception as provided
73.21 - * by Sun in the GPL Version 2 section of the License file that
73.22 - * accompanied this code. If applicable, add the following below the
73.23 - * License Header, with the fields enclosed by brackets [] replaced by
73.24 - * your own identifying information:
73.25 - * "Portions Copyrighted [year] [name of copyright owner]"
73.26 - *
73.27 - * If you wish your version of this file to be governed by only the CDDL
73.28 - * or only the GPL Version 2, indicate your decision by adding
73.29 - * "[Contributor] elects to include this software in this distribution
73.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
73.31 - * single choice of license, a recipient has the option to distribute
73.32 - * your version of this file under either the CDDL, the GPL Version 2 or
73.33 - * to extend the choice of license to its licensees as provided above.
73.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
73.35 - * Version 2 license, then the option applies only if the new code is
73.36 - * made subject to such option by the copyright holder.
73.37 - *
73.38 - * Contributor(s):
73.39 - *
73.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
73.41 - */
73.42 -
73.43 -package org.netbeans.modules.jackpot30.impl.pm;
73.44 -
73.45 -import com.sun.source.util.TreePath;
73.46 -import java.io.ByteArrayInputStream;
73.47 -import java.io.ByteArrayOutputStream;
73.48 -import java.io.File;
73.49 -import java.io.IOException;
73.50 -import java.util.LinkedList;
73.51 -import java.util.List;
73.52 -import org.netbeans.api.java.source.ClasspathInfo;
73.53 -import org.netbeans.api.java.source.CompilationController;
73.54 -import org.netbeans.api.java.source.JavaSource;
73.55 -import org.netbeans.api.java.source.JavaSource.Phase;
73.56 -import org.netbeans.api.java.source.Task;
73.57 -import org.netbeans.junit.NbTestCase;
73.58 -import org.netbeans.modules.java.hints.jackpot.impl.Utilities;
73.59 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch;
73.60 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch.BulkPattern;
73.61 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch.EncodingContext;
73.62 -import org.netbeans.modules.java.hints.jackpot.impl.pm.CopyFinderBasedBulkSearch;
73.63 -import org.netbeans.modules.java.hints.jackpot.impl.pm.NFABasedBulkSearch;
73.64 -import org.openide.filesystems.FileObject;
73.65 -import org.openide.filesystems.FileUtil;
73.66 -
73.67 -/**
73.68 - *
73.69 - * @author lahvac
73.70 - */
73.71 -public class BulkSearchPerformance extends NbTestCase {
73.72 -
73.73 - public BulkSearchPerformance(String name) {
73.74 - super(name);
73.75 - }
73.76 -
73.77 - public void testPerformance() throws Exception {
73.78 - File root = new File("/media/karta/space/src/nb-main/uml");
73.79 - List<FileObject> files = new LinkedList<FileObject>();
73.80 -
73.81 - gatherFiles(FileUtil.toFileObject(root), files);
73.82 -
73.83 - String[] patterns = new String[] {"$1.isDirectory()", "new ImageIcon()"};
73.84 -
73.85 - for (int c = 0; c < 5; c++) {
73.86 - performPerformanceTest(files, new NFABasedBulkSearch(), patterns);
73.87 - performPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
73.88 - }
73.89 -
73.90 - performPerformanceTest(files, new NFABasedBulkSearch(), patterns);
73.91 - long nfa1 = performPerformanceTest(files, new NFABasedBulkSearch(), patterns);
73.92 - performPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
73.93 - long cf1 = performPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
73.94 -
73.95 - performPerformanceTest(files, new NFABasedBulkSearch(), patterns);
73.96 - long nfa2 = performPerformanceTest(files, new NFABasedBulkSearch(), patterns);
73.97 - performPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
73.98 - long cf2 = performPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
73.99 -
73.100 - System.err.println("nfa1=" + nfa1);
73.101 - System.err.println("cf1=" + cf1);
73.102 - System.err.println("nfa2=" + nfa2);
73.103 - System.err.println("cf2=" + cf2);
73.104 -
73.105 - System.err.println("perf (cf1/nfa1): " + ((1000 * cf1 / nfa1) /10.0) + "%");
73.106 - System.err.println("perf (cf2/nfa2): " + ((1000 * cf2 / nfa2) /10.0) + "%");
73.107 - }
73.108 -
73.109 - public void testIndexingPerformance() throws Exception {
73.110 - File root = new File("/media/karta/space/src/nb-main/uml");
73.111 -// File root = new File("/media/karta/space/src/nb-main/contrib/javahints");
73.112 - List<FileObject> files = new LinkedList<FileObject>();
73.113 -
73.114 - gatherFiles(FileUtil.toFileObject(root), files);
73.115 -
73.116 - String[] patterns = new String[] {"$1.isDirectory()", "new ImageIcon()"};
73.117 -
73.118 - for (int c = 0; c < 5; c++) {
73.119 - performIndexingPerformanceTest(files, new NFABasedBulkSearch(), patterns);
73.120 -// performIndexingPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
73.121 - }
73.122 -
73.123 - performIndexingPerformanceTest(files, new NFABasedBulkSearch(), patterns);
73.124 - long[] nfa1 = performIndexingPerformanceTest(files, new NFABasedBulkSearch(), patterns);
73.125 -// performIndexingPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
73.126 -// long cf1 = performIndexingPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
73.127 -
73.128 - performIndexingPerformanceTest(files, new NFABasedBulkSearch(), patterns);
73.129 - long[] nfa2 = performIndexingPerformanceTest(files, new NFABasedBulkSearch(), patterns);
73.130 -// performIndexingPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
73.131 -// long cf2 = performIndexingPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
73.132 -
73.133 - System.err.println("i.nfa1=" + nfa1[0]);
73.134 - System.err.println("m.nfa1=" + nfa1[1]);
73.135 -// System.err.println("cf1=" + cf1);
73.136 - System.err.println("i.nfa2=" + nfa2[0]);
73.137 - System.err.println("m.nfa2=" + nfa2[1]);
73.138 -// System.err.println("cf2=" + cf2);
73.139 -
73.140 -// System.err.println("perf i.(nfa1/regexp1): " + ((1000 * nfa1[0] / regexp1[0]) /10.0) + "%");
73.141 -// System.err.println("perf m.(nfa1/regexp1): " + ((1000 * nfa1[1] / regexp1[1]) /10.0) + "%");
73.142 -// System.err.println("perf i.(nfa2/regexp2): " + ((1000 * nfa2[0] / regexp2[0]) /10.0) + "%");
73.143 -// System.err.println("perf m.(nfa2/regexp2): " + ((1000 * nfa2[1] / regexp2[1]) /10.0) + "%");
73.144 -// System.err.println("perf (cf1/regexp1): " + ((1000 * cf1 / regexp1) /10.0) + "%");
73.145 -// System.err.println("perf (cf2/regexp2): " + ((1000 * cf2 / regexp2) /10.0) + "%");
73.146 - }
73.147 -
73.148 - private long performPerformanceTest(List<FileObject> files, final BulkSearch search, final String... pattern) throws IOException {
73.149 - ClasspathInfo cpInfo = Utilities.createUniversalCPInfo();
73.150 -
73.151 - final BulkPattern[] bulkPattern = new BulkPattern[1];
73.152 - JavaSource.create(cpInfo).runUserActionTask(new Task<CompilationController>() {
73.153 -
73.154 - public void run(CompilationController parameter) throws Exception {
73.155 - bulkPattern[0] = search.create(parameter, pattern);
73.156 - }
73.157 - }, true);
73.158 -
73.159 - long start = System.currentTimeMillis();
73.160 - JavaSource.create(cpInfo, files).runUserActionTask(new Task<CompilationController>() {
73.161 -
73.162 - public void run(CompilationController parameter) throws Exception {
73.163 - if (parameter.toPhase(Phase.PARSED).compareTo(Phase.PARSED) < 0)
73.164 - return;
73.165 -
73.166 - search.match(parameter, new TreePath(parameter.getCompilationUnit()), bulkPattern[0]);
73.167 - }
73.168 - }, true);
73.169 - long end = System.currentTimeMillis();
73.170 -
73.171 - return end - start;
73.172 - }
73.173 -
73.174 - private long[] performIndexingPerformanceTest(List<FileObject> files, final BulkSearch search, final String... pattern) throws IOException {
73.175 - final List<byte[]> index = new LinkedList<byte[]>();
73.176 - long[] result = new long[2];
73.177 - ClasspathInfo cpInfo = Utilities.createUniversalCPInfo();
73.178 -
73.179 - final BulkPattern[] bulkPattern = new BulkPattern[1];
73.180 - JavaSource.create(cpInfo).runUserActionTask(new Task<CompilationController>() {
73.181 -
73.182 - public void run(CompilationController parameter) throws Exception {
73.183 - bulkPattern[0] = search.create(parameter, pattern);
73.184 - }
73.185 - }, true);
73.186 -
73.187 - long start = System.currentTimeMillis();
73.188 - JavaSource.create(cpInfo, files).runUserActionTask(new Task<CompilationController>() {
73.189 -
73.190 - public void run(CompilationController parameter) throws Exception {
73.191 - if (parameter.toPhase(Phase.PARSED).compareTo(Phase.PARSED) < 0)
73.192 - return;
73.193 -
73.194 - ByteArrayOutputStream out = new ByteArrayOutputStream();
73.195 - EncodingContext ec = new EncodingContext(out, false);
73.196 - search.encode(parameter.getCompilationUnit(), ec);
73.197 -
73.198 - index.add(out.toByteArray());
73.199 - }
73.200 - }, true);
73.201 - long end = System.currentTimeMillis();
73.202 -
73.203 - result[0] = end - start;
73.204 -
73.205 - start = System.currentTimeMillis();
73.206 -
73.207 - for (byte[] data : index) {
73.208 - search.matches(new ByteArrayInputStream(data), bulkPattern[0]);
73.209 - }
73.210 -
73.211 - end = System.currentTimeMillis();
73.212 -
73.213 - result[1] = end - start;
73.214 -
73.215 - return result;
73.216 - }
73.217 -
73.218 - private static void gatherFiles(FileObject root, List<FileObject> files) {
73.219 - if ("java".equals(root.getExt())) {
73.220 - files.add(root);
73.221 - }
73.222 -
73.223 - if (root.isFolder()) {
73.224 - for (FileObject c : root.getChildren()) {
73.225 - gatherFiles(c, files);
73.226 - }
73.227 - }
73.228 - }
73.229 -}
74.1 --- a/api/test/unit/src/org/netbeans/modules/jackpot30/impl/pm/IndexBulkTest.java Fri Jan 27 13:35:56 2012 +0100
74.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
74.3 @@ -1,182 +0,0 @@
74.4 -/*
74.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
74.6 - *
74.7 - * Copyright 2009-2010 Oracle and/or its affiliates. All rights reserved.
74.8 - *
74.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
74.10 - * Other names may be trademarks of their respective owners.
74.11 - *
74.12 - * The contents of this file are subject to the terms of either the GNU
74.13 - * General Public License Version 2 only ("GPL") or the Common
74.14 - * Development and Distribution License("CDDL") (collectively, the
74.15 - * "License"). You may not use this file except in compliance with the
74.16 - * License. You can obtain a copy of the License at
74.17 - * http://www.netbeans.org/cddl-gplv2.html
74.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
74.19 - * specific language governing permissions and limitations under the
74.20 - * License. When distributing the software, include this License Header
74.21 - * Notice in each file and include the License file at
74.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
74.23 - * particular file as subject to the "Classpath" exception as provided
74.24 - * by Oracle in the GPL Version 2 section of the License file that
74.25 - * accompanied this code. If applicable, add the following below the
74.26 - * License Header, with the fields enclosed by brackets [] replaced by
74.27 - * your own identifying information:
74.28 - * "Portions Copyrighted [year] [name of copyright owner]"
74.29 - *
74.30 - * If you wish your version of this file to be governed by only the CDDL
74.31 - * or only the GPL Version 2, indicate your decision by adding
74.32 - * "[Contributor] elects to include this software in this distribution
74.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
74.34 - * single choice of license, a recipient has the option to distribute
74.35 - * your version of this file under either the CDDL, the GPL Version 2 or
74.36 - * to extend the choice of license to its licensees as provided above.
74.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
74.38 - * Version 2 license, then the option applies only if the new code is
74.39 - * made subject to such option by the copyright holder.
74.40 - *
74.41 - * Contributor(s):
74.42 - *
74.43 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
74.44 - */
74.45 -
74.46 -package org.netbeans.modules.jackpot30.impl.pm;
74.47 -
74.48 -import com.sun.source.tree.Tree;
74.49 -import com.sun.source.util.TreePath;
74.50 -import java.io.IOException;
74.51 -import java.io.InputStream;
74.52 -import java.io.Reader;
74.53 -import java.util.Collection;
74.54 -import java.util.Collections;
74.55 -import java.util.Map;
74.56 -import org.apache.lucene.analysis.Analyzer;
74.57 -import org.apache.lucene.analysis.TokenStream;
74.58 -import org.apache.lucene.index.IndexReader;
74.59 -import org.apache.lucene.index.IndexWriter.MaxFieldLength;
74.60 -import org.apache.lucene.store.Directory;
74.61 -import org.apache.lucene.store.RAMDirectory;
74.62 -import org.netbeans.api.java.source.CompilationInfo;
74.63 -import org.netbeans.modules.jackpot30.impl.indexing.AbstractLuceneIndex;
74.64 -import org.netbeans.modules.jackpot30.impl.indexing.Index.IndexWriter;
74.65 -import org.netbeans.modules.jackpot30.impl.indexing.IndexInfo;
74.66 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch;
74.67 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch.BulkPattern;
74.68 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch.EncodingContext;
74.69 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearchTestPerformer;
74.70 -import org.netbeans.modules.java.hints.jackpot.impl.pm.NFABasedBulkSearch;
74.71 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription.AdditionalQueryConstraints;
74.72 -
74.73 -/**
74.74 - *
74.75 - * @author lahvac
74.76 - */
74.77 -public class IndexBulkTest extends BulkSearchTestPerformer {
74.78 -
74.79 - public IndexBulkTest(String name) {
74.80 - super(name);
74.81 - }
74.82 -
74.83 -// public static TestSuite suite() {
74.84 -// NbTestSuite r = new NbTestSuite();
74.85 -//
74.86 -// r.addTest(new NFABasedBulkSearchTest("testField1"));
74.87 -// r.addTest(new NFABasedBulkSearchTest("testField2"));
74.88 -//
74.89 -// return r;
74.90 -// }
74.91 -
74.92 - @Override
74.93 - protected BulkSearch createSearch() {
74.94 - return new BulkSearchImpl(false);
74.95 - }
74.96 -
74.97 - private static class BulkSearchImpl extends BulkSearch {
74.98 -
74.99 - public BulkSearchImpl(boolean requiresLightweightVerification) {
74.100 - super(requiresLightweightVerification);
74.101 - }
74.102 -
74.103 - @Override
74.104 - public Map<String, Collection<TreePath>> match(CompilationInfo info, TreePath toSearch, BulkPattern pattern, Map<String, Long> timeLog) {
74.105 - try {
74.106 - IndexImpl ii = new IndexImpl();
74.107 - IndexWriter writer = ii.openForWriting();
74.108 -
74.109 - writer.record(toSearch.getCompilationUnit().getSourceFile().toUri().toURL(), toSearch.getCompilationUnit(), null);
74.110 - writer.close();
74.111 -
74.112 - if (!ii.findCandidates(pattern).isEmpty()) {
74.113 - return new NFABasedBulkSearch().match(info, toSearch, pattern, timeLog);
74.114 - } else {
74.115 - assertTrue(new NFABasedBulkSearch().match(info, toSearch, pattern, timeLog).isEmpty());
74.116 - return Collections.emptyMap();
74.117 - }
74.118 - } catch (IOException ex) {
74.119 - throw new IllegalStateException(ex);
74.120 - }
74.121 - }
74.122 -
74.123 - @Override
74.124 - public boolean matches(InputStream encoded, BulkPattern pattern) {
74.125 - return new NFABasedBulkSearch().matches(encoded, pattern);
74.126 - }
74.127 -
74.128 - @Override
74.129 - public boolean matches(CompilationInfo info, TreePath toSearch, BulkPattern pattern) {
74.130 - return new NFABasedBulkSearch().matches(info, toSearch, pattern);
74.131 - }
74.132 -
74.133 - @Override
74.134 - public void encode(Tree tree, EncodingContext ctx) {
74.135 - new NFABasedBulkSearch().encode(tree, ctx);
74.136 - }
74.137 -
74.138 - @Override
74.139 - public BulkPattern create(Collection<? extends String> code, Collection<? extends Tree> patterns, Collection<? extends AdditionalQueryConstraints> additionalConstraints) {
74.140 - return new NFABasedBulkSearch().create(code, patterns, additionalConstraints);
74.141 - }
74.142 -
74.143 - @Override
74.144 - public Map<String, Integer> matchesWithFrequencies(InputStream encoded, BulkPattern pattern) {
74.145 - return new NFABasedBulkSearch().matchesWithFrequencies(encoded, pattern);
74.146 - }
74.147 - }
74.148 -
74.149 - private static final class IndexImpl extends AbstractLuceneIndex {
74.150 -
74.151 - private final Directory dir = new RAMDirectory();
74.152 -
74.153 - public IndexImpl() {
74.154 - super(0, false, true);
74.155 - }
74.156 -
74.157 - @Override
74.158 - protected IndexReader createReader() throws IOException {
74.159 - return IndexReader.open(dir, true);
74.160 - }
74.161 -
74.162 - @Override
74.163 - protected org.apache.lucene.index.IndexWriter createWriter() throws IOException {
74.164 - return new org.apache.lucene.index.IndexWriter(dir, new NoAnalyzer(), MaxFieldLength.UNLIMITED);
74.165 - }
74.166 -
74.167 - @Override
74.168 - public IndexInfo getIndexInfo() {
74.169 - return IndexInfo.empty();
74.170 - }
74.171 -
74.172 - @Override
74.173 - protected void storeIndexInfo(IndexInfo info) throws IOException {}
74.174 - }
74.175 -
74.176 - private static final class NoAnalyzer extends Analyzer {
74.177 -
74.178 - @Override
74.179 - public TokenStream tokenStream(String string, Reader reader) {
74.180 - throw new UnsupportedOperationException("Should not be called");
74.181 - }
74.182 -
74.183 - }
74.184 -
74.185 -}
75.1 --- a/api/test/unit/src/org/netbeans/modules/jackpot30/impl/refactoring/findusages/PatternGeneratorTest.java Fri Jan 27 13:35:56 2012 +0100
75.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
75.3 @@ -1,134 +0,0 @@
75.4 -/*
75.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
75.6 - *
75.7 - * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
75.8 - *
75.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
75.10 - * Other names may be trademarks of their respective owners.
75.11 - *
75.12 - * The contents of this file are subject to the terms of either the GNU
75.13 - * General Public License Version 2 only ("GPL") or the Common
75.14 - * Development and Distribution License("CDDL") (collectively, the
75.15 - * "License"). You may not use this file except in compliance with the
75.16 - * License. You can obtain a copy of the License at
75.17 - * http://www.netbeans.org/cddl-gplv2.html
75.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
75.19 - * specific language governing permissions and limitations under the
75.20 - * License. When distributing the software, include this License Header
75.21 - * Notice in each file and include the License file at
75.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
75.23 - * particular file as subject to the "Classpath" exception as provided
75.24 - * by Oracle in the GPL Version 2 section of the License file that
75.25 - * accompanied this code. If applicable, add the following below the
75.26 - * License Header, with the fields enclosed by brackets [] replaced by
75.27 - * your own identifying information:
75.28 - * "Portions Copyrighted [year] [name of copyright owner]"
75.29 - *
75.30 - * If you wish your version of this file to be governed by only the CDDL
75.31 - * or only the GPL Version 2, indicate your decision by adding
75.32 - * "[Contributor] elects to include this software in this distribution
75.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
75.34 - * single choice of license, a recipient has the option to distribute
75.35 - * your version of this file under either the CDDL, the GPL Version 2 or
75.36 - * to extend the choice of license to its licensees as provided above.
75.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
75.38 - * Version 2 license, then the option applies only if the new code is
75.39 - * made subject to such option by the copyright holder.
75.40 - *
75.41 - * Contributor(s):
75.42 - *
75.43 - * Portions Copyrighted 2011 Sun Microsystems, Inc.
75.44 - */
75.45 -
75.46 -package org.netbeans.modules.jackpot30.impl.refactoring.findusages;
75.47 -
75.48 -import com.sun.source.util.TreePath;
75.49 -import java.util.List;
75.50 -import java.util.concurrent.atomic.AtomicBoolean;
75.51 -import org.netbeans.api.java.source.CompilationInfo;
75.52 -import org.netbeans.modules.java.hints.infrastructure.TreeRuleTestBase;
75.53 -import org.netbeans.modules.java.hints.jackpot.impl.hints.HintsInvoker;
75.54 -import org.netbeans.modules.java.hints.jackpot.spi.PatternConvertor;
75.55 -import org.netbeans.spi.editor.hints.ErrorDescription;
75.56 -
75.57 -/**
75.58 - *
75.59 - * @author lahvac
75.60 - */
75.61 -public class PatternGeneratorTest extends TreeRuleTestBase {
75.62 -
75.63 - public PatternGeneratorTest(String name) {
75.64 - super(name);
75.65 - }
75.66 -
75.67 - public void testStaticMethod() throws Exception {
75.68 - performTest("package test;\n" +
75.69 - "public class Test {\n" +
75.70 - " public static void te|st(int i, String s) {\n" +
75.71 - " test(i, s);\n" +
75.72 - " }\n" +
75.73 - "}\n",
75.74 - "3:8-3:12:verifier:TODO: No display name");
75.75 - }
75.76 -
75.77 - public void testInstanceMethod() throws Exception {
75.78 - performTest("package test;\n" +
75.79 - "public class Test {\n" +
75.80 - " public void te|st(int i, String s) {\n" +
75.81 - " new Test().test(i, s);\n" +
75.82 - " test(i, s);\n" +
75.83 - " }\n" +
75.84 - "}\n",
75.85 - "3:19-3:23:verifier:TODO: No display name",
75.86 - "4:8-4:12:verifier:TODO: No display name");
75.87 - }
75.88 -
75.89 - public void testStaticField() throws Exception {
75.90 - performTest("package test;\n" +
75.91 - "public class Test {\n" +
75.92 - " public static int I|I = 0;" +
75.93 - " public int test() {\n" +
75.94 - " return II;\n" +
75.95 - " }\n" +
75.96 - "}\n",
75.97 - "3:15-3:17:verifier:TODO: No display name");
75.98 - }
75.99 -
75.100 - public void testInstanceField() throws Exception {
75.101 - performTest("package test;\n" +
75.102 - "public class Test {\n" +
75.103 - " public int I|I = 0;" +
75.104 - " public int test() {\n" +
75.105 - " if (true) return II; else return new Test().II;\n" +
75.106 - " }\n" +
75.107 - "}\n",
75.108 - "3:25-3:27:verifier:TODO: No display name",
75.109 - "3:52-3:54:verifier:TODO: No display name");
75.110 - }
75.111 -
75.112 - private void performTest(String code, String... golden) throws Exception {
75.113 - performAnalysisTest("test/Test.java",
75.114 - code,
75.115 - golden);
75.116 - }
75.117 -
75.118 - @Override
75.119 - protected List<ErrorDescription> computeErrors(CompilationInfo info, TreePath path) {
75.120 - String script = PatternGenerator.generateFindUsagesScript(info, info.getTrees().getElement(path));
75.121 -
75.122 - return new HintsInvoker(info, new AtomicBoolean()).computeHints(info, PatternConvertor.create(script));
75.123 - }
75.124 -
75.125 - @Override
75.126 - public void testIssue105979() throws Exception {}
75.127 -
75.128 - @Override
75.129 - public void testIssue108246() throws Exception {}
75.130 -
75.131 - @Override
75.132 - public void testIssue113933() throws Exception {}
75.133 -
75.134 - @Override
75.135 - public void testNoHintsForSimpleInitialize() throws Exception {}
75.136 -
75.137 -}
76.1 --- a/api/test/unit/src/org/netbeans/modules/jackpot30/spi/refactoring/JackpotBasedRefactoringTestBase.java Fri Jan 27 13:35:56 2012 +0100
76.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
76.3 @@ -1,198 +0,0 @@
76.4 -/*
76.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
76.6 - *
76.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
76.8 - *
76.9 - * The contents of this file are subject to the terms of either the GNU
76.10 - * General Public License Version 2 only ("GPL") or the Common
76.11 - * Development and Distribution License("CDDL") (collectively, the
76.12 - * "License"). You may not use this file except in compliance with the
76.13 - * License. You can obtain a copy of the License at
76.14 - * http://www.netbeans.org/cddl-gplv2.html
76.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
76.16 - * specific language governing permissions and limitations under the
76.17 - * License. When distributing the software, include this License Header
76.18 - * Notice in each file and include the License file at
76.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
76.20 - * particular file as subject to the "Classpath" exception as provided
76.21 - * by Sun in the GPL Version 2 section of the License file that
76.22 - * accompanied this code. If applicable, add the following below the
76.23 - * License Header, with the fields enclosed by brackets [] replaced by
76.24 - * your own identifying information:
76.25 - * "Portions Copyrighted [year] [name of copyright owner]"
76.26 - *
76.27 - * If you wish your version of this file to be governed by only the CDDL
76.28 - * or only the GPL Version 2, indicate your decision by adding
76.29 - * "[Contributor] elects to include this software in this distribution
76.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
76.31 - * single choice of license, a recipient has the option to distribute
76.32 - * your version of this file under either the CDDL, the GPL Version 2 or
76.33 - * to extend the choice of license to its licensees as provided above.
76.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
76.35 - * Version 2 license, then the option applies only if the new code is
76.36 - * made subject to such option by the copyright holder.
76.37 - *
76.38 - * Contributor(s):
76.39 - *
76.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
76.41 - */
76.42 -
76.43 -package org.netbeans.modules.jackpot30.spi.refactoring;
76.44 -
76.45 -import java.io.IOException;
76.46 -import java.util.Collections;
76.47 -import org.netbeans.api.editor.mimelookup.MimePath;
76.48 -import org.netbeans.api.java.classpath.ClassPath;
76.49 -import org.netbeans.api.java.classpath.GlobalPathRegistry;
76.50 -import org.netbeans.api.java.source.SourceUtils;
76.51 -import org.netbeans.api.java.source.SourceUtilsTestUtil;
76.52 -import org.netbeans.api.java.source.TestUtilities;
76.53 -import org.netbeans.api.project.Project;
76.54 -import org.netbeans.api.project.ProjectManager;
76.55 -import org.netbeans.core.startup.Main;
76.56 -import org.netbeans.junit.NbTestCase;
76.57 -import org.netbeans.modules.java.JavaDataLoader;
76.58 -import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
76.59 -import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
76.60 -import org.netbeans.modules.parsing.impl.indexing.MimeTypes;
76.61 -import org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater;
76.62 -import org.netbeans.modules.parsing.impl.indexing.Util;
76.63 -import org.netbeans.spi.editor.mimelookup.MimeDataProvider;
76.64 -import org.netbeans.spi.java.classpath.ClassPathProvider;
76.65 -import org.netbeans.spi.java.classpath.support.ClassPathSupport;
76.66 -import org.netbeans.spi.project.ProjectFactory;
76.67 -import org.netbeans.spi.project.ProjectState;
76.68 -import org.openide.filesystems.FileObject;
76.69 -import org.openide.filesystems.FileUtil;
76.70 -import org.openide.util.Lookup;
76.71 -import org.openide.util.lookup.Lookups;
76.72 -import org.openide.util.lookup.ServiceProvider;
76.73 -
76.74 -/**
76.75 - *
76.76 - * @author lahvac
76.77 - */
76.78 -public class JackpotBasedRefactoringTestBase extends NbTestCase {
76.79 -
76.80 - public JackpotBasedRefactoringTestBase(String name) {
76.81 - super(name);
76.82 - }
76.83 -
76.84 - protected static void writeFilesAndWaitForScan(FileObject sourceRoot, File... files) throws Exception {
76.85 - for (FileObject c : sourceRoot.getChildren()) {
76.86 - c.delete();
76.87 - }
76.88 -
76.89 - for (File f : files) {
76.90 - FileObject fo = FileUtil.createData(sourceRoot, f.filename);
76.91 - TestUtilities.copyStringToFile(fo, f.content);
76.92 - }
76.93 -
76.94 - SourceUtils.waitScanFinished();
76.95 - }
76.96 -
76.97 - protected static void assertContent(FileObject sourceRoot, File... files) throws Exception {
76.98 - for (File f : files) {
76.99 - FileObject fo = sourceRoot.getFileObject(f.filename);
76.100 -
76.101 - assertNotNull(f.filename, fo);
76.102 -
76.103 - assertEquals(f.content.replaceAll("[ \t\n]+", " "), TestUtilities.copyFileToString(FileUtil.toFile(fo)).replaceAll("[ \t\n]+", " "));
76.104 - }
76.105 - }
76.106 -
76.107 - protected static final class File {
76.108 - public final String filename;
76.109 - public final String content;
76.110 -
76.111 - public File(String filename, String content) {
76.112 - this.filename = filename;
76.113 - this.content = content;
76.114 - }
76.115 - }
76.116 -
76.117 - protected FileObject src;
76.118 - protected Project prj;
76.119 -
76.120 - @Override
76.121 - protected void setUp() throws Exception {
76.122 - SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml"}, new Object[] {
76.123 - new ClassPathProvider() {
76.124 - public ClassPath findClassPath(FileObject file, String type) {
76.125 - if (src != null && (file == src || FileUtil.isParentOf(src, file))) {
76.126 - if (ClassPath.BOOT.equals(type)) {
76.127 - return ClassPathSupport.createClassPath(System.getProperty("sun.boot.class.path"));
76.128 - }
76.129 - if (ClassPath.COMPILE.equals(type)) {
76.130 - return ClassPathSupport.createClassPath(new FileObject[0]);
76.131 - }
76.132 - if (ClassPath.SOURCE.equals(type)) {
76.133 - return ClassPathSupport.createClassPath(src);
76.134 - }
76.135 - }
76.136 -
76.137 - return null;
76.138 - }
76.139 - },
76.140 - new ProjectFactory() {
76.141 - public boolean isProject(FileObject projectDirectory) {
76.142 - return src == projectDirectory;
76.143 - }
76.144 - public Project loadProject(final FileObject projectDirectory, ProjectState state) throws IOException {
76.145 - if (!isProject(projectDirectory)) return null;
76.146 - return new Project() {
76.147 - public FileObject getProjectDirectory() {
76.148 - return projectDirectory;
76.149 - }
76.150 - public Lookup getLookup() {
76.151 - return Lookup.EMPTY;
76.152 - }
76.153 - };
76.154 - }
76.155 - public void saveProject(Project project) throws IOException, ClassCastException {}
76.156 - },
76.157 - JavaDataLoader.getLoader(JavaDataLoader.class),
76.158 - });
76.159 - Main.initializeURLFactory();
76.160 - org.netbeans.api.project.ui.OpenProjects.getDefault().getOpenProjects();
76.161 - prepareTest();
76.162 - org.netbeans.api.project.ui.OpenProjects.getDefault().open(new Project[] {prj = ProjectManager.getDefault().findProject(src)}, false);
76.163 - MimeTypes.setAllMimeTypes(Collections.singleton("text/x-java"));
76.164 - GlobalPathRegistry.getDefault().register(ClassPath.SOURCE, new ClassPath[] {ClassPathSupport.createClassPath(src)});
76.165 - RepositoryUpdater.getDefault().start(true);
76.166 - super.setUp();
76.167 - }
76.168 -
76.169 - @Override
76.170 - protected void tearDown() throws Exception {
76.171 - super.tearDown();
76.172 - org.netbeans.api.project.ui.OpenProjects.getDefault().open(new Project[] {prj}, false);
76.173 - prj = null;
76.174 - }
76.175 -
76.176 - private void prepareTest() throws Exception {
76.177 - FileObject workdir = SourceUtilsTestUtil.makeScratchDir(this);
76.178 -
76.179 - src = FileUtil.createFolder(workdir, "src");
76.180 -
76.181 - FileObject cache = FileUtil.createFolder(workdir, "cache");
76.182 -
76.183 - CacheFolder.setCacheFolder(cache);
76.184 - }
76.185 -
76.186 - @ServiceProvider(service=MimeDataProvider.class)
76.187 - public static final class MimeDataProviderImpl implements MimeDataProvider {
76.188 -
76.189 - private static final Lookup L = Lookups.singleton(new JavaCustomIndexer.Factory());
76.190 -
76.191 - public Lookup getLookup(MimePath mimePath) {
76.192 - if ("text/x-java".equals(mimePath.getPath())) {
76.193 - return L;
76.194 - }
76.195 -
76.196 - return null;
76.197 - }
76.198 -
76.199 - }
76.200 -
76.201 -}
77.1 --- a/borrowedtests/build.xml Fri Jan 27 13:35:56 2012 +0100
77.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
77.3 @@ -1,13 +0,0 @@
77.4 -<?xml version="1.0" encoding="UTF-8"?>
77.5 -<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
77.6 -<!-- for some information on what you could do (e.g. targets to override). -->
77.7 -<!-- If you delete this file and reopen the project it will be recreated. -->
77.8 -<project name="org.netbeans.modules.jackpot30.test.borrowed" default="netbeans" basedir=".">
77.9 - <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.test.borrowed.</description>
77.10 - <import file="nbproject/build-impl.xml"/>
77.11 - <import file="../findbugs-import.xml"/>
77.12 -
77.13 - <target name="test" />
77.14 - <target name="test-coverage" />
77.15 - <target name="coverage-report" />
77.16 -</project>
78.1 --- a/borrowedtests/manifest.mf Fri Jan 27 13:35:56 2012 +0100
78.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
78.3 @@ -1,6 +0,0 @@
78.4 -Manifest-Version: 1.0
78.5 -AutoUpdate-Show-In-Client: false
78.6 -OpenIDE-Module: org.netbeans.modules.jackpot30.test.borrowed
78.7 -OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/test/borrowed/Bundle.properties
78.8 -OpenIDE-Module-Specification-Version: 1.16
78.9 -
79.1 --- a/borrowedtests/nbproject/build-impl.xml Fri Jan 27 13:35:56 2012 +0100
79.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
79.3 @@ -1,42 +0,0 @@
79.4 -<?xml version="1.0" encoding="UTF-8"?>
79.5 -<!--
79.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
79.7 -*** EDIT ../build.xml INSTEAD ***
79.8 --->
79.9 -<project name="org.netbeans.modules.jackpot30.test.borrowed-impl" basedir="..">
79.10 - <fail message="Please build using Ant 1.7.1 or higher.">
79.11 - <condition>
79.12 - <not>
79.13 - <antversion atleast="1.7.1"/>
79.14 - </not>
79.15 - </condition>
79.16 - </fail>
79.17 - <property file="nbproject/private/platform-private.properties"/>
79.18 - <property file="nbproject/platform.properties"/>
79.19 - <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
79.20 - <attribute name="name"/>
79.21 - <attribute name="value"/>
79.22 - <sequential>
79.23 - <property name="@{name}" value="${@{value}}"/>
79.24 - </sequential>
79.25 - </macrodef>
79.26 - <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
79.27 - <attribute name="property"/>
79.28 - <attribute name="value"/>
79.29 - <sequential>
79.30 - <property name="@{property}" value="@{value}"/>
79.31 - </sequential>
79.32 - </macrodef>
79.33 - <property file="${user.properties.file}"/>
79.34 - <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
79.35 - <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
79.36 - <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
79.37 - <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
79.38 - <condition>
79.39 - <not>
79.40 - <contains string="${cluster.path.evaluated}" substring="platform"/>
79.41 - </not>
79.42 - </condition>
79.43 - </fail>
79.44 - <import file="${harness.dir}/build.xml"/>
79.45 -</project>
80.1 --- a/borrowedtests/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
80.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
80.3 @@ -1,8 +0,0 @@
80.4 -build.xml.data.CRC32=a4393221
80.5 -build.xml.script.CRC32=3cb17d2d
80.6 -build.xml.stylesheet.CRC32=79c3b980@1.28.0.7
80.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
80.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
80.9 -nbproject/build-impl.xml.data.CRC32=c00f7099
80.10 -nbproject/build-impl.xml.script.CRC32=c6833bcb
80.11 -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.49
81.1 --- a/borrowedtests/nbproject/platform.properties Fri Jan 27 13:35:56 2012 +0100
81.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
81.3 @@ -1,21 +0,0 @@
81.4 -cluster.path=\
81.5 - ${nbplatform.active.dir}/identity:\
81.6 - ${nbplatform.active.dir}/enterprise:\
81.7 - ${nbplatform.active.dir}/webcommon:\
81.8 - ${nbplatform.active.dir}/mobility:\
81.9 - ${nbplatform.active.dir}/php:\
81.10 - ${nbplatform.active.dir}/harness:\
81.11 - ${nbplatform.active.dir}/dlight:\
81.12 - ${nbplatform.active.dir}/profiler:\
81.13 - ${nbplatform.active.dir}/platform:\
81.14 - ${nbplatform.active.dir}/websvccommon:\
81.15 - ${nbplatform.active.dir}/nb:\
81.16 - ${nbplatform.active.dir}/apisupport:\
81.17 - ${nbplatform.active.dir}/cnd:\
81.18 - ${nbplatform.active.dir}/ergonomics:\
81.19 - ${nbplatform.active.dir}/java:\
81.20 - ${nbplatform.active.dir}/groovy:\
81.21 - ${nbplatform.active.dir}/ruby:\
81.22 - ${nbplatform.active.dir}/extra:\
81.23 - ${nbplatform.active.dir}/ide
81.24 -nbplatform.active=default
82.1 --- a/borrowedtests/nbproject/project.properties Fri Jan 27 13:35:56 2012 +0100
82.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
82.3 @@ -1,2 +0,0 @@
82.4 -javac.source=1.5
82.5 -javac.compilerargs=-Xlint -Xlint:-serial
83.1 --- a/borrowedtests/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
83.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
83.3 @@ -1,328 +0,0 @@
83.4 -<?xml version="1.0" encoding="UTF-8"?>
83.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
83.6 - <type>org.netbeans.modules.apisupport.project</type>
83.7 - <configuration>
83.8 - <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
83.9 - <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
83.10 - <standalone/>
83.11 - <module-dependencies>
83.12 - <dependency>
83.13 - <code-name-base>org.netbeans.api.annotations.common</code-name-base>
83.14 - <build-prerequisite/>
83.15 - <compile-dependency/>
83.16 - <run-dependency>
83.17 - <release-version>1</release-version>
83.18 - <specification-version>1.13</specification-version>
83.19 - </run-dependency>
83.20 - </dependency>
83.21 - <dependency>
83.22 - <code-name-base>org.netbeans.api.java</code-name-base>
83.23 - <build-prerequisite/>
83.24 - <compile-dependency/>
83.25 - <run-dependency>
83.26 - <release-version>1</release-version>
83.27 - <specification-version>1.31</specification-version>
83.28 - </run-dependency>
83.29 - </dependency>
83.30 - <dependency>
83.31 - <code-name-base>org.netbeans.api.java.classpath</code-name-base>
83.32 - <build-prerequisite/>
83.33 - <compile-dependency/>
83.34 - <run-dependency>
83.35 - <release-version>1</release-version>
83.36 - <specification-version>1.27</specification-version>
83.37 - </run-dependency>
83.38 - </dependency>
83.39 - <dependency>
83.40 - <code-name-base>org.netbeans.api.progress</code-name-base>
83.41 - <build-prerequisite/>
83.42 - <compile-dependency/>
83.43 - <run-dependency>
83.44 - <release-version>1</release-version>
83.45 - <specification-version>1.22</specification-version>
83.46 - </run-dependency>
83.47 - </dependency>
83.48 - <dependency>
83.49 - <code-name-base>org.netbeans.insane</code-name-base>
83.50 - <build-prerequisite/>
83.51 - <compile-dependency/>
83.52 - <run-dependency>
83.53 - <release-version>1</release-version>
83.54 - <implementation-version/>
83.55 - </run-dependency>
83.56 - </dependency>
83.57 - <dependency>
83.58 - <code-name-base>org.netbeans.libs.javacapi</code-name-base>
83.59 - <build-prerequisite/>
83.60 - <compile-dependency/>
83.61 - <run-dependency>
83.62 - <specification-version>7.1.0.2</specification-version>
83.63 - </run-dependency>
83.64 - </dependency>
83.65 - <dependency>
83.66 - <code-name-base>org.netbeans.libs.javacimpl</code-name-base>
83.67 - <build-prerequisite/>
83.68 - <compile-dependency/>
83.69 - <run-dependency>
83.70 - <release-version>1</release-version>
83.71 - <implementation-version/>
83.72 - </run-dependency>
83.73 - </dependency>
83.74 - <dependency>
83.75 - <code-name-base>org.netbeans.libs.junit4</code-name-base>
83.76 - <build-prerequisite/>
83.77 - <compile-dependency/>
83.78 - <run-dependency>
83.79 - <specification-version>1.12</specification-version>
83.80 - </run-dependency>
83.81 - </dependency>
83.82 - <dependency>
83.83 - <code-name-base>org.netbeans.libs.lucene</code-name-base>
83.84 - <build-prerequisite/>
83.85 - <compile-dependency/>
83.86 - <run-dependency>
83.87 - <release-version>1-3</release-version>
83.88 - <specification-version>2.13</specification-version>
83.89 - </run-dependency>
83.90 - </dependency>
83.91 - <dependency>
83.92 - <code-name-base>org.netbeans.modules.editor.lib2</code-name-base>
83.93 - <build-prerequisite/>
83.94 - <compile-dependency/>
83.95 - <run-dependency>
83.96 - <release-version>1</release-version>
83.97 - <specification-version>1.35.0.5</specification-version>
83.98 - </run-dependency>
83.99 - </dependency>
83.100 - <dependency>
83.101 - <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
83.102 - <build-prerequisite/>
83.103 - <compile-dependency/>
83.104 - <run-dependency>
83.105 - <release-version>1</release-version>
83.106 - <specification-version>1.20</specification-version>
83.107 - </run-dependency>
83.108 - </dependency>
83.109 - <dependency>
83.110 - <code-name-base>org.netbeans.modules.editor.util</code-name-base>
83.111 - <build-prerequisite/>
83.112 - <compile-dependency/>
83.113 - <run-dependency>
83.114 - <release-version>1</release-version>
83.115 - <specification-version>1.39</specification-version>
83.116 - </run-dependency>
83.117 - </dependency>
83.118 - <dependency>
83.119 - <code-name-base>org.netbeans.modules.java.hints</code-name-base>
83.120 - <build-prerequisite/>
83.121 - <compile-dependency/>
83.122 - <run-dependency>
83.123 - <release-version>1</release-version>
83.124 - <implementation-version/>
83.125 - </run-dependency>
83.126 - </dependency>
83.127 - <dependency>
83.128 - <code-name-base>org.netbeans.modules.java.lexer</code-name-base>
83.129 - <build-prerequisite/>
83.130 - <compile-dependency/>
83.131 - <run-dependency>
83.132 - <release-version>1</release-version>
83.133 - <specification-version>1.12</specification-version>
83.134 - </run-dependency>
83.135 - </dependency>
83.136 - <dependency>
83.137 - <code-name-base>org.netbeans.modules.java.source</code-name-base>
83.138 - <build-prerequisite/>
83.139 - <compile-dependency/>
83.140 - <run-dependency>
83.141 - <implementation-version/>
83.142 - </run-dependency>
83.143 - </dependency>
83.144 - <dependency>
83.145 - <code-name-base>org.netbeans.modules.lexer</code-name-base>
83.146 - <build-prerequisite/>
83.147 - <compile-dependency/>
83.148 - <run-dependency>
83.149 - <release-version>2</release-version>
83.150 - <specification-version>1.37.0.1</specification-version>
83.151 - </run-dependency>
83.152 - </dependency>
83.153 - <dependency>
83.154 - <code-name-base>org.netbeans.modules.masterfs</code-name-base>
83.155 - <build-prerequisite/>
83.156 - <compile-dependency/>
83.157 - <run-dependency>
83.158 - <release-version>2</release-version>
83.159 - <implementation-version/>
83.160 - </run-dependency>
83.161 - </dependency>
83.162 - <dependency>
83.163 - <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
83.164 - <build-prerequisite/>
83.165 - <compile-dependency/>
83.166 - <run-dependency>
83.167 - <release-version>1</release-version>
83.168 - <specification-version>1.65</specification-version>
83.169 - </run-dependency>
83.170 - </dependency>
83.171 - <dependency>
83.172 - <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
83.173 - <build-prerequisite/>
83.174 - <compile-dependency/>
83.175 - <run-dependency>
83.176 - <release-version>1</release-version>
83.177 - <implementation-version/>
83.178 - </run-dependency>
83.179 - </dependency>
83.180 - <dependency>
83.181 - <code-name-base>org.netbeans.modules.projectapi</code-name-base>
83.182 - <build-prerequisite/>
83.183 - <compile-dependency/>
83.184 - <run-dependency>
83.185 - <release-version>1</release-version>
83.186 - <specification-version>1.34</specification-version>
83.187 - </run-dependency>
83.188 - </dependency>
83.189 - <dependency>
83.190 - <code-name-base>org.netbeans.modules.projectui</code-name-base>
83.191 - <build-prerequisite/>
83.192 - <compile-dependency/>
83.193 - <run-dependency>
83.194 - <implementation-version/>
83.195 - </run-dependency>
83.196 - </dependency>
83.197 - <dependency>
83.198 - <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
83.199 - <build-prerequisite/>
83.200 - <compile-dependency/>
83.201 - <run-dependency>
83.202 - <release-version>1</release-version>
83.203 - <specification-version>1.49.0.8</specification-version>
83.204 - </run-dependency>
83.205 - </dependency>
83.206 - <dependency>
83.207 - <code-name-base>org.netbeans.modules.queries</code-name-base>
83.208 - <build-prerequisite/>
83.209 - <compile-dependency/>
83.210 - <run-dependency>
83.211 - <release-version>1</release-version>
83.212 - <specification-version>1.21</specification-version>
83.213 - </run-dependency>
83.214 - </dependency>
83.215 - <dependency>
83.216 - <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
83.217 - <build-prerequisite/>
83.218 - <compile-dependency/>
83.219 - <run-dependency>
83.220 - <release-version>0-1</release-version>
83.221 - <specification-version>1.16.0.7.5</specification-version>
83.222 - </run-dependency>
83.223 - </dependency>
83.224 - <dependency>
83.225 - <code-name-base>org.openide.actions</code-name-base>
83.226 - <build-prerequisite/>
83.227 - <compile-dependency/>
83.228 - <run-dependency>
83.229 - <specification-version>6.19</specification-version>
83.230 - </run-dependency>
83.231 - </dependency>
83.232 - <dependency>
83.233 - <code-name-base>org.openide.awt</code-name-base>
83.234 - <build-prerequisite/>
83.235 - <compile-dependency/>
83.236 - <run-dependency>
83.237 - <specification-version>7.29</specification-version>
83.238 - </run-dependency>
83.239 - </dependency>
83.240 - <dependency>
83.241 - <code-name-base>org.openide.dialogs</code-name-base>
83.242 - <build-prerequisite/>
83.243 - <compile-dependency/>
83.244 - <run-dependency>
83.245 - <specification-version>7.17</specification-version>
83.246 - </run-dependency>
83.247 - </dependency>
83.248 - <dependency>
83.249 - <code-name-base>org.openide.filesystems</code-name-base>
83.250 - <build-prerequisite/>
83.251 - <compile-dependency/>
83.252 - <run-dependency>
83.253 - <specification-version>7.43</specification-version>
83.254 - </run-dependency>
83.255 - </dependency>
83.256 - <dependency>
83.257 - <code-name-base>org.openide.loaders</code-name-base>
83.258 - <build-prerequisite/>
83.259 - <compile-dependency/>
83.260 - <run-dependency>
83.261 - <specification-version>7.19</specification-version>
83.262 - </run-dependency>
83.263 - </dependency>
83.264 - <dependency>
83.265 - <code-name-base>org.openide.nodes</code-name-base>
83.266 - <build-prerequisite/>
83.267 - <compile-dependency/>
83.268 - <run-dependency>
83.269 - <specification-version>7.19</specification-version>
83.270 - </run-dependency>
83.271 - </dependency>
83.272 - <dependency>
83.273 - <code-name-base>org.openide.text</code-name-base>
83.274 - <build-prerequisite/>
83.275 - <compile-dependency/>
83.276 - <run-dependency>
83.277 - <specification-version>6.34</specification-version>
83.278 - </run-dependency>
83.279 - </dependency>
83.280 - <dependency>
83.281 - <code-name-base>org.openide.util</code-name-base>
83.282 - <build-prerequisite/>
83.283 - <compile-dependency/>
83.284 - <run-dependency>
83.285 - <specification-version>8.9</specification-version>
83.286 - </run-dependency>
83.287 - </dependency>
83.288 - <dependency>
83.289 - <code-name-base>org.openide.util.lookup</code-name-base>
83.290 - <build-prerequisite/>
83.291 - <compile-dependency/>
83.292 - <run-dependency>
83.293 - <specification-version>8.5</specification-version>
83.294 - </run-dependency>
83.295 - </dependency>
83.296 - <dependency>
83.297 - <code-name-base>org.openide.windows</code-name-base>
83.298 - <build-prerequisite/>
83.299 - <compile-dependency/>
83.300 - <run-dependency>
83.301 - <specification-version>6.37</specification-version>
83.302 - </run-dependency>
83.303 - </dependency>
83.304 - <dependency>
83.305 - <code-name-base>org.openidex.util</code-name-base>
83.306 - <build-prerequisite/>
83.307 - <compile-dependency/>
83.308 - <run-dependency>
83.309 - <release-version>3</release-version>
83.310 - <specification-version>3.27</specification-version>
83.311 - </run-dependency>
83.312 - </dependency>
83.313 - </module-dependencies>
83.314 - <test-dependencies>
83.315 - <test-type>
83.316 - <name>unit</name>
83.317 - <test-dependency>
83.318 - <code-name-base>org.netbeans.libs.junit4</code-name-base>
83.319 - <compile-dependency/>
83.320 - </test-dependency>
83.321 - <test-dependency>
83.322 - <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
83.323 - <recursive/>
83.324 - <compile-dependency/>
83.325 - </test-dependency>
83.326 - </test-type>
83.327 - </test-dependencies>
83.328 - <public-packages/>
83.329 - </data>
83.330 - </configuration>
83.331 -</project>
84.1 --- a/borrowedtests/src/org/netbeans/api/java/source/SourceUtilsTestUtil.java Fri Jan 27 13:35:56 2012 +0100
84.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
84.3 @@ -1,441 +0,0 @@
84.4 -/*
84.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
84.6 - *
84.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
84.8 - *
84.9 - * The contents of this file are subject to the terms of either the GNU
84.10 - * General Public License Version 2 only ("GPL") or the Common
84.11 - * Development and Distribution License("CDDL") (collectively, the
84.12 - * "License"). You may not use this file except in compliance with the
84.13 - * License. You can obtain a copy of the License at
84.14 - * http://www.netbeans.org/cddl-gplv2.html
84.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
84.16 - * specific language governing permissions and limitations under the
84.17 - * License. When distributing the software, include this License Header
84.18 - * Notice in each file and include the License file at
84.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
84.20 - * particular file as subject to the "Classpath" exception as provided
84.21 - * by Sun in the GPL Version 2 section of the License file that
84.22 - * accompanied this code. If applicable, add the following below the
84.23 - * License Header, with the fields enclosed by brackets [] replaced by
84.24 - * your own identifying information:
84.25 - * "Portions Copyrighted [year] [name of copyright owner]"
84.26 - *
84.27 - * Contributor(s):
84.28 - *
84.29 - * The Original Software is NetBeans. The Initial Developer of the Original
84.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
84.31 - * Microsystems, Inc. All Rights Reserved.
84.32 - *
84.33 - * If you wish your version of this file to be governed by only the CDDL
84.34 - * or only the GPL Version 2, indicate your decision by adding
84.35 - * "[Contributor] elects to include this software in this distribution
84.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
84.37 - * single choice of license, a recipient has the option to distribute
84.38 - * your version of this file under either the CDDL, the GPL Version 2 or
84.39 - * to extend the choice of license to its licensees as provided above.
84.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
84.41 - * Version 2 license, then the option applies only if the new code is
84.42 - * made subject to such option by the copyright holder.
84.43 - */
84.44 -package org.netbeans.api.java.source;
84.45 -
84.46 -import com.sun.source.util.JavacTask;
84.47 -import java.beans.PropertyVetoException;
84.48 -import java.io.File;
84.49 -import java.io.IOException;
84.50 -import java.net.URL;
84.51 -import java.util.ArrayList;
84.52 -import java.util.Enumeration;
84.53 -import java.util.HashSet;
84.54 -import java.util.LinkedList;
84.55 -import java.util.List;
84.56 -import java.util.Map;
84.57 -import java.util.Set;
84.58 -import java.util.WeakHashMap;
84.59 -import java.util.logging.Logger;
84.60 -import java.util.logging.Level;
84.61 -import java.util.regex.Pattern;
84.62 -import javax.swing.event.ChangeListener;
84.63 -import junit.framework.Assert;
84.64 -import org.netbeans.api.editor.mimelookup.MimePath;
84.65 -import org.netbeans.api.java.classpath.ClassPath;
84.66 -import org.netbeans.api.java.queries.SourceForBinaryQuery;
84.67 -import org.netbeans.api.java.source.JavaSource.Phase;
84.68 -import org.netbeans.junit.NbTestCase;
84.69 -import org.netbeans.modules.java.JavaDataLoader;
84.70 -import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
84.71 -import org.netbeans.modules.java.source.parsing.JavacParser;
84.72 -import org.netbeans.modules.java.source.parsing.JavacParserFactory;
84.73 -import org.netbeans.modules.java.source.usages.IndexUtil;
84.74 -import org.netbeans.modules.parsing.api.indexing.IndexingManager;
84.75 -import org.netbeans.modules.parsing.impl.indexing.MimeTypes;
84.76 -import org.netbeans.spi.editor.mimelookup.MimeDataProvider;
84.77 -import org.netbeans.spi.java.classpath.ClassPathProvider;
84.78 -import org.netbeans.spi.java.classpath.support.ClassPathSupport;
84.79 -import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
84.80 -import org.netbeans.spi.java.queries.SourceLevelQueryImplementation;
84.81 -import org.openide.filesystems.FileObject;
84.82 -import org.openide.filesystems.FileStateInvalidException;
84.83 -import org.openide.filesystems.FileSystem;
84.84 -import org.openide.filesystems.FileUtil;
84.85 -import org.openide.filesystems.LocalFileSystem;
84.86 -import org.openide.filesystems.MIMEResolver;
84.87 -import org.openide.filesystems.MultiFileSystem;
84.88 -import org.openide.filesystems.Repository;
84.89 -import org.openide.filesystems.URLMapper;
84.90 -import org.openide.filesystems.XMLFileSystem;
84.91 -import org.openide.util.Lookup;
84.92 -import org.openide.util.lookup.Lookups;
84.93 -import org.openide.util.lookup.ProxyLookup;
84.94 -import org.openide.util.lookup.ServiceProvider;
84.95 -import org.xml.sax.SAXException;
84.96 -
84.97 -/**
84.98 - *
84.99 - * @author Jan Lahoda
84.100 - */
84.101 -public final class SourceUtilsTestUtil extends ProxyLookup {
84.102 -
84.103 - private static SourceUtilsTestUtil DEFAULT_LOOKUP = null;
84.104 -
84.105 - public SourceUtilsTestUtil() {
84.106 -// Assert.assertNull(DEFAULT_LOOKUP);
84.107 - DEFAULT_LOOKUP = this;
84.108 - }
84.109 -
84.110 - /**
84.111 - * Set the global default lookup with some fixed instances including META-INF/services/*.
84.112 - */
84.113 - /**
84.114 - * Set the global default lookup with some fixed instances including META-INF/services/*.
84.115 - */
84.116 - public static void setLookup(Object[] instances, ClassLoader cl) {
84.117 - DEFAULT_LOOKUP.setLookups(new Lookup[] {
84.118 - Lookups.fixed(instances),
84.119 - Lookups.metaInfServices(cl),
84.120 - Lookups.singleton(cl),
84.121 - });
84.122 - }
84.123 -
84.124 - private static Object[] extraLookupContent = null;
84.125 -
84.126 - public static void prepareTest(String[] additionalLayers, Object[] additionalLookupContent) throws IOException, SAXException, PropertyVetoException {
84.127 - List<URL> layers = new LinkedList<URL>();
84.128 -
84.129 - for (int cntr = 0; cntr < additionalLayers.length; cntr++) {
84.130 - boolean found = false;
84.131 -
84.132 - for (Enumeration<URL> en = Thread.currentThread().getContextClassLoader().getResources(additionalLayers[cntr]); en.hasMoreElements(); ) {
84.133 - found = true;
84.134 - layers.add(en.nextElement());
84.135 - }
84.136 -
84.137 - Assert.assertTrue(additionalLayers[cntr], found);
84.138 - }
84.139 -
84.140 - XMLFileSystem xmlFS = new XMLFileSystem();
84.141 - xmlFS.setXmlUrls(layers.toArray(new URL[0]));
84.142 -
84.143 - FileSystem system = new MultiFileSystem(new FileSystem[] {FileUtil.createMemoryFileSystem(), xmlFS});
84.144 -
84.145 - Repository repository = new Repository(system);
84.146 - extraLookupContent = new Object[additionalLookupContent.length + 1];
84.147 -
84.148 - System.arraycopy(additionalLookupContent, 0, extraLookupContent, 1, additionalLookupContent.length);
84.149 -
84.150 - extraLookupContent[0] = repository;
84.151 -
84.152 - SourceUtilsTestUtil.setLookup(extraLookupContent, SourceUtilsTestUtil.class.getClassLoader());
84.153 -
84.154 - SourceUtilsTestUtil2.disableLocks();
84.155 -
84.156 - Set<String> mimeTypes = MimeTypes.getAllMimeTypes();
84.157 -
84.158 - if (mimeTypes == null) {
84.159 - mimeTypes = new HashSet<String>();
84.160 - } else {
84.161 - mimeTypes = new HashSet<String>(mimeTypes);
84.162 - }
84.163 -
84.164 - mimeTypes.add("text/x-java");
84.165 -
84.166 - MimeTypes.setAllMimeTypes(mimeTypes);
84.167 - org.netbeans.api.project.ui.OpenProjects.getDefault().getOpenProjects();
84.168 - }
84.169 -
84.170 - static {
84.171 - SourceUtilsTestUtil.class.getClassLoader().setDefaultAssertionStatus(true);
84.172 - System.setProperty("org.openide.util.Lookup", SourceUtilsTestUtil.class.getName());
84.173 - Assert.assertEquals(SourceUtilsTestUtil.class, Lookup.getDefault().getClass());
84.174 - }
84.175 -
84.176 - public static void prepareTest(FileObject sourceRoot, FileObject buildRoot, FileObject cache) throws Exception {
84.177 - prepareTest(sourceRoot, buildRoot, cache, new FileObject[0]);
84.178 - }
84.179 -
84.180 - public static void prepareTest(FileObject sourceRoot, FileObject buildRoot, FileObject cache, FileObject[] classPathElements) throws Exception {
84.181 - if (extraLookupContent == null)
84.182 - prepareTest(new String[0], new Object[0]);
84.183 -
84.184 - Object[] lookupContent = new Object[extraLookupContent.length + 4];
84.185 -
84.186 - System.arraycopy(extraLookupContent, 0, lookupContent, 4, extraLookupContent.length);
84.187 -
84.188 - lookupContent[0] = new TestProxyClassPathProvider(sourceRoot, buildRoot, classPathElements);
84.189 - lookupContent[1] = new TestSourceForBinaryQuery(sourceRoot, buildRoot);
84.190 - lookupContent[2] = new TestSourceLevelQueryImplementation();
84.191 - lookupContent[3] = JavaDataLoader.findObject(JavaDataLoader.class, true);
84.192 -
84.193 - setLookup(lookupContent, SourceUtilsTestUtil.class.getClassLoader());
84.194 -
84.195 - IndexUtil.setCacheFolder(FileUtil.toFile(cache));
84.196 - }
84.197 -
84.198 - private static Map<FileObject, String> file2SourceLevel = new WeakHashMap<FileObject, String>();
84.199 -
84.200 - public static void setSourceLevel(FileObject file, String level) {
84.201 - file2SourceLevel.put(file, level);
84.202 - }
84.203 -
84.204 - /**This method assures that all java classes under sourceRoot are compiled,
84.205 - * and the caches are created for them.
84.206 - */
84.207 - public static void compileRecursively(FileObject sourceRoot) throws Exception {
84.208 - IndexingManager.getDefault().refreshIndexAndWait(sourceRoot.getURL(), null);
84.209 - }
84.210 -
84.211 - private static List<URL> bootClassPath;
84.212 -
84.213 - private static Logger log = Logger.getLogger(SourceUtilsTestUtil.class.getName());
84.214 -
84.215 - public static synchronized List<URL> getBootClassPath() {
84.216 - if (bootClassPath == null) {
84.217 - try {
84.218 - String cp = System.getProperty("sun.boot.class.path");
84.219 - List<URL> urls = new ArrayList<URL>();
84.220 - String[] paths = cp.split(Pattern.quote(System.getProperty("path.separator")));
84.221 -
84.222 - for (String path : paths) {
84.223 - File f = new File(path);
84.224 -
84.225 - if (!f.canRead())
84.226 - continue;
84.227 -
84.228 - FileObject fo = FileUtil.toFileObject(f);
84.229 -
84.230 - if (FileUtil.isArchiveFile(fo)) {
84.231 - fo = FileUtil.getArchiveRoot(fo);
84.232 - }
84.233 -
84.234 - if (fo != null) {
84.235 - urls.add(fo.getURL());
84.236 - }
84.237 - }
84.238 -
84.239 - bootClassPath = urls;
84.240 - } catch (FileStateInvalidException e) {
84.241 - if (log.isLoggable(Level.SEVERE))
84.242 - log.log(Level.SEVERE, e.getMessage(), e);
84.243 - }
84.244 - }
84.245 -
84.246 - return bootClassPath;
84.247 - }
84.248 -
84.249 - private static class TestSourceForBinaryQuery implements SourceForBinaryQueryImplementation {
84.250 -
84.251 - private final FileObject sourceRoot;
84.252 - private final FileObject buildRoot;
84.253 -
84.254 - public TestSourceForBinaryQuery(FileObject sourceRoot, FileObject buildRoot) {
84.255 - this.sourceRoot = sourceRoot;
84.256 - this.buildRoot = buildRoot;
84.257 - }
84.258 -
84.259 - public SourceForBinaryQuery.Result findSourceRoots(URL binaryRoot) {
84.260 - FileObject f = URLMapper.findFileObject(binaryRoot);
84.261 -
84.262 - if (buildRoot.equals(f)) {
84.263 - return new SourceForBinaryQuery.Result() {
84.264 - public FileObject[] getRoots() {
84.265 - return new FileObject[] {
84.266 - sourceRoot,
84.267 - };
84.268 - }
84.269 -
84.270 - public void addChangeListener(ChangeListener l) {
84.271 - }
84.272 -
84.273 - public void removeChangeListener(ChangeListener l) {
84.274 - }
84.275 - };
84.276 - }
84.277 -
84.278 - return null;
84.279 - }
84.280 -
84.281 - }
84.282 -
84.283 - private static class TestProxyClassPathProvider implements ClassPathProvider {
84.284 -
84.285 - private FileObject sourceRoot;
84.286 - private FileObject buildRoot;
84.287 - private FileObject[] classPathElements;
84.288 -
84.289 - public TestProxyClassPathProvider(FileObject sourceRoot, FileObject buildRoot, FileObject[] classPathElements) {
84.290 - this.sourceRoot = sourceRoot;
84.291 - this.buildRoot = buildRoot;
84.292 - this.classPathElements = classPathElements;
84.293 - }
84.294 -
84.295 - public ClassPath findClassPath(FileObject file, String type) {
84.296 - try {
84.297 - if (ClassPath.BOOT == type) {
84.298 - return ClassPathSupport.createClassPath(getBootClassPath().toArray(new URL[0]));
84.299 - }
84.300 -
84.301 - if (ClassPath.SOURCE == type) {
84.302 - return ClassPathSupport.createClassPath(new FileObject[] {
84.303 - sourceRoot
84.304 - });
84.305 - }
84.306 -
84.307 - if (ClassPath.COMPILE == type) {
84.308 - return ClassPathSupport.createClassPath(classPathElements);
84.309 - }
84.310 -
84.311 - if (ClassPath.EXECUTE == type) {
84.312 - return ClassPathSupport.createClassPath(new FileObject[] {
84.313 - buildRoot
84.314 - });
84.315 - }
84.316 - } catch (Exception e) {
84.317 - e.printStackTrace();
84.318 - }
84.319 - return null;
84.320 - }
84.321 -
84.322 - }
84.323 -
84.324 - public static class TestSourceLevelQueryImplementation implements SourceLevelQueryImplementation {
84.325 -
84.326 - public String getSourceLevel(FileObject javaFile) {
84.327 - String level = file2SourceLevel.get(javaFile);
84.328 -
84.329 - if (level == null) {
84.330 - if (javaFile.isFolder()) {
84.331 - for (FileObject data : file2SourceLevel.keySet()) {
84.332 - if (FileUtil.isParentOf(javaFile, data)) {
84.333 - return file2SourceLevel.get(data);
84.334 - }
84.335 - }
84.336 - }
84.337 - return "1.5";
84.338 - } else
84.339 - return level;
84.340 - }
84.341 -
84.342 - }
84.343 -
84.344 - /**Copied from org.netbeans.api.project.
84.345 - * Create a scratch directory for tests.
84.346 - * Will be in /tmp or whatever, and will be empty.
84.347 - * If you just need a java.io.File use clearWorkDir + getWorkDir.
84.348 - */
84.349 - public static FileObject makeScratchDir(NbTestCase test) throws IOException {
84.350 - test.clearWorkDir();
84.351 - File root = test.getWorkDir();
84.352 - assert root.isDirectory() && root.list().length == 0;
84.353 - FileObject fo = FileUtil.toFileObject(root);
84.354 - if (fo != null) {
84.355 - // Presumably using masterfs.
84.356 - return fo;
84.357 - } else {
84.358 - // For the benefit of those not using masterfs.
84.359 - LocalFileSystem lfs = new LocalFileSystem();
84.360 - try {
84.361 - lfs.setRootDirectory(root);
84.362 - } catch (PropertyVetoException e) {
84.363 - assert false : e;
84.364 - }
84.365 - Repository.getDefault().addFileSystem(lfs);
84.366 - return lfs.getRoot();
84.367 - }
84.368 - }
84.369 -
84.370 - public static JavacTask getJavacTaskFor(CompilationInfo info) {
84.371 - return info.impl.getJavacTask();
84.372 - }
84.373 -
84.374 - /** Blocking call for CompilationInfo after given phase is reached.
84.375 - * @param phase to be reached
84.376 - * @return CompilationInfo or null
84.377 - * XXX: REMOVE ME!!!!!!!
84.378 - */
84.379 - public static CompilationInfo getCompilationInfo(JavaSource js, Phase phase ) throws IOException {
84.380 - if (phase == null || phase == Phase.MODIFIED) {
84.381 - throw new IllegalArgumentException (String.format("The %s is not a legal value of phase",phase)); //NOI18N
84.382 - }
84.383 - final DeadlockTask bt = new DeadlockTask(phase);
84.384 - js.runUserActionTask(bt,true);
84.385 - return bt.info;
84.386 - }
84.387 -
84.388 -
84.389 - private static class DeadlockTask implements Task<CompilationController> {
84.390 -
84.391 - private final Phase phase;
84.392 - private CompilationInfo info;
84.393 -
84.394 - public DeadlockTask(Phase phase) {
84.395 - assert phase != null;
84.396 - this.phase = phase;
84.397 - }
84.398 -
84.399 - public void run( CompilationController info ) {
84.400 - try {
84.401 - info.toPhase(this.phase);
84.402 - this.info = info;
84.403 - } catch (IOException ioe) {
84.404 - if (log.isLoggable(Level.SEVERE))
84.405 - log.log(Level.SEVERE, ioe.getMessage(), ioe);
84.406 - }
84.407 - }
84.408 -
84.409 - }
84.410 -
84.411 - @ServiceProvider(service=MimeDataProvider.class)
84.412 - public static final class JavacParserProvider implements MimeDataProvider {
84.413 -
84.414 - private Lookup javaLookup = Lookups.fixed(new JavacParserFactory(), new JavaCustomIndexer.Factory());
84.415 -
84.416 - public Lookup getLookup(MimePath mimePath) {
84.417 - if (mimePath.getPath().endsWith(JavacParser.MIME_TYPE)) {
84.418 - return javaLookup;
84.419 - }
84.420 -
84.421 - return Lookup.EMPTY;
84.422 - }
84.423 -
84.424 - }
84.425 -
84.426 - @ServiceProvider(service=MIMEResolver.class)
84.427 - public static final class JavaMimeResolver extends MIMEResolver {
84.428 -
84.429 - public JavaMimeResolver() {
84.430 - super(JavacParser.MIME_TYPE);
84.431 - }
84.432 -
84.433 - @Override
84.434 - public String findMIMEType(FileObject fo) {
84.435 - if ("java".equals(fo.getExt())) {
84.436 - return JavacParser.MIME_TYPE;
84.437 - }
84.438 -
84.439 - return null;
84.440 - }
84.441 -
84.442 - }
84.443 -
84.444 -}
85.1 --- a/borrowedtests/src/org/netbeans/api/java/source/SourceUtilsTestUtil2.java Fri Jan 27 13:35:56 2012 +0100
85.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
85.3 @@ -1,80 +0,0 @@
85.4 -/*
85.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
85.6 - *
85.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
85.8 - *
85.9 - * The contents of this file are subject to the terms of either the GNU
85.10 - * General Public License Version 2 only ("GPL") or the Common
85.11 - * Development and Distribution License("CDDL") (collectively, the
85.12 - * "License"). You may not use this file except in compliance with the
85.13 - * License. You can obtain a copy of the License at
85.14 - * http://www.netbeans.org/cddl-gplv2.html
85.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
85.16 - * specific language governing permissions and limitations under the
85.17 - * License. When distributing the software, include this License Header
85.18 - * Notice in each file and include the License file at
85.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
85.20 - * particular file as subject to the "Classpath" exception as provided
85.21 - * by Sun in the GPL Version 2 section of the License file that
85.22 - * accompanied this code. If applicable, add the following below the
85.23 - * License Header, with the fields enclosed by brackets [] replaced by
85.24 - * your own identifying information:
85.25 - * "Portions Copyrighted [year] [name of copyright owner]"
85.26 - *
85.27 - * Contributor(s):
85.28 - *
85.29 - * The Original Software is NetBeans. The Initial Developer of the Original
85.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
85.31 - * Microsystems, Inc. All Rights Reserved.
85.32 - *
85.33 - * If you wish your version of this file to be governed by only the CDDL
85.34 - * or only the GPL Version 2, indicate your decision by adding
85.35 - * "[Contributor] elects to include this software in this distribution
85.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
85.37 - * single choice of license, a recipient has the option to distribute
85.38 - * your version of this file under either the CDDL, the GPL Version 2 or
85.39 - * to extend the choice of license to its licensees as provided above.
85.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
85.41 - * Version 2 license, then the option applies only if the new code is
85.42 - * made subject to such option by the copyright holder.
85.43 - */
85.44 -package org.netbeans.api.java.source;
85.45 -
85.46 -import com.sun.source.tree.Tree;
85.47 -import org.apache.lucene.store.FSDirectory;
85.48 -import org.netbeans.modules.java.source.transform.Transformer;
85.49 -
85.50 -/**
85.51 - *
85.52 - * @author Jan Lahoda
85.53 - */
85.54 -public final class SourceUtilsTestUtil2 {
85.55 -
85.56 - private SourceUtilsTestUtil2() {
85.57 - }
85.58 -
85.59 - public static <R, P> void run(WorkingCopy wc, Transformer<R, P> t) {
85.60 -// if (afterCommit)
85.61 -// throw new IllegalStateException ("The run method can't be called on a WorkingCopy instance after the commit"); //NOI18N
85.62 - t.init();
85.63 - t.attach(wc.impl.getJavacTask().getContext(), wc);
85.64 - t.apply(wc.getCompilationUnit());
85.65 - t.release();
85.66 - t.destroy();
85.67 - }
85.68 -
85.69 - public static <R, P> void run(WorkingCopy wc, Transformer<R, P> t, Tree tree) {
85.70 -// if (afterCommit)
85.71 -// throw new IllegalStateException ("The run method can't be called on a WorkingCopy instance after the commit"); //NOI18N
85.72 - t.init();
85.73 - t.attach(wc.impl.getJavacTask().getContext(), wc);
85.74 - t.apply(tree);
85.75 - t.release();
85.76 - t.destroy();
85.77 - }
85.78 -
85.79 - public static void disableLocks() {
85.80 -// FSDirectory.setDisableLocks(true);
85.81 - }
85.82 -
85.83 -}
86.1 --- a/borrowedtests/src/org/netbeans/api/java/source/TestUtilities.java Fri Jan 27 13:35:56 2012 +0100
86.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
86.3 @@ -1,263 +0,0 @@
86.4 -/*
86.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
86.6 - *
86.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
86.8 - *
86.9 - * The contents of this file are subject to the terms of either the GNU
86.10 - * General Public License Version 2 only ("GPL") or the Common
86.11 - * Development and Distribution License("CDDL") (collectively, the
86.12 - * "License"). You may not use this file except in compliance with the
86.13 - * License. You can obtain a copy of the License at
86.14 - * http://www.netbeans.org/cddl-gplv2.html
86.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
86.16 - * specific language governing permissions and limitations under the
86.17 - * License. When distributing the software, include this License Header
86.18 - * Notice in each file and include the License file at
86.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
86.20 - * particular file as subject to the "Classpath" exception as provided
86.21 - * by Sun in the GPL Version 2 section of the License file that
86.22 - * accompanied this code. If applicable, add the following below the
86.23 - * License Header, with the fields enclosed by brackets [] replaced by
86.24 - * your own identifying information:
86.25 - * "Portions Copyrighted [year] [name of copyright owner]"
86.26 - *
86.27 - * Contributor(s):
86.28 - *
86.29 - * The Original Software is NetBeans. The Initial Developer of the Original
86.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
86.31 - * Microsystems, Inc. All Rights Reserved.
86.32 - *
86.33 - * If you wish your version of this file to be governed by only the CDDL
86.34 - * or only the GPL Version 2, indicate your decision by adding
86.35 - * "[Contributor] elects to include this software in this distribution
86.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
86.37 - * single choice of license, a recipient has the option to distribute
86.38 - * your version of this file under either the CDDL, the GPL Version 2 or
86.39 - * to extend the choice of license to its licensees as provided above.
86.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
86.41 - * Version 2 license, then the option applies only if the new code is
86.42 - * made subject to such option by the copyright holder.
86.43 - */
86.44 -
86.45 -package org.netbeans.api.java.source;
86.46 -
86.47 -import java.io.ByteArrayInputStream;
86.48 -import java.io.EOFException;
86.49 -import java.io.File;
86.50 -import java.io.FileInputStream;
86.51 -import java.io.FileOutputStream;
86.52 -import java.io.IOException;
86.53 -import java.io.InputStream;
86.54 -import java.io.OutputStream;
86.55 -import java.net.URL;
86.56 -import java.util.ArrayList;
86.57 -import java.util.Collection;
86.58 -import java.util.List;
86.59 -import java.util.concurrent.ExecutionException;
86.60 -import java.util.concurrent.Future;
86.61 -import java.util.concurrent.TimeUnit;
86.62 -import java.util.concurrent.TimeoutException;
86.63 -import java.util.concurrent.atomic.AtomicBoolean;
86.64 -import java.util.zip.GZIPInputStream;
86.65 -
86.66 -import org.netbeans.api.java.classpath.ClassPath;
86.67 -import org.netbeans.modules.java.source.usages.BinaryAnalyser;
86.68 -import org.netbeans.modules.java.source.usages.ClassIndexImpl;
86.69 -import org.netbeans.modules.java.source.usages.ClassIndexManager;
86.70 -import org.netbeans.modules.java.source.usages.IndexUtil;
86.71 -//import org.netbeans.modules.parsing.lucene.support.IndexManager.Action;
86.72 -import org.netbeans.spi.java.classpath.support.ClassPathSupport;
86.73 -import org.openide.filesystems.FileObject;
86.74 -import org.openide.filesystems.FileUtil;
86.75 -
86.76 -/**
86.77 - * Utilities to aid unit testing java.source module.
86.78 - *
86.79 - * @author Jaroslav Tulach
86.80 - * @author Tom Ball
86.81 - * @author Tomas Zezula
86.82 - */
86.83 -public final class TestUtilities {
86.84 -
86.85 - // do not instantiate
86.86 - private TestUtilities() {}
86.87 -
86.88 - /**
86.89 - * Waits for the end of the background scan, this helper method
86.90 - * is designed for tests which require to wait for the end of initial scan.
86.91 - * The method can be used as a barrier but it is not guaranteed that the
86.92 - * background scan will not start again after return from this method, the
86.93 - * test is responsible for it itself. In general it's safer to use {@link JavaSource#runWhenScanFinished}
86.94 - * method and do the critical action inside the run method.
86.95 - * @param timeout the maximum time to wait
86.96 - * @param unit the time unit of the timeout argument
86.97 - * @return true if the scan finished, false when the timeout elapsed before the end of the scan.
86.98 - * @throws InterruptedException is thrown when the waiting thread is interrupted.
86.99 - */
86.100 - public static boolean waitScanFinished (final long timeout, final TimeUnit unit) throws InterruptedException {
86.101 - assert unit != null;
86.102 - final ClasspathInfo cpInfo = ClasspathInfo.create(ClassPathSupport.createClassPath(new URL[0]),
86.103 - ClassPathSupport.createClassPath(new URL[0]), null);
86.104 - assert cpInfo != null;
86.105 - final JavaSource js = JavaSource.create(cpInfo);
86.106 - assert js != null;
86.107 - try {
86.108 - Future<Void> future = js.runWhenScanFinished(new Task<CompilationController>() {
86.109 - public void run(CompilationController parameter) throws Exception {
86.110 - }
86.111 - }, true);
86.112 - future.get(timeout,unit);
86.113 - return true;
86.114 - } catch (IOException ioe) {
86.115 - //Actually never thrown
86.116 - }
86.117 - catch (ExecutionException ee) {
86.118 - //Actually never thrown
86.119 - }
86.120 - catch (TimeoutException timeoutEx) {
86.121 - }
86.122 - return false;
86.123 - }
86.124 -
86.125 -// /**
86.126 -// * Disables use of {@link LibraryManager} in the {@link GlobalSourcePath}. The tests
86.127 -// * which don't register {@link LibraryProvider} or {@link LibraryTypeProvider} may
86.128 -// * use this method to disable use of {@link LibraryManager} in the {@link GlobalSourcePath}.
86.129 -// * @param use false value disables use of {@link LibraryManager}
86.130 -// */
86.131 -// public static void setUseLibraries (final boolean use) {
86.132 -// //GlobalSourcePathTestUtil.setUseLibraries(use);
86.133 -// // IMO this in fact did nothing... If your tests are failing due to this
86.134 -// // please file a defect on editor/parsing & indexing and we will try to help.
86.135 -// }
86.136 -
86.137 - /**
86.138 - * Sets a root folder of the java source caches. This method may be used by tests
86.139 - * which need to do an initial compilation, they require either {@link ClassIndex} or
86.140 - * need to work with a group of related java files.
86.141 - * @param cacheFolder the folder used by java infrastructure as a cache,
86.142 - * has to exist and must be a folder.
86.143 - */
86.144 - public static void setCacheFolder (final File cacheFolder) {
86.145 - IndexUtil.setCacheFolder(cacheFolder);
86.146 - }
86.147 -
86.148 - /**
86.149 - * Creates boot {@link ClassPath} for platform the test is running on,
86.150 - * it uses the sun.boot.class.path property to find out the boot path roots.
86.151 - * @return ClassPath
86.152 - * @throws java.io.IOException when boot path property contains non valid path
86.153 - */
86.154 - public static ClassPath createBootClassPath () throws IOException {
86.155 - String bootPath = System.getProperty ("sun.boot.class.path");
86.156 - String[] paths = bootPath.split(File.pathSeparator);
86.157 - List<URL>roots = new ArrayList<URL> (paths.length);
86.158 - for (String path : paths) {
86.159 - File f = new File (path);
86.160 - if (!f.exists()) {
86.161 - continue;
86.162 - }
86.163 - URL url = f.toURI().toURL();
86.164 - if (FileUtil.isArchiveFile(url)) {
86.165 - url = FileUtil.getArchiveRoot(url);
86.166 - }
86.167 - roots.add (url);
86.168 - }
86.169 - return ClassPathSupport.createClassPath(roots.toArray(new URL[roots.size()]));
86.170 - }
86.171 - /**
86.172 - * Returns a string which contains the contents of a file.
86.173 - *
86.174 - * @param f the file to be read
86.175 - * @return the contents of the file(s).
86.176 - */
86.177 - public final static String copyFileToString (java.io.File f) throws java.io.IOException {
86.178 - int s = (int)f.length ();
86.179 - byte[] data = new byte[s];
86.180 - int len = new FileInputStream (f).read (data);
86.181 - if (len != s)
86.182 - throw new EOFException("truncated file");
86.183 - return new String (data);
86.184 - }
86.185 -
86.186 - /**
86.187 - * Returns a string which contains the contents of a GZIP compressed file.
86.188 - *
86.189 - * @param f the file to be read
86.190 - * @return the contents of the file(s).
86.191 - */
86.192 - public final static String copyGZipFileToString (java.io.File f) throws java.io.IOException {
86.193 - GZIPInputStream is = new GZIPInputStream(new FileInputStream(f));
86.194 - byte[] arr = new byte[256 * 256];
86.195 - int first = 0;
86.196 - for(;;) {
86.197 - int len = is.read(arr, first, arr.length - first);
86.198 - if (first + len < arr.length) {
86.199 - return new String(arr, 0, first + len);
86.200 - }
86.201 - }
86.202 - }
86.203 -
86.204 - /**
86.205 - * Copies a string to a specified file.
86.206 - *
86.207 - * @param f the file to use.
86.208 - * @param content the contents of the returned file.
86.209 - * @return the created file
86.210 - */
86.211 - public final static File copyStringToFile (File f, String content) throws Exception {
86.212 - FileOutputStream os = new FileOutputStream(f);
86.213 - InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
86.214 - FileUtil.copy(is, os);
86.215 - os.close ();
86.216 - is.close();
86.217 -
86.218 - return f;
86.219 - }
86.220 -
86.221 - /**
86.222 - * Copies a string to a specified file.
86.223 - *
86.224 - * @param f the {@link FilObject} to use.
86.225 - * @param content the contents of the returned file.
86.226 - * @return the created file
86.227 - */
86.228 - public final static FileObject copyStringToFile (FileObject f, String content) throws Exception {
86.229 - OutputStream os = f.getOutputStream();
86.230 - InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
86.231 - FileUtil.copy(is, os);
86.232 - os.close ();
86.233 - is.close();
86.234 -
86.235 - return f;
86.236 - }
86.237 -
86.238 - private static final ClassPath EMPTY = ClassPathSupport.createClassPath(new URL[0]);
86.239 -
86.240 -// /**
86.241 -// * Prepare Java caches for given binary roots.
86.242 -// *
86.243 -// * @param urls to analyze
86.244 -// */
86.245 -// public final static void analyzeBinaries(final Collection<URL> urls) throws IOException {
86.246 -// final ClasspathInfo cpInfo = ClasspathInfo.create(EMPTY, EMPTY, EMPTY);
86.247 -// final ClassIndexManager mgr = ClassIndexManager.getDefault();
86.248 -// final JavaSource js = JavaSource.create(cpInfo);
86.249 -// js.runUserActionTask(new Task<CompilationController>() {
86.250 -// public void run(CompilationController parameter) throws Exception {
86.251 -// for (final URL url : urls) {
86.252 -// final ClassIndexImpl cii = mgr.createUsagesQuery(url, false);
86.253 -// ClassIndexManager.getDefault().writeLock(new Action<Void>() {
86.254 -// public Void run() throws IOException, InterruptedException {
86.255 -// BinaryAnalyser ba = cii.getBinaryAnalyser();
86.256 -// ba.start(url, new AtomicBoolean(false), new AtomicBoolean(false));
86.257 -// ba.finish();
86.258 -// return null;
86.259 -// }
86.260 -// });
86.261 -// }
86.262 -// }
86.263 -// }, true);
86.264 -// }
86.265 -
86.266 -}
87.1 --- a/borrowedtests/src/org/netbeans/modules/jackpot30/impl/TestUtils.java Fri Jan 27 13:35:56 2012 +0100
87.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
87.3 @@ -1,116 +0,0 @@
87.4 -/*
87.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
87.6 - *
87.7 - * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
87.8 - *
87.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
87.10 - * Other names may be trademarks of their respective owners.
87.11 - *
87.12 - * The contents of this file are subject to the terms of either the GNU
87.13 - * General Public License Version 2 only ("GPL") or the Common
87.14 - * Development and Distribution License("CDDL") (collectively, the
87.15 - * "License"). You may not use this file except in compliance with the
87.16 - * License. You can obtain a copy of the License at
87.17 - * http://www.netbeans.org/cddl-gplv2.html
87.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
87.19 - * specific language governing permissions and limitations under the
87.20 - * License. When distributing the software, include this License Header
87.21 - * Notice in each file and include the License file at
87.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
87.23 - * particular file as subject to the "Classpath" exception as provided
87.24 - * by Oracle in the GPL Version 2 section of the License file that
87.25 - * accompanied this code. If applicable, add the following below the
87.26 - * License Header, with the fields enclosed by brackets [] replaced by
87.27 - * your own identifying information:
87.28 - * "Portions Copyrighted [year] [name of copyright owner]"
87.29 - *
87.30 - * If you wish your version of this file to be governed by only the CDDL
87.31 - * or only the GPL Version 2, indicate your decision by adding
87.32 - * "[Contributor] elects to include this software in this distribution
87.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
87.34 - * single choice of license, a recipient has the option to distribute
87.35 - * your version of this file under either the CDDL, the GPL Version 2 or
87.36 - * to extend the choice of license to its licensees as provided above.
87.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
87.38 - * Version 2 license, then the option applies only if the new code is
87.39 - * made subject to such option by the copyright holder.
87.40 - *
87.41 - * Contributor(s):
87.42 - *
87.43 - * Portions Copyrighted 2011 Sun Microsystems, Inc.
87.44 - */
87.45 -package org.netbeans.modules.jackpot30.impl;
87.46 -
87.47 -import java.io.ByteArrayInputStream;
87.48 -import java.io.IOException;
87.49 -import java.net.URL;
87.50 -import java.net.URLConnection;
87.51 -import java.net.URLStreamHandler;
87.52 -import java.net.URLStreamHandlerFactory;
87.53 -import java.util.HashMap;
87.54 -import java.util.Map;
87.55 -import junit.framework.Assert;
87.56 -import org.openide.util.lookup.ServiceProvider;
87.57 -
87.58 -/**
87.59 - *
87.60 - * @author lahvac
87.61 - */
87.62 -public class TestUtils {
87.63 -
87.64 - public static void clearRemoteContent() {
87.65 - content.clear();
87.66 - }
87.67 -
87.68 - public static void addRemoteContent(URL url, String content) {
87.69 - TestUtils.content.put(url, content);
87.70 - }
87.71 -
87.72 - private static final Map<URL, String> content = new HashMap<URL, String>();
87.73 -
87.74 - @ServiceProvider(service=URLStreamHandlerFactory.class)
87.75 - public static final class URLStreamHandlerFactoryImpl implements URLStreamHandlerFactory {
87.76 -
87.77 - public URLStreamHandler createURLStreamHandler(String protocol) {
87.78 - if ("test".equals(protocol)) {
87.79 - return new URLStreamHandlerImpl();
87.80 - }
87.81 -
87.82 - return null;
87.83 - }
87.84 -
87.85 - }
87.86 -
87.87 - private static final class URLStreamHandlerImpl extends URLStreamHandler {
87.88 -
87.89 - @Override
87.90 - protected URLConnection openConnection(URL u) throws IOException {
87.91 - String str = content.get(u);
87.92 -
87.93 - Assert.assertNotNull(u.toExternalForm(), str);
87.94 -
87.95 - return new TestURLConnection(u, str);
87.96 - }
87.97 -
87.98 - }
87.99 -
87.100 - private static final class TestURLConnection extends URLConnection {
87.101 -
87.102 - private final String content;
87.103 -
87.104 - public TestURLConnection(URL url, String content) {
87.105 - super(url);
87.106 - this.content = content;
87.107 - }
87.108 -
87.109 - @Override
87.110 - public void connect() throws IOException {
87.111 - }
87.112 -
87.113 - @Override
87.114 - public Object getContent() throws IOException {
87.115 - return new ByteArrayInputStream(content.getBytes("ASCII")); //XXX
87.116 - }
87.117 -
87.118 - }
87.119 -}
88.1 --- a/borrowedtests/src/org/netbeans/modules/jackpot30/test/borrowed/Bundle.properties Fri Jan 27 13:35:56 2012 +0100
88.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
88.3 @@ -1,38 +0,0 @@
88.4 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
88.5 -#
88.6 -# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
88.7 -#
88.8 -# The contents of this file are subject to the terms of either the GNU
88.9 -# General Public License Version 2 only ("GPL") or the Common
88.10 -# Development and Distribution License("CDDL") (collectively, the
88.11 -# "License"). You may not use this file except in compliance with the
88.12 -# License. You can obtain a copy of the License at
88.13 -# http://www.netbeans.org/cddl-gplv2.html
88.14 -# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
88.15 -# specific language governing permissions and limitations under the
88.16 -# License. When distributing the software, include this License Header
88.17 -# Notice in each file and include the License file at
88.18 -# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
88.19 -# particular file as subject to the "Classpath" exception as provided
88.20 -# by Sun in the GPL Version 2 section of the License file that
88.21 -# accompanied this code. If applicable, add the following below the
88.22 -# License Header, with the fields enclosed by brackets [] replaced by
88.23 -# your own identifying information:
88.24 -# "Portions Copyrighted [year] [name of copyright owner]"
88.25 -#
88.26 -# If you wish your version of this file to be governed by only the CDDL
88.27 -# or only the GPL Version 2, indicate your decision by adding
88.28 -# "[Contributor] elects to include this software in this distribution
88.29 -# under the [CDDL or GPL Version 2] license." If you do not indicate a
88.30 -# single choice of license, a recipient has the option to distribute
88.31 -# your version of this file under either the CDDL, the GPL Version 2 or
88.32 -# to extend the choice of license to its licensees as provided above.
88.33 -# However, if you add GPL Version 2 code and therefore, elected the GPL
88.34 -# Version 2 license, then the option applies only if the new code is
88.35 -# made subject to such option by the copyright holder.
88.36 -#
88.37 -# Contributor(s):
88.38 -#
88.39 -# Portions Copyrighted 2009 Sun Microsystems, Inc.
88.40 -
88.41 -OpenIDE-Module-Name=Borrowed Test Infra
89.1 --- a/borrowedtests/src/org/netbeans/modules/java/hints/TestUtilities.java Fri Jan 27 13:35:56 2012 +0100
89.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
89.3 @@ -1,60 +0,0 @@
89.4 -/*
89.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
89.6 - *
89.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
89.8 - *
89.9 - * The contents of this file are subject to the terms of either the GNU
89.10 - * General Public License Version 2 only ("GPL") or the Common
89.11 - * Development and Distribution License("CDDL") (collectively, the
89.12 - * "License"). You may not use this file except in compliance with the
89.13 - * License. You can obtain a copy of the License at
89.14 - * http://www.netbeans.org/cddl-gplv2.html
89.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
89.16 - * specific language governing permissions and limitations under the
89.17 - * License. When distributing the software, include this License Header
89.18 - * Notice in each file and include the License file at
89.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
89.20 - * particular file as subject to the "Classpath" exception as provided
89.21 - * by Sun in the GPL Version 2 section of the License file that
89.22 - * accompanied this code. If applicable, add the following below the
89.23 - * License Header, with the fields enclosed by brackets [] replaced by
89.24 - * your own identifying information:
89.25 - * "Portions Copyrighted [year] [name of copyright owner]"
89.26 - *
89.27 - * Contributor(s):
89.28 - *
89.29 - * Portions Copyrighted 2007 Sun Microsystems, Inc.
89.30 - */
89.31 -package org.netbeans.modules.java.hints;
89.32 -
89.33 -import junit.framework.Assert;
89.34 -
89.35 -/**
89.36 - *
89.37 - * @author Jan Lahoda
89.38 - */
89.39 -public class TestUtilities {
89.40 -
89.41 - private TestUtilities() {
89.42 - }
89.43 -
89.44 - public static String detectOffsets(String source, int[] positionOrSpan) {
89.45 - //for now, the position/span delimiter is '|', without possibility of escaping:
89.46 - String[] split = source.split("\\|");
89.47 -
89.48 - Assert.assertTrue("incorrect number of position markers (|)", positionOrSpan.length == split.length - 1);
89.49 -
89.50 - StringBuilder sb = new StringBuilder();
89.51 - int index = 0;
89.52 - int offset = 0;
89.53 -
89.54 - for (String s : split) {
89.55 - sb.append(s);
89.56 - if (index < positionOrSpan.length)
89.57 - positionOrSpan[index++] = (offset += s.length());
89.58 - }
89.59 -
89.60 - return sb.toString();
89.61 - }
89.62 -
89.63 -}
90.1 --- a/borrowedtests/src/org/netbeans/modules/java/hints/infrastructure/TreeRuleTestBase.java Fri Jan 27 13:35:56 2012 +0100
90.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
90.3 @@ -1,303 +0,0 @@
90.4 -/*
90.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
90.6 - *
90.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
90.8 - *
90.9 - * The contents of this file are subject to the terms of either the GNU
90.10 - * General Public License Version 2 only ("GPL") or the Common
90.11 - * Development and Distribution License("CDDL") (collectively, the
90.12 - * "License"). You may not use this file except in compliance with the
90.13 - * License. You can obtain a copy of the License at
90.14 - * http://www.netbeans.org/cddl-gplv2.html
90.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
90.16 - * specific language governing permissions and limitations under the
90.17 - * License. When distributing the software, include this License Header
90.18 - * Notice in each file and include the License file at
90.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
90.20 - * particular file as subject to the "Classpath" exception as provided
90.21 - * by Sun in the GPL Version 2 section of the License file that
90.22 - * accompanied this code. If applicable, add the following below the
90.23 - * License Header, with the fields enclosed by brackets [] replaced by
90.24 - * your own identifying information:
90.25 - * "Portions Copyrighted [year] [name of copyright owner]"
90.26 - *
90.27 - * Contributor(s):
90.28 - *
90.29 - * The Original Software is NetBeans. The Initial Developer of the Original
90.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
90.31 - * Microsystems, Inc. All Rights Reserved.
90.32 - *
90.33 - * If you wish your version of this file to be governed by only the CDDL
90.34 - * or only the GPL Version 2, indicate your decision by adding
90.35 - * "[Contributor] elects to include this software in this distribution
90.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
90.37 - * single choice of license, a recipient has the option to distribute
90.38 - * your version of this file under either the CDDL, the GPL Version 2 or
90.39 - * to extend the choice of license to its licensees as provided above.
90.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
90.41 - * Version 2 license, then the option applies only if the new code is
90.42 - * made subject to such option by the copyright holder.
90.43 - */
90.44 -package org.netbeans.modules.java.hints.infrastructure;
90.45 -
90.46 -import com.sun.source.util.TreePath;
90.47 -import java.io.File;
90.48 -import java.util.Arrays;
90.49 -import java.util.Collections;
90.50 -import java.util.LinkedList;
90.51 -import java.util.List;
90.52 -import java.util.logging.Level;
90.53 -import java.util.logging.Logger;
90.54 -import javax.swing.text.Document;
90.55 -import org.netbeans.api.java.lexer.JavaTokenId;
90.56 -import org.netbeans.api.java.source.CompilationInfo;
90.57 -import org.netbeans.api.java.source.JavaSource;
90.58 -import org.netbeans.api.java.source.JavaSource.Phase;
90.59 -import org.netbeans.api.java.source.SourceUtilsTestUtil;
90.60 -import org.netbeans.api.java.source.TestUtilities;
90.61 -import org.netbeans.api.lexer.Language;
90.62 -import org.netbeans.junit.NbTestCase;
90.63 -import org.netbeans.modules.java.source.TreeLoader;
90.64 -import org.netbeans.spi.editor.hints.ErrorDescription;
90.65 -import org.netbeans.spi.editor.hints.Fix;
90.66 -import org.openide.LifecycleManager;
90.67 -import org.openide.cookies.EditorCookie;
90.68 -import org.openide.filesystems.FileObject;
90.69 -import org.openide.filesystems.FileUtil;
90.70 -import org.openide.loaders.DataObject;
90.71 -
90.72 -/**
90.73 - * @author Jan Lahoda
90.74 - */
90.75 -public abstract class TreeRuleTestBase extends NbTestCase {
90.76 - protected final Logger LOG;
90.77 -
90.78 - public TreeRuleTestBase(String name) {
90.79 - super(name);
90.80 - LOG = Logger.getLogger("test." + name);
90.81 - }
90.82 -
90.83 - @Override
90.84 - protected Level logLevel() {
90.85 - return Level.INFO;
90.86 - }
90.87 -
90.88 - @Override
90.89 - protected void setUp() throws Exception {
90.90 - super.setUp();
90.91 - SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml"}, new Object[0]);
90.92 - TreeLoader.DISABLE_CONFINEMENT_TEST = true;
90.93 - }
90.94 -
90.95 - private void prepareTest(String fileName, String code) throws Exception {
90.96 - clearWorkDir();
90.97 - File wdFile = getWorkDir();
90.98 - FileUtil.refreshFor(wdFile);
90.99 -
90.100 - FileObject wd = FileUtil.toFileObject(wdFile);
90.101 - assertNotNull(wd);
90.102 - sourceRoot = FileUtil.createFolder(wd, "src");
90.103 - FileObject buildRoot = FileUtil.createFolder(wd, "build");
90.104 - FileObject cache = FileUtil.createFolder(wd, "cache");
90.105 -
90.106 - FileObject data = FileUtil.createData(sourceRoot, fileName);
90.107 - File dataFile = FileUtil.toFile(data);
90.108 -
90.109 - assertNotNull(dataFile);
90.110 -
90.111 - TestUtilities.copyStringToFile(dataFile, code);
90.112 -
90.113 - SourceUtilsTestUtil.prepareTest(sourceRoot, buildRoot, cache, extraClassPath());
90.114 -
90.115 - DataObject od = DataObject.find(data);
90.116 - EditorCookie ec = od.getCookie(EditorCookie.class);
90.117 -
90.118 - assertNotNull(ec);
90.119 -
90.120 - doc = ec.openDocument();
90.121 - doc.putProperty(Language.class, JavaTokenId.language());
90.122 - doc.putProperty("mimeType", "text/x-java");
90.123 -
90.124 - JavaSource js = JavaSource.forFileObject(data);
90.125 -
90.126 - assertNotNull(js);
90.127 -
90.128 - info = SourceUtilsTestUtil.getCompilationInfo(js, Phase.RESOLVED);
90.129 -
90.130 - assertNotNull(info);
90.131 - }
90.132 -
90.133 - private FileObject sourceRoot;
90.134 - private CompilationInfo info;
90.135 - private Document doc;
90.136 -
90.137 - protected abstract List<ErrorDescription> computeErrors(CompilationInfo info, TreePath path);
90.138 -
90.139 - protected List<ErrorDescription> computeErrors(CompilationInfo info, TreePath path, int offset) {
90.140 - return computeErrors(info, path);
90.141 - }
90.142 -
90.143 - protected String toDebugString(CompilationInfo info, Fix f) {
90.144 - return f.toString();
90.145 - }
90.146 -
90.147 - protected void performAnalysisTest(String fileName, String code, String... golden) throws Exception {
90.148 - int[] offset = new int[1];
90.149 -
90.150 - code = org.netbeans.modules.java.hints.TestUtilities.detectOffsets(code, offset);
90.151 -
90.152 - performAnalysisTest(fileName, code, offset[0], golden);
90.153 - }
90.154 -
90.155 - protected void performAnalysisTest(String fileName, String code, int pos, String... golden) throws Exception {
90.156 - prepareTest(fileName, code);
90.157 -
90.158 - TreePath path = info.getTreeUtilities().pathFor(pos);
90.159 -
90.160 - List<ErrorDescription> errors = computeErrors(info, path, pos);
90.161 - List<String> errorsNames = new LinkedList<String>();
90.162 -
90.163 - errors = errors != null ? errors : Collections.<ErrorDescription>emptyList();
90.164 -
90.165 - for (ErrorDescription e : errors) {
90.166 - errorsNames.add(e.toString());
90.167 - }
90.168 -
90.169 - assertTrue("The warnings provided by the hint do not match expected warnings. Provided warnings: " + errorsNames.toString(), Arrays.equals(golden, errorsNames.toArray(new String[0])));
90.170 - }
90.171 -
90.172 - protected String performFixTest(String fileName, String code, String errorDescriptionToString, String fixDebugString, String golden) throws Exception {
90.173 - int[] offset = new int[1];
90.174 -
90.175 - code = org.netbeans.modules.java.hints.TestUtilities.detectOffsets(code, offset);
90.176 -
90.177 - return performFixTest(fileName, code, offset[0], errorDescriptionToString, fixDebugString, golden);
90.178 - }
90.179 -
90.180 - protected String performFixTest(String fileName, String code, int pos, String errorDescriptionToString, String fixDebugString, String golden) throws Exception {
90.181 - return performFixTest(fileName, code, pos, errorDescriptionToString, fixDebugString, fileName, golden);
90.182 - }
90.183 -
90.184 - protected String performFixTest(String fileName, String code, String errorDescriptionToString, String fixDebugString, String goldenFileName, String golden) throws Exception {
90.185 - int[] offset = new int[1];
90.186 -
90.187 - code = org.netbeans.modules.java.hints.TestUtilities.detectOffsets(code, offset);
90.188 -
90.189 - return performFixTest(fileName, code, offset[0], errorDescriptionToString, fixDebugString, goldenFileName, golden);
90.190 - }
90.191 -
90.192 - protected String performFixTest(String fileName, String code, int pos, String errorDescriptionToString, String fixDebugString, String goldenFileName, String golden) throws Exception {
90.193 - prepareTest(fileName, code);
90.194 -
90.195 - TreePath path = info.getTreeUtilities().pathFor(pos);
90.196 -
90.197 - List<ErrorDescription> errors = computeErrors(info, path, pos);
90.198 -
90.199 - ErrorDescription toFix = null;
90.200 -
90.201 - for (ErrorDescription d : errors) {
90.202 - if (errorDescriptionToString.equals(d.toString())) {
90.203 - toFix = d;
90.204 - break;
90.205 - }
90.206 - }
90.207 -
90.208 - assertNotNull("Error: \"" + errorDescriptionToString + "\" not found. All ErrorDescriptions: " + errors.toString(), toFix);
90.209 -
90.210 - assertTrue("Must be computed", toFix.getFixes().isComputed());
90.211 -
90.212 - List<Fix> fixes = toFix.getFixes().getFixes();
90.213 - List<String> fixNames = new LinkedList<String>();
90.214 - Fix toApply = null;
90.215 -
90.216 - for (Fix f : fixes) {
90.217 - if (fixDebugString.equals(toDebugString(info, f))) {
90.218 - toApply = f;
90.219 - }
90.220 -
90.221 - fixNames.add(toDebugString(info, f));
90.222 - }
90.223 -
90.224 - assertNotNull("Cannot find fix to invoke: " + fixNames.toString(), toApply);
90.225 -
90.226 - toApply.implement();
90.227 -
90.228 - FileObject toCheck = sourceRoot.getFileObject(goldenFileName);
90.229 -
90.230 - assertNotNull(toCheck);
90.231 -
90.232 - DataObject toCheckDO = DataObject.find(toCheck);
90.233 - EditorCookie ec = toCheckDO.getLookup().lookup(EditorCookie.class);
90.234 - Document toCheckDocument = ec.openDocument();
90.235 -
90.236 - String realCode = toCheckDocument.getText(0, toCheckDocument.getLength());
90.237 -
90.238 - //ignore whitespaces:
90.239 - realCode = realCode.replaceAll("[ \t\n]+", " ");
90.240 -
90.241 - if (golden != null) {
90.242 - assertEquals("The output code does not match the expected code.", golden, realCode);
90.243 - }
90.244 -
90.245 - LifecycleManager.getDefault().saveAll();
90.246 -
90.247 - return realCode;
90.248 - }
90.249 -
90.250 - protected FileObject[] extraClassPath() {
90.251 - return new FileObject[0];
90.252 - }
90.253 -
90.254 - // common tests to check nothing is reported
90.255 - public void testIssue105979() throws Exception {
90.256 - String before = "package test; class Test {" +
90.257 - " return b;" +
90.258 - "}\n";
90.259 -
90.260 - for (int i = 0; i < before.length(); i++) {
90.261 - LOG.info("testing position " + i + " at " + before.charAt(i));
90.262 - clearWorkDir();
90.263 - performAnalysisTest("test/Test.java", before, i);
90.264 -}
90.265 - }
90.266 - public void testIssue108246() throws Exception {
90.267 -
90.268 - String before = "package test; class Test {" +
90.269 - " Integer ii = new Integer(0);" +
90.270 - " String s = ii.toString();" +
90.271 - "\n}\n";
90.272 -
90.273 - for (int i = 0; i < before.length(); i++) {
90.274 - LOG.info("testing position " + i + " at " + before.charAt(i));
90.275 - clearWorkDir();
90.276 - performAnalysisTest("test/Test.java", before, i);
90.277 - }
90.278 - }
90.279 -
90.280 - public void testNoHintsForSimpleInitialize() throws Exception {
90.281 -
90.282 - String before = "package test; class Test {" +
90.283 - " { java.lang.System.out.println(); } " +
90.284 - "}\n";
90.285 -
90.286 - for (int i = 0; i < before.length(); i++) {
90.287 - LOG.info("testing position " + i + " at " + before.charAt(i));
90.288 - clearWorkDir();
90.289 - performAnalysisTest("test/Test.java", before, i);
90.290 - }
90.291 - }
90.292 -
90.293 - public void testIssue113933() throws Exception {
90.294 -
90.295 - String before = "package test; class Test {" +
90.296 - " public void test() {" +
90.297 - " super.A();" +
90.298 - "\n}\n}\n";
90.299 -
90.300 - for (int i = 0; i < before.length(); i++) {
90.301 - LOG.info("testing position " + i + " at " + before.charAt(i));
90.302 - clearWorkDir();
90.303 - performAnalysisTest("test/Test.java", before, i);
90.304 - }
90.305 - }
90.306 -}
91.1 --- a/borrowedtests/src/org/netbeans/modules/java/hints/jackpot/code/spi/TestBase.java Fri Jan 27 13:35:56 2012 +0100
91.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
91.3 @@ -1,341 +0,0 @@
91.4 -/*
91.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
91.6 - *
91.7 - * Copyright 2009-2010 Oracle and/or its affiliates. All rights reserved.
91.8 - *
91.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
91.10 - * Other names may be trademarks of their respective owners.
91.11 - *
91.12 - * The contents of this file are subject to the terms of either the GNU
91.13 - * General Public License Version 2 only ("GPL") or the Common
91.14 - * Development and Distribution License("CDDL") (collectively, the
91.15 - * "License"). You may not use this file except in compliance with the
91.16 - * License. You can obtain a copy of the License at
91.17 - * http://www.netbeans.org/cddl-gplv2.html
91.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
91.19 - * specific language governing permissions and limitations under the
91.20 - * License. When distributing the software, include this License Header
91.21 - * Notice in each file and include the License file at
91.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
91.23 - * particular file as subject to the "Classpath" exception as provided
91.24 - * by Oracle in the GPL Version 2 section of the License file that
91.25 - * accompanied this code. If applicable, add the following below the
91.26 - * License Header, with the fields enclosed by brackets [] replaced by
91.27 - * your own identifying information:
91.28 - * "Portions Copyrighted [year] [name of copyright owner]"
91.29 - *
91.30 - * If you wish your version of this file to be governed by only the CDDL
91.31 - * or only the GPL Version 2, indicate your decision by adding
91.32 - * "[Contributor] elects to include this software in this distribution
91.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
91.34 - * single choice of license, a recipient has the option to distribute
91.35 - * your version of this file under either the CDDL, the GPL Version 2 or
91.36 - * to extend the choice of license to its licensees as provided above.
91.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
91.38 - * Version 2 license, then the option applies only if the new code is
91.39 - * made subject to such option by the copyright holder.
91.40 - *
91.41 - * Contributor(s):
91.42 - *
91.43 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
91.44 - */
91.45 -
91.46 -package org.netbeans.modules.java.hints.jackpot.code.spi;
91.47 -
91.48 -import java.io.File;
91.49 -import java.lang.reflect.Method;
91.50 -import java.util.ArrayList;
91.51 -import java.util.Arrays;
91.52 -import java.util.Collection;
91.53 -import java.util.Collections;
91.54 -import java.util.Comparator;
91.55 -import java.util.HashMap;
91.56 -import java.util.HashSet;
91.57 -import java.util.LinkedList;
91.58 -import java.util.List;
91.59 -import java.util.Map;
91.60 -import java.util.Map.Entry;
91.61 -import java.util.Set;
91.62 -import java.util.concurrent.atomic.AtomicBoolean;
91.63 -import java.util.logging.Level;
91.64 -import java.util.logging.Logger;
91.65 -import javax.swing.text.Document;
91.66 -import org.netbeans.api.java.lexer.JavaTokenId;
91.67 -import org.netbeans.api.java.source.CompilationInfo;
91.68 -import org.netbeans.api.java.source.JavaSource;
91.69 -import org.netbeans.api.java.source.JavaSource.Phase;
91.70 -import org.netbeans.api.java.source.SourceUtilsTestUtil;
91.71 -import org.netbeans.api.java.source.TestUtilities;
91.72 -import org.netbeans.api.java.source.support.CaretAwareJavaSourceTaskFactory;
91.73 -import org.netbeans.api.lexer.Language;
91.74 -import org.netbeans.junit.NbTestCase;
91.75 -import org.netbeans.modules.java.hints.jackpot.code.CodeHintProviderImpl;
91.76 -import org.netbeans.modules.java.hints.jackpot.code.FSWrapper;
91.77 -import org.netbeans.modules.java.hints.jackpot.code.FSWrapper.ClassWrapper;
91.78 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
91.79 -import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata;
91.80 -import org.netbeans.modules.java.hints.jackpot.spi.HintsRunner;
91.81 -import org.netbeans.modules.java.source.TreeLoader;
91.82 -import org.netbeans.spi.editor.hints.ErrorDescription;
91.83 -import org.netbeans.spi.editor.hints.Fix;
91.84 -import org.openide.LifecycleManager;
91.85 -import org.openide.cookies.EditorCookie;
91.86 -import org.openide.filesystems.FileObject;
91.87 -import org.openide.filesystems.FileUtil;
91.88 -import org.openide.loaders.DataObject;
91.89 -import org.openide.util.NbBundle;
91.90 -
91.91 -/**
91.92 - *
91.93 - * @author lahvac
91.94 - */
91.95 -public abstract class TestBase extends NbTestCase {
91.96 - private final Class<?> hintClass;
91.97 - protected final Logger LOG;
91.98 -
91.99 - public TestBase(String name, Class<?> hintClass) {
91.100 - super(name);
91.101 - this.hintClass = hintClass;
91.102 - LOG = Logger.getLogger("test." + name);
91.103 - }
91.104 -
91.105 - @Override
91.106 - protected Level logLevel() {
91.107 - return Level.INFO;
91.108 - }
91.109 -
91.110 - @Override
91.111 - protected void setUp() throws Exception {
91.112 - super.setUp();
91.113 - SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml", "META-INF/generated-layer.xml"}, new Object[0]);
91.114 - TreeLoader.DISABLE_CONFINEMENT_TEST = true;
91.115 - }
91.116 -
91.117 - private String sourceLevel = "1.5";
91.118 -
91.119 - protected void setSourceLevel(String sourceLevel) {
91.120 - this.sourceLevel = sourceLevel;
91.121 - }
91.122 -
91.123 - protected void prepareTest(String fileName, String code) throws Exception {
91.124 - clearWorkDir();
91.125 - File wdFile = getWorkDir();
91.126 - FileUtil.refreshFor(wdFile);
91.127 -
91.128 - FileObject wd = FileUtil.toFileObject(wdFile);
91.129 - assertNotNull(wd);
91.130 - sourceRoot = FileUtil.createFolder(wd, "src");
91.131 - FileObject buildRoot = FileUtil.createFolder(wd, "build");
91.132 - FileObject cache = FileUtil.createFolder(wd, "cache");
91.133 -
91.134 - FileObject data = FileUtil.createData(sourceRoot, fileName);
91.135 - File dataFile = FileUtil.toFile(data);
91.136 -
91.137 - assertNotNull(dataFile);
91.138 -
91.139 - TestUtilities.copyStringToFile(dataFile, code);
91.140 -
91.141 - SourceUtilsTestUtil.prepareTest(sourceRoot, buildRoot, cache, extraClassPath());
91.142 -
91.143 - SourceUtilsTestUtil.setSourceLevel(data, sourceLevel);
91.144 -
91.145 - DataObject od = DataObject.find(data);
91.146 - EditorCookie ec = od.getCookie(EditorCookie.class);
91.147 -
91.148 - assertNotNull(ec);
91.149 -
91.150 - doc = ec.openDocument();
91.151 - doc.putProperty(Language.class, JavaTokenId.language());
91.152 - doc.putProperty("mimeType", "text/x-java");
91.153 -
91.154 - JavaSource js = JavaSource.forFileObject(data);
91.155 -
91.156 - assertNotNull(js);
91.157 -
91.158 - info = SourceUtilsTestUtil.getCompilationInfo(js, Phase.RESOLVED);
91.159 -
91.160 - assertNotNull(info);
91.161 - }
91.162 -
91.163 - private FileObject sourceRoot;
91.164 - private CompilationInfo info;
91.165 - private Document doc;
91.166 -
91.167 - protected final void setTestFileCaretLocation(int pos) throws Exception {
91.168 - Method m = CaretAwareJavaSourceTaskFactory.class.getDeclaredMethod("setLastPosition", FileObject.class, int.class);
91.169 -
91.170 - m.setAccessible(true);
91.171 - m.invoke(null, info.getFileObject(), pos);
91.172 - }
91.173 -
91.174 - private List<ErrorDescription> computeErrors(CompilationInfo info) {
91.175 - Map<HintMetadata, Collection<HintDescription>> hints = new HashMap<HintMetadata, Collection<HintDescription>>();
91.176 -
91.177 - ClassWrapper found = null;
91.178 -
91.179 - for (ClassWrapper w : FSWrapper.listClasses()) {
91.180 - if (w.getName().equals(hintClass.getName())) {
91.181 - found = w;
91.182 - break;
91.183 - }
91.184 - }
91.185 -
91.186 - assertNotNull(found);
91.187 -
91.188 - CodeHintProviderImpl.processClass(found, hints);
91.189 -
91.190 - List<HintDescription> total = new LinkedList<HintDescription>();
91.191 -
91.192 - for (Collection<? extends HintDescription> l : hints.values()) {
91.193 - total.addAll(l);
91.194 - }
91.195 -
91.196 - List<ErrorDescription> result = new ArrayList<ErrorDescription>();
91.197 -
91.198 - for (Entry<HintDescription, List<ErrorDescription>> e : HintsRunner.computeErrors(info, total, new AtomicBoolean()).entrySet()) {
91.199 - result.addAll(e.getValue());
91.200 - }
91.201 -
91.202 - return result;
91.203 - }
91.204 -
91.205 - protected String toDebugString(CompilationInfo info, Fix f) {
91.206 - return "FixImpl";
91.207 - }
91.208 -
91.209 - protected void performAnalysisTest(String fileName, String code, String... golden) throws Exception {
91.210 - prepareTest(fileName, code);
91.211 -
91.212 - List<ErrorDescription> errors = computeErrors(info);
91.213 - Collections.sort (errors, ERRORS_COMPARATOR);
91.214 - List<String> errorsNames = new LinkedList<String>();
91.215 -
91.216 - errors = errors != null ? errors : Collections.<ErrorDescription>emptyList();
91.217 -
91.218 - for (ErrorDescription e : errors) {
91.219 - errorsNames.add(e.toString());
91.220 - }
91.221 -
91.222 - assertTrue("The warnings provided by the hint do not match expected warnings. Provided warnings: " + errorsNames.toString(), Arrays.equals(golden, errorsNames.toArray(new String[0])));
91.223 - }
91.224 -
91.225 - protected void performAnalysisContainsTest(String fileName, String code, String... golden) throws Exception {
91.226 - prepareTest(fileName, code);
91.227 -
91.228 - Set<String> goldenSet = new HashSet<String>();
91.229 - for (String s : golden) {
91.230 - goldenSet.add(s);
91.231 - }
91.232 -
91.233 - List<ErrorDescription> errors = computeErrors(info);
91.234 - Collections.sort (errors, ERRORS_COMPARATOR);
91.235 - List<String> errorsNames = new LinkedList<String>();
91.236 -
91.237 - errors = errors != null ? errors : Collections.<ErrorDescription>emptyList();
91.238 -
91.239 - for (ErrorDescription d : errors) {
91.240 - goldenSet.remove(d.toString());
91.241 - errorsNames.add(d.toString());
91.242 - }
91.243 - assertTrue("The warnings provided by the hint do not contain expected warnings. Provided warnings: " + errorsNames.toString(), goldenSet.isEmpty());
91.244 - }
91.245 -
91.246 - protected void performAnalysisExcludesTest(String fileName, String code, String... golden) throws Exception {
91.247 - prepareTest(fileName, code);
91.248 -
91.249 - Set<String> goldenSet = new HashSet<String>();
91.250 - for (String s : golden) {
91.251 - goldenSet.add(s);
91.252 - }
91.253 -
91.254 - List<ErrorDescription> errors = computeErrors(info);
91.255 - Collections.sort (errors, ERRORS_COMPARATOR);
91.256 - List<String> errorsNames = new LinkedList<String>();
91.257 -
91.258 - errors = errors != null ? errors : Collections.<ErrorDescription>emptyList();
91.259 -
91.260 - boolean fail = false;
91.261 - for (ErrorDescription d : errors) {
91.262 - if (goldenSet.remove(d.getDescription()))
91.263 - fail = true;
91.264 - errorsNames.add(d.toString());
91.265 - }
91.266 - assertFalse("The warnings provided by the hint do not exclude expected warnings. Provided warnings: " + errorsNames.toString(), fail);
91.267 - }
91.268 -
91.269 - protected String performFixTest(String fileName, String code, String errorDescriptionToString, String fixDebugString, String golden) throws Exception {
91.270 - return performFixTest(fileName, code, errorDescriptionToString, fixDebugString, fileName, golden);
91.271 - }
91.272 -
91.273 - protected String performFixTest(String fileName, String code, String errorDescriptionToString, String fixDebugString, String goldenFileName, String golden) throws Exception {
91.274 - prepareTest(fileName, code);
91.275 -
91.276 - List<ErrorDescription> errors = computeErrors(info);
91.277 - Collections.sort (errors, ERRORS_COMPARATOR);
91.278 -
91.279 - ErrorDescription toFix = null;
91.280 -
91.281 - for (ErrorDescription d : errors) {
91.282 - if (errorDescriptionToString.equals(d.toString())) {
91.283 - toFix = d;
91.284 - break;
91.285 - }
91.286 - }
91.287 -
91.288 - assertNotNull("Error: \"" + errorDescriptionToString + "\" not found. All ErrorDescriptions: " + errors.toString(), toFix);
91.289 -
91.290 - assertTrue("Must be computed", toFix.getFixes().isComputed());
91.291 -
91.292 - List<Fix> fixes = toFix.getFixes().getFixes();
91.293 - List<String> fixNames = new LinkedList<String>();
91.294 - Fix toApply = null;
91.295 -
91.296 - for (Fix f : fixes) {
91.297 - if (fixDebugString.equals(toDebugString(info, f))) {
91.298 - toApply = f;
91.299 - }
91.300 -
91.301 - fixNames.add(toDebugString(info, f));
91.302 - }
91.303 -
91.304 - assertNotNull("Cannot find fix to invoke: " + fixNames.toString(), toApply);
91.305 -
91.306 - toApply.implement();
91.307 -
91.308 - FileObject toCheck = sourceRoot.getFileObject(goldenFileName);
91.309 -
91.310 - assertNotNull(toCheck);
91.311 -
91.312 - DataObject toCheckDO = DataObject.find(toCheck);
91.313 - EditorCookie ec = toCheckDO.getLookup().lookup(EditorCookie.class);
91.314 - Document toCheckDocument = ec.openDocument();
91.315 -
91.316 - String realCode = toCheckDocument.getText(0, toCheckDocument.getLength());
91.317 -
91.318 - //ignore whitespaces:
91.319 - realCode = realCode.replaceAll("[ \t\n]+", " ");
91.320 -
91.321 - if (golden != null) {
91.322 - assertEquals("The output code does not match the expected code.", golden, realCode);
91.323 - }
91.324 -
91.325 - LifecycleManager.getDefault().saveAll();
91.326 -
91.327 - return realCode;
91.328 - }
91.329 -
91.330 - protected FileObject[] extraClassPath() {
91.331 - return new FileObject[0];
91.332 - }
91.333 -
91.334 - static {
91.335 - NbBundle.setBranding("test");
91.336 - }
91.337 -
91.338 - private static final Comparator<ErrorDescription> ERRORS_COMPARATOR = new Comparator<ErrorDescription> () {
91.339 -
91.340 - public int compare (ErrorDescription e1, ErrorDescription e2) {
91.341 - return e1.getRange ().getBegin ().getOffset () - e2.getRange ().getBegin ().getOffset ();
91.342 - }
91.343 - };
91.344 -}
92.1 --- a/borrowedtests/src/org/netbeans/modules/java/hints/jackpot/impl/pm/BulkSearchTestPerformer.java Fri Jan 27 13:35:56 2012 +0100
92.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
92.3 @@ -1,664 +0,0 @@
92.4 -/*
92.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
92.6 - *
92.7 - * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
92.8 - *
92.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
92.10 - * Other names may be trademarks of their respective owners.
92.11 - *
92.12 - * The contents of this file are subject to the terms of either the GNU
92.13 - * General Public License Version 2 only ("GPL") or the Common
92.14 - * Development and Distribution License("CDDL") (collectively, the
92.15 - * "License"). You may not use this file except in compliance with the
92.16 - * License. You can obtain a copy of the License at
92.17 - * http://www.netbeans.org/cddl-gplv2.html
92.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
92.19 - * specific language governing permissions and limitations under the
92.20 - * License. When distributing the software, include this License Header
92.21 - * Notice in each file and include the License file at
92.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
92.23 - * particular file as subject to the "Classpath" exception as provided
92.24 - * by Oracle in the GPL Version 2 section of the License file that
92.25 - * accompanied this code. If applicable, add the following below the
92.26 - * License Header, with the fields enclosed by brackets [] replaced by
92.27 - * your own identifying information:
92.28 - * "Portions Copyrighted [year] [name of copyright owner]"
92.29 - *
92.30 - * If you wish your version of this file to be governed by only the CDDL
92.31 - * or only the GPL Version 2, indicate your decision by adding
92.32 - * "[Contributor] elects to include this software in this distribution
92.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
92.34 - * single choice of license, a recipient has the option to distribute
92.35 - * your version of this file under either the CDDL, the GPL Version 2 or
92.36 - * to extend the choice of license to its licensees as provided above.
92.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
92.38 - * Version 2 license, then the option applies only if the new code is
92.39 - * made subject to such option by the copyright holder.
92.40 - *
92.41 - * Contributor(s):
92.42 - *
92.43 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
92.44 - */
92.45 -
92.46 -package org.netbeans.modules.java.hints.jackpot.impl.pm;
92.47 -
92.48 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch.BulkPattern;
92.49 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch.EncodingContext;
92.50 -import com.sun.source.util.TreePath;
92.51 -import java.io.ByteArrayInputStream;
92.52 -import java.io.ByteArrayOutputStream;
92.53 -import java.io.File;
92.54 -import java.util.Arrays;
92.55 -import java.util.Collection;
92.56 -import java.util.Collections;
92.57 -import java.util.HashMap;
92.58 -import java.util.HashSet;
92.59 -import java.util.LinkedList;
92.60 -import java.util.List;
92.61 -import java.util.Map;
92.62 -import java.util.Map.Entry;
92.63 -import java.util.Set;
92.64 -import java.util.regex.Pattern;
92.65 -import javax.swing.text.Document;
92.66 -import org.netbeans.api.java.lexer.JavaTokenId;
92.67 -import org.netbeans.api.java.source.CompilationInfo;
92.68 -import org.netbeans.api.java.source.JavaSource;
92.69 -import org.netbeans.api.java.source.JavaSource.Phase;
92.70 -import org.netbeans.api.java.source.SourceUtilsTestUtil;
92.71 -import org.netbeans.api.java.source.TestUtilities;
92.72 -import org.netbeans.api.java.source.TreePathHandle;
92.73 -import org.netbeans.api.lexer.Language;
92.74 -import org.netbeans.junit.NbTestCase;
92.75 -import org.netbeans.modules.java.source.TreeLoader;
92.76 -import org.openide.cookies.EditorCookie;
92.77 -import org.openide.filesystems.FileObject;
92.78 -import org.openide.filesystems.FileUtil;
92.79 -import org.openide.loaders.DataObject;
92.80 -import static org.junit.Assert.*;
92.81 -
92.82 -/**
92.83 - *
92.84 - * @author lahvac
92.85 - */
92.86 -public abstract class BulkSearchTestPerformer extends NbTestCase {
92.87 -
92.88 - public BulkSearchTestPerformer(String name) {
92.89 - super(name);
92.90 - }
92.91 -
92.92 - @Override
92.93 - protected void setUp() throws Exception {
92.94 - super.setUp();
92.95 - SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml"}, new Object[0]);
92.96 - TreeLoader.DISABLE_CONFINEMENT_TEST = true;
92.97 - }
92.98 -
92.99 -// public static TestSuite suite() {
92.100 -// NbTestSuite s = new NbTestSuite();
92.101 -//
92.102 -// s.addTestSuite(NFABasedBulkSearchTest.class);
92.103 -//
92.104 -// return s;
92.105 -// }
92.106 -
92.107 - public void testSimple1() throws Exception {
92.108 - performTest("package test; public class Test { private void test() { System.err./**/println(\"\");}}",
92.109 - Collections.singletonMap("System.err.println(\"\")", Arrays.asList("System.err./**/println(\"\")")),
92.110 - Arrays.asList("System.err.println(\"\" + \"\")"));
92.111 - }
92.112 -
92.113 - public void testDontCare() throws Exception {
92.114 - performTest("package test; public class Test { private void test() { System.err./**/println(\"\" + \"\");}}",
92.115 - Collections.singletonMap("System.err.println($1)", Arrays.asList("System.err./**/println(\"\" + \"\")")),
92.116 - Collections.<String>emptyList());
92.117 - }
92.118 -
92.119 - public void testMemberSelectAndIdentifier() throws Exception {
92.120 - performTest("package test; public class Test { private static void test() { test();}}",
92.121 - Collections.singletonMap("test.Test.test()", Arrays.asList("test()")),
92.122 - Collections.<String>emptyList());
92.123 - }
92.124 -
92.125 - public void testUnpureMemberSelect() throws Exception {
92.126 - performTest("package test; public class Test { private static void test() { new StringBuilder().append(\"\");}}",
92.127 - Collections.<String, List<String>>emptyMap(),
92.128 - Arrays.asList("test.append(\"\")"));
92.129 - }
92.130 -
92.131 - public void testMemberSelectWithVariables1() throws Exception {
92.132 - performTest("package test; public class Test { private static void test() { new StringBuilder().append(\"\");}}",
92.133 - Collections.singletonMap("$0.append(\"\")", Arrays.asList("new StringBuilder().append(\"\")")),
92.134 - Collections.<String>emptyList());
92.135 - }
92.136 -
92.137 - public void testMemberSelectWithVariables2() throws Exception {
92.138 - performTest("package test; public class Test { private void append(char c) { append(\"\");}}",
92.139 - Collections.singletonMap("$0.append(\"\")", Arrays.asList("append(\"\")")),
92.140 - Collections.<String>emptyList());
92.141 - }
92.142 -
92.143 - public void testLocalVariables() throws Exception {
92.144 - performTest("package test; public class Test { private void test() { { int y; y = 1; } }}",
92.145 - Collections.singletonMap("{ int $1; $1 = 1; }", Arrays.asList("{ int y; y = 1; }")),
92.146 - Collections.<String>emptyList());
92.147 - }
92.148 -
92.149 - public void testAssert() throws Exception {
92.150 - performTest("package test; public class Test { private void test() { assert true : \"\"; }}",
92.151 - Collections.singletonMap("assert $1 : $2;", Arrays.asList("assert true : \"\";")),
92.152 - Collections.<String>emptyList());
92.153 - }
92.154 -
92.155 - public void testStatementAndSingleBlockStatementAreSame1() throws Exception {
92.156 - performTest("package test; public class Test { private void test() { { int y; { y = 1; } } }}",
92.157 - Collections.singletonMap("{ int $1; $1 = 1; }", Arrays.asList("{ int y; { y = 1; } }")),
92.158 - Collections.<String>emptyList());
92.159 - }
92.160 -
92.161 - public void testStatementAndSingleBlockStatementAreSame2() throws Exception {
92.162 - performTest("package test; public class Test { private void test() { { int y; y = 1; } }}",
92.163 - Collections.singletonMap("{ int $1; { $1 = 1; } }", Arrays.asList("{ int y; y = 1; }")),
92.164 - Collections.<String>emptyList());
92.165 - }
92.166 -
92.167 - public void testStatementVariables1() throws Exception {
92.168 - performTest("package test; public class Test { public int test1() { if (true) return 1; else return 2; } }",
92.169 - Collections.singletonMap("if ($1) $2; else $3;", Arrays.asList("if (true) return 1; else return 2;")),
92.170 - Collections.<String>emptyList());
92.171 - }
92.172 -
92.173 - public void testMultiStatementVariables1() throws Exception {
92.174 - performTest("package test; public class Test { public int test1(int i) { System.err.println(i); System.err.println(i); i = 3; System.err.println(i); System.err.println(i); return i; } }",
92.175 - Collections.singletonMap("{ $s1$; i = 3; $s2$; return i; }", Arrays.asList("{ System.err.println(i); System.err.println(i); i = 3; System.err.println(i); System.err.println(i); return i; }")),
92.176 - Collections.<String>emptyList());
92.177 - }
92.178 -
92.179 - public void testMultiStatementVariables2() throws Exception {
92.180 - performTest("package test; public class Test { public int test1(int i) { i = 3; return i; } }",
92.181 - Collections.singletonMap("{ $s1$; i = 3; $s2$; return i; }", Arrays.asList("{ i = 3; return i; }")),
92.182 - Collections.<String>emptyList());
92.183 - }
92.184 -
92.185 - public void testMultiStatementVariablesAndBlocks1() throws Exception {
92.186 - performTest("package test; public class Test { public void test1() { if (true) System.err.println(); } }",
92.187 - Collections.singletonMap("if ($c) {$s1$; System.err.println(); $s2$; }", Arrays.asList("if (true) System.err.println();")),
92.188 - Collections.<String>emptyList());
92.189 - }
92.190 -
92.191 - public void testMultiStatementVariablesAndBlocks2() throws Exception {
92.192 - performTest("package test; public class Test { public void test1() { if (true) System.err.println(); } }",
92.193 - Collections.singletonMap("if ($c) {$s1$; System.err.println(); }", Arrays.asList("if (true) System.err.println();")),
92.194 - Collections.<String>emptyList());
92.195 - }
92.196 -
92.197 - public void testMultiStatementVariablesAndBlocks3() throws Exception {
92.198 - performTest("package test; public class Test { public void test1() { if (true) System.err.println(); } }",
92.199 - Collections.singletonMap("if ($c) {System.err.println(); $s2$; }", Arrays.asList("if (true) System.err.println();")),
92.200 - Collections.<String>emptyList());
92.201 - }
92.202 -
92.203 - public void testMultiStatementVariablesAndBlocks4() throws Exception {
92.204 - performTest("package test; public class Test { public void test1() { if (true) System.err.println(); } }",
92.205 - Collections.singletonMap("{ $s1$; System.err.println(); $s2$; }", Arrays.asList("System.err.println();")),
92.206 - Collections.<String>emptyList());
92.207 - }
92.208 -
92.209 - public void testTwoPatterns() throws Exception {
92.210 - Map<String, List<String>> contained = new HashMap<String, List<String>>();
92.211 -
92.212 - contained.put("if ($a) $ret = $b; else $ret = $c;", Arrays.asList("if (b) q = 2; else q = 3;"));
92.213 - contained.put("{ $p$; $T $v; if($a) $v = $b; else $v = $c; $q$; }", Arrays.asList("{ int q; if (b) q = 2; else q = 3; }"));
92.214 -
92.215 - performTest("package test; public class Test { public void test1(boolean b) { int q; if (b) q = 2; else q = 3; } }",
92.216 - contained,
92.217 - Collections.<String>emptyList());
92.218 - }
92.219 -
92.220 - public void testEffectiveNewClass() throws Exception {
92.221 - performTest("package test; import javax.swing.ImageIcon; public class Test { public void test1(java.awt.Image i) { new ImageIcon(i); new String(i); } }",
92.222 - Collections.singletonMap("new javax.swing.ImageIcon($1)", Arrays.asList("new ImageIcon(i)")),
92.223 - Collections.<String>emptyList());
92.224 - }
92.225 -
92.226 - public void testSynchronizedAndMultiStatementVariables() throws Exception {
92.227 - performTest("package test; public class Test {public void test() { Object o = null; int i = 0; synchronized (o) {} } }",
92.228 - Collections.singletonMap("synchronized($var) {$stmts$;}", Arrays.asList("synchronized (o) {}")),
92.229 - Collections.<String>emptyList());
92.230 - }
92.231 -
92.232 - public void testJackpot30_2() throws Exception {
92.233 - String code = "package test;\n" +
92.234 - "public class Test {\n" +
92.235 - " private void m() {\n" +
92.236 - " a(c.i().getFileObject());\n" +
92.237 - " if (span != null && span[0] != (-1) && span[1] != (-1));\n" +
92.238 - " }\n" +
92.239 - "}\n";
92.240 -
92.241 - performTest(code,
92.242 - Collections.<String, List<String>>emptyMap(),
92.243 - Arrays.asList("$0.getFileObject($1)"));
92.244 - }
92.245 -
92.246 - public void testIdentifierInPureMemberSelect() throws Exception {
92.247 - String code = "package test;\n" +
92.248 - "public class Test {\n" +
92.249 - " public Test test;\n" +
92.250 - " public String name;\n" +
92.251 - " private void test() {\n" +
92.252 - " Test t = null;\n" +
92.253 - " String s = t.test.name;\n" +
92.254 - " }\n" +
92.255 - "}\n";
92.256 -
92.257 - performTest(code,
92.258 - Collections.singletonMap("$Test.test", Arrays.asList("test", "t.test")),
92.259 - Collections.<String>emptyList());
92.260 - }
92.261 -
92.262 - public void testNoExponentialTimeComplexity() throws Exception {
92.263 - try {
92.264 - String code = "package test;\n" +
92.265 - "public class Test {\n" +
92.266 - " private void test() {\n" +
92.267 - " Object o;\n" +
92.268 - " if(o == null) {\n" +
92.269 - " f(\"\");\n" +
92.270 - " }|\n" +
92.271 - " }\n" +
92.272 - "}";
92.273 - String pattern = "{ $p$; $T $v; if($a) $v = $b; else $v = $c; }";
92.274 -
92.275 - measure(code, "\na(\"\");", 5, pattern); //to load needed classes, etc.
92.276 -
92.277 - int rep = 1;
92.278 - long baseline;
92.279 -
92.280 - while (true) {
92.281 - baseline = measure(code, "\na(\"\");", rep, pattern);
92.282 -
92.283 - if (baseline >= 2000) {
92.284 - break;
92.285 - }
92.286 -
92.287 - rep *= 2;
92.288 - }
92.289 -
92.290 - long doubleSize = measure(code, "\na(\"\");", 2 * rep, pattern);
92.291 -
92.292 - assertTrue("baseline=" + baseline + ", actual=" + String.valueOf(doubleSize), doubleSize <= 4 * baseline);
92.293 - } catch (OutOfMemoryError oome) {
92.294 - //OK
92.295 - }
92.296 - }
92.297 -
92.298 - public void testMultiParameter1() throws Exception {
92.299 - performTest("package test; public class Test { { java.util.Arrays.asList(\"a\", \"b\", \"c\"); } }",
92.300 - Collections.singletonMap("java.util.Arrays.asList($params$)", Arrays.asList("java.util.Arrays.asList(\"a\", \"b\", \"c\")")),
92.301 - Collections.<String>emptyList());
92.302 - }
92.303 -
92.304 - public void testMultiParameter2() throws Exception {
92.305 - performTest("package test; public class Test { { java.util.Arrays.asList(); } }",
92.306 - Collections.singletonMap("java.util.Arrays.asList($params$)", Arrays.asList("java.util.Arrays.asList()")),
92.307 - Collections.<String>emptyList());
92.308 - }
92.309 -
92.310 - public void testTypeParameter() throws Exception {
92.311 - performTest("package test; public class Test { { java.util.Arrays.<String>asList(); } }",
92.312 - Collections.singletonMap("java.util.Arrays.<$1>asList($params$)", Arrays.asList("java.util.Arrays.<String>asList()")),
92.313 - Collections.<String>emptyList());
92.314 - }
92.315 -
92.316 - public void testField1() throws Exception {
92.317 - String code = "package test;\n" +
92.318 - "public class Test {\n" +
92.319 - " String name = null;\n" +
92.320 - "}\n";
92.321 -
92.322 - performTest(code,
92.323 - Collections.singletonMap("$modifiers$ java.lang.String $name = $initializer;", Arrays.asList("String name = null;")),
92.324 - Collections.<String>emptyList());
92.325 - }
92.326 -
92.327 - public void testField2() throws Exception {
92.328 - String code = "package test;\n" +
92.329 - "public class Test {\n" +
92.330 - " private String name = null;\n" +
92.331 - "}\n";
92.332 -
92.333 - performTest(code,
92.334 - Collections.singletonMap("$modifiers$ java.lang.String $name = $initializer;", Arrays.asList("private String name = null;")),
92.335 - Collections.<String>emptyList());
92.336 - }
92.337 -
92.338 - public void testMemberSelectWithVariable() throws Exception {
92.339 - String code = "package test;\n" +
92.340 - "import java.util.Arrays;\n" +
92.341 - "public class Test {" +
92.342 - " {\n" +
92.343 - " foo.bar(0, 3, 4);\n" +
92.344 - " }\n" +
92.345 - "}\n";
92.346 -
92.347 - performTest(code,
92.348 - Collections.singletonMap("$foo.$bar($p1, $p2$)", Arrays.asList("foo.bar(0, 3, 4)")),
92.349 - Collections.<String>emptyList());
92.350 - }
92.351 -
92.352 - public void testCheckIdentifiers1() throws Exception {
92.353 - String code = "package test;\n" +
92.354 - "import static java.util.Arrays.*;\n" +
92.355 - "public class Test {" +
92.356 - " {\n" +
92.357 - " toString(new int[] {0, 3, 4});\n" +
92.358 - " }\n" +
92.359 - "}\n";
92.360 -
92.361 - performTest(code,
92.362 - Collections.singletonMap("java.util.Arrays.toString($x)", Arrays.asList("toString(new int[] {0, 3, 4})")),
92.363 - Collections.<String>emptyList());
92.364 - }
92.365 -
92.366 - public void testCheckIdentifiers2() throws Exception {
92.367 - String code = "package test;\n" +
92.368 - "public class Test {" +
92.369 - " {\n" +
92.370 - " toString(new int[] {0, 3, 4});\n" +
92.371 - " }\n" +
92.372 - "}\n";
92.373 -
92.374 - performTest(code,
92.375 - Collections.<String, List<String>>emptyMap(),
92.376 - Collections.singletonList("java.util.Arrays.toString($x)"));
92.377 - }
92.378 -
92.379 - public void testCheckIdentifiers3() throws Exception {
92.380 - String code = "package test;\n" +
92.381 - "import static java.util.Arrays.*;\n" +
92.382 - "public class Test {" +
92.383 - " {\n" +
92.384 - " Foo.toString(new int[] {0, 3, 4});\n" +
92.385 - " }\n" +
92.386 - "}\n";
92.387 -
92.388 - performTest(code,
92.389 - Collections.<String, List<String>>emptyMap(),
92.390 - Collections.singletonList("java.util.Arrays.toString($x)"));
92.391 - }
92.392 -
92.393 - public void testCheckIdentifiers4() throws Exception {
92.394 - String code = "package test;\n" +
92.395 - "public class Test {" +
92.396 - " {\n" +
92.397 - " java.util.Arrays.toString(new int[] {0, 3, 4});\n" +
92.398 - " }\n" +
92.399 - "}\n";
92.400 -
92.401 - performTest(code,
92.402 - Collections.singletonMap("Arrays", Arrays.asList("java.util.Arrays")), //could be imported in the input pattern
92.403 - Collections.<String>emptyList());
92.404 - }
92.405 -
92.406 - public void testLambdaInput() throws Exception {
92.407 - String code = "package test; public class Test {public void test() { new java.io.FilenameFilter() { public boolean accept(java.io.File dir, String name) { return true; } }; } }";
92.408 -
92.409 - performTest(code,
92.410 - Collections.singletonMap("new $type() {public $retType $name($params$) { $body$; } }", Arrays.asList("new java.io.FilenameFilter() { public boolean accept(java.io.File dir, String name) { return true; } }")),
92.411 -
92.412 - Collections.<String>emptyList());
92.413 - }
92.414 -
92.415 - public void testDoubleCheckedLockingWithVariable() throws Exception {
92.416 - String dcl = "if (o == null) {\n" +
92.417 - " Object o1 = new Object();\n" +
92.418 - " synchronized (Test.class) {\n" +
92.419 - " if (o == null) {\n" +
92.420 - " o = o1;\n" +
92.421 - " }\n" +
92.422 - " }\n" +
92.423 - " }";
92.424 - String code = "package test;\n" +
92.425 - "public class Test {\n" +
92.426 - " private Object o;\n" +
92.427 - " private void t() {\n" +
92.428 - " " + dcl + "\n" +
92.429 - " }\n" +
92.430 - "}\n";
92.431 -
92.432 - performTest(code,
92.433 - Collections.singletonMap("if ($var == null) {$pref$; synchronized ($lock) { if ($var == null) { $init$; } } }", Arrays.asList(dcl)),
92.434 - Collections.<String>emptyList());
92.435 - }
92.436 -
92.437 - public void testMethodName1() throws Exception {
92.438 - String code = "package test; public class Test {public void test() { clone(); } }";
92.439 -
92.440 - performTest(code,
92.441 - Collections.<String, List<String>>emptyMap(),
92.442 - Collections.<String>singletonList("public void clone() {$stmts$;}"));
92.443 - }
92.444 -
92.445 - public void testMethodName2() throws Exception {
92.446 - String code = "package test; public class Test {public void test() { clone(); } }";
92.447 -
92.448 - performTest(code,
92.449 - Collections.singletonMap("public void test() {$stmts$;}", Arrays.asList("public void test() { clone(); }")),
92.450 - Collections.<String>emptyList());
92.451 - }
92.452 -
92.453 - private long measure(String baseCode, String toInsert, int repetitions, String pattern) throws Exception {
92.454 - int pos = baseCode.indexOf('|');
92.455 -
92.456 - assertTrue(pos != (-1));
92.457 -
92.458 - baseCode = baseCode.replaceAll(Pattern.quote("|"), "");
92.459 -
92.460 - StringBuilder code = new StringBuilder(baseCode.length() + repetitions * toInsert.length());
92.461 -
92.462 - code.append(baseCode);
92.463 -
92.464 - while (repetitions-- > 0) {
92.465 - code.insert(pos, toInsert);
92.466 - }
92.467 -
92.468 - long startTime = System.currentTimeMillis();
92.469 -
92.470 - performTest(code.toString(),
92.471 - Collections.<String, List<String>>emptyMap(),
92.472 - Arrays.asList(pattern));
92.473 -
92.474 - long endTime = System.currentTimeMillis();
92.475 -
92.476 - return endTime - startTime;
92.477 - }
92.478 -
92.479 - public void XtestMeasureTime() throws Exception {
92.480 - String code = TestUtilities.copyFileToString(new File("/usr/local/home/lahvac/src/nb//outgoing/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionProvider.java"));
92.481 - List<String> patterns = new LinkedList<String>();
92.482 -
92.483 - for (int cntr = 0; cntr < 1000; cntr++) {
92.484 - patterns.add("System.err.println($1)");
92.485 - }
92.486 -
92.487 - performTest(code,
92.488 - Collections.<String, List<String>>emptyMap(),
92.489 - patterns);
92.490 - }
92.491 -
92.492 - public void testMatches1() throws Exception {
92.493 - performMatchesTest("package test; public class Test { private void test() { f.isDirectory(); } }", Arrays.asList("$1.isDirectory()", "new ImageIcon($1)"), true);
92.494 - }
92.495 -
92.496 - public void testSerialization() throws Exception {
92.497 - String text = "package test; public class Test { public void test1(boolean b) { int q; if (b) q = 2; else q = 3; } }";
92.498 -
92.499 - prepareTest("test/Test.java", text);
92.500 -
92.501 - ByteArrayOutputStream out = new ByteArrayOutputStream();
92.502 - EncodingContext ec = new EncodingContext(out, false);
92.503 -
92.504 - createSearch().encode(info.getCompilationUnit(), ec);
92.505 -
92.506 - boolean matches = createSearch().matches(new ByteArrayInputStream(out.toByteArray()), createSearch().create(info, "{ $p$; $T $v; if($a) $v = $b; else $v = $c; $q$; }"));
92.507 -
92.508 - assertTrue(matches);
92.509 - }
92.510 -
92.511 - public void testFrequencies() throws Exception {
92.512 - String text = "package test; public class Test { public void test1(boolean b) { java.io.File f = null; f.isDirectory(); f.isDirectory(); new javax.swing.ImageIcon(null); } }";
92.513 -
92.514 - prepareTest("test/Test.java", text);
92.515 -
92.516 - ByteArrayOutputStream out = new ByteArrayOutputStream();
92.517 - EncodingContext ec = new EncodingContext(out, false);
92.518 -
92.519 - createSearch().encode(info.getCompilationUnit(), ec);
92.520 -
92.521 - Map<String, Integer> actual = createSearch().matchesWithFrequencies(new ByteArrayInputStream(out.toByteArray()), createSearch().create(info, "$1.isDirectory()", "new ImageIcon($1)"));
92.522 - Map<String, Integer> golden = new HashMap<String, Integer>();
92.523 -
92.524 - golden.put("$1.isDirectory()", 2);
92.525 - golden.put("new ImageIcon($1)", 1);
92.526 -
92.527 - assertEquals(golden, actual);
92.528 - }
92.529 -
92.530 - public void testPatternEncodingAndIdentifiers() throws Exception {
92.531 - String text = "package test; public class Test { }";
92.532 -
92.533 - prepareTest("test/Test.java", text);
92.534 -
92.535 - BulkPattern bp = createSearch().create(info, "$0.isDirectory()");
92.536 -
92.537 - assertEquals(Arrays.asList(new HashSet<String>(Arrays.asList("isDirectory"))), bp.getIdentifiers());
92.538 - //TODO: the actual code for kinds differs for NFABased search and REBased search:
92.539 -// assertEquals(Arrays.asList(new HashSet<String>(Arrays.asList(Kind.METHOD_INVOCATION.name()))), bp.getKinds());
92.540 - }
92.541 -
92.542 - protected abstract BulkSearch createSearch();
92.543 -
92.544 - private void performMatchesTest(String text, List<String> patterns, boolean golden) throws Exception {
92.545 - prepareTest("test/Test.java", text);
92.546 -
92.547 - BulkPattern p = createSearch().create(info, patterns);
92.548 -
92.549 - boolean result = createSearch().matches(info, new TreePath(info.getCompilationUnit()), p);
92.550 -
92.551 - assertEquals(golden, result);
92.552 - }
92.553 -
92.554 - private void performTest(String text, Map<String, List<String>> containedPatterns, Collection<String> notContainedPatterns) throws Exception {
92.555 - prepareTest("test/Test.java", text);
92.556 -
92.557 - List<String> patterns = new LinkedList<String>();
92.558 -
92.559 - patterns.addAll(containedPatterns.keySet());
92.560 - patterns.addAll(notContainedPatterns);
92.561 -
92.562 - long s1 = System.currentTimeMillis();
92.563 - BulkPattern p = createSearch().create(info, patterns);
92.564 - long e1 = System.currentTimeMillis();
92.565 -
92.566 -// System.err.println("create: " + (e1 - s1));
92.567 -
92.568 - long s2 = System.currentTimeMillis();
92.569 - Map<String, Collection<TreePath>> result = createSearch().match(info, new TreePath(info.getCompilationUnit()), p);
92.570 - long e2 = System.currentTimeMillis();
92.571 -
92.572 -// System.err.println("match: " + (e2 - s2));
92.573 -
92.574 - assertTrue(result.toString(), result.keySet().containsAll(containedPatterns.keySet()));
92.575 -
92.576 - for (Entry<String, Collection<TreePath>> e : result.entrySet()) {
92.577 - List<String> actual = new LinkedList<String>();
92.578 -
92.579 - for (TreePath tp : e.getValue()) {
92.580 - assertNotNull(TreePathHandle.create(tp, info).resolve(info));
92.581 -
92.582 - int start = (int) info.getTrees().getSourcePositions().getStartPosition(info.getCompilationUnit(), tp.getLeaf());
92.583 - int end = (int) info.getTrees().getSourcePositions().getEndPosition(info.getCompilationUnit(), tp.getLeaf());
92.584 -
92.585 - actual.add(info.getText().substring(start, end));
92.586 - }
92.587 -
92.588 - assertEquals(e.getKey(), containedPatterns.get(e.getKey()), actual);
92.589 - }
92.590 -
92.591 -
92.592 - Set<String> none = new HashSet<String>(result.keySet());
92.593 -
92.594 - none.retainAll(notContainedPatterns);
92.595 -
92.596 - assertTrue(none.isEmpty());
92.597 -
92.598 - if (!verifyIndexingData())
92.599 - return ;
92.600 -
92.601 - //ensure the returned identifiers/treeKinds are correct:
92.602 - ByteArrayOutputStream data = new ByteArrayOutputStream();
92.603 - EncodingContext ec = new EncodingContext(data, false);
92.604 -
92.605 - createSearch().encode(info.getCompilationUnit(), ec);
92.606 -
92.607 - for (int i = 0; i < containedPatterns.size(); i++) {
92.608 - assertTrue("expected: " + p.getIdentifiers().get(i) + ", but exist only: " + ec.getIdentifiers(), ec.getIdentifiers().containsAll(p.getIdentifiers().get(i)));
92.609 -
92.610 - for (List<String> phrase : p.getRequiredContent().get(i)) {
92.611 - assertTrue("expected: " + phrase + ", but exist only: " + ec.getContent() + "(all phrases: " + p.getRequiredContent().get(i) + ")", Collections.indexOfSubList(ec.getContent(), phrase) != (-1));
92.612 - }
92.613 - }
92.614 -
92.615 - data.close();
92.616 - assertEquals(!containedPatterns.isEmpty(), createSearch().matches(new ByteArrayInputStream(data.toByteArray()), p));
92.617 - }
92.618 -
92.619 - private void prepareTest(String fileName, String code) throws Exception {
92.620 - clearWorkDir();
92.621 -
92.622 - FileUtil.refreshFor(File.listRoots());
92.623 -
92.624 - FileObject workFO = FileUtil.toFileObject(getWorkDir());
92.625 -
92.626 - assertNotNull(workFO);
92.627 -
92.628 - workFO.refresh();
92.629 -
92.630 - sourceRoot = workFO.createFolder("src");
92.631 - FileObject buildRoot = workFO.createFolder("build");
92.632 - FileObject cache = workFO.createFolder("cache");
92.633 -
92.634 - FileObject data = FileUtil.createData(sourceRoot, fileName);
92.635 - File dataFile = FileUtil.toFile(data);
92.636 -
92.637 - assertNotNull(dataFile);
92.638 -
92.639 - TestUtilities.copyStringToFile(dataFile, code);
92.640 -
92.641 - SourceUtilsTestUtil.prepareTest(sourceRoot, buildRoot, cache);
92.642 -
92.643 - DataObject od = DataObject.find(data);
92.644 - EditorCookie ec = od.getLookup().lookup(EditorCookie.class);
92.645 -
92.646 - assertNotNull(ec);
92.647 -
92.648 - doc = ec.openDocument();
92.649 - doc.putProperty(Language.class, JavaTokenId.language());
92.650 -
92.651 - JavaSource js = JavaSource.forFileObject(data);
92.652 -
92.653 - assertNotNull(js);
92.654 -
92.655 - info = SourceUtilsTestUtil.getCompilationInfo(js, Phase.RESOLVED);
92.656 -
92.657 - assertNotNull(info);
92.658 - }
92.659 -
92.660 - private FileObject sourceRoot;
92.661 - private CompilationInfo info;
92.662 - private Document doc;
92.663 -
92.664 - protected boolean verifyIndexingData() {
92.665 - return true;
92.666 - }
92.667 -}
93.1 --- a/borrowedtests/src/org/netbeans/modules/java/source/transform/Transformer.java Fri Jan 27 13:35:56 2012 +0100
93.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
93.3 @@ -1,133 +0,0 @@
93.4 -/*
93.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
93.6 - *
93.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
93.8 - *
93.9 - * The contents of this file are subject to the terms of either the GNU
93.10 - * General Public License Version 2 only ("GPL") or the Common
93.11 - * Development and Distribution License("CDDL") (collectively, the
93.12 - * "License"). You may not use this file except in compliance with the
93.13 - * License. You can obtain a copy of the License at
93.14 - * http://www.netbeans.org/cddl-gplv2.html
93.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
93.16 - * specific language governing permissions and limitations under the
93.17 - * License. When distributing the software, include this License Header
93.18 - * Notice in each file and include the License file at
93.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
93.20 - * particular file as subject to the "Classpath" exception as provided
93.21 - * by Sun in the GPL Version 2 section of the License file that
93.22 - * accompanied this code. If applicable, add the following below the
93.23 - * License Header, with the fields enclosed by brackets [] replaced by
93.24 - * your own identifying information:
93.25 - * "Portions Copyrighted [year] [name of copyright owner]"
93.26 - *
93.27 - * Contributor(s):
93.28 - *
93.29 - * The Original Software is NetBeans. The Initial Developer of the Original
93.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
93.31 - * Microsystems, Inc. All Rights Reserved.
93.32 - *
93.33 - * If you wish your version of this file to be governed by only the CDDL
93.34 - * or only the GPL Version 2, indicate your decision by adding
93.35 - * "[Contributor] elects to include this software in this distribution
93.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
93.37 - * single choice of license, a recipient has the option to distribute
93.38 - * your version of this file under either the CDDL, the GPL Version 2 or
93.39 - * to extend the choice of license to its licensees as provided above.
93.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
93.41 - * Version 2 license, then the option applies only if the new code is
93.42 - * made subject to such option by the copyright holder.
93.43 - */
93.44 -
93.45 -package org.netbeans.modules.java.source.transform;
93.46 -
93.47 -import org.netbeans.modules.java.source.query.CommentHandler;
93.48 -import org.openide.util.NbBundle;
93.49 -import com.sun.source.tree.*;
93.50 -import com.sun.source.util.TreeScanner;
93.51 -import com.sun.tools.javac.model.JavacTypes;
93.52 -import com.sun.tools.javac.util.Context;
93.53 -import java.util.List;
93.54 -import java.util.logging.*;
93.55 -import javax.lang.model.util.Types;
93.56 -import org.netbeans.api.java.source.WorkingCopy;
93.57 -import org.netbeans.modules.java.source.builder.ASTService;
93.58 -import org.netbeans.modules.java.source.builder.CommentHandlerService;
93.59 -import org.netbeans.modules.java.source.builder.TreeFactory;
93.60 -
93.61 -/**
93.62 - * A Transformer is an Query that modifies the model. Model transformation
93.63 - * is done by a supplied ImmutableTreeTranslator implementation. A new context
93.64 - * is set upon successful completion of this Transformer.
93.65 - */
93.66 -public abstract class Transformer<R, P> extends TreeScanner<R,P> {
93.67 -
93.68 - CommentHandler commentHandler;
93.69 - public TreeFactory make;
93.70 - protected WorkingCopy copy;
93.71 - protected String refactoringDescription;
93.72 - protected Types types; // used by tests
93.73 - private String failureMessage;
93.74 - protected ASTService model;
93.75 -
93.76 - static final Logger logger = Logger.getLogger("org.netbeans.modules.java.source");
93.77 -
93.78 - public void init() {
93.79 - }
93.80 -
93.81 - /**
93.82 - * Initialize and associate this Query instance with the
93.83 - * specified QueryEnvironment.
93.84 - */
93.85 - public void attach(Context context, WorkingCopy copy) {
93.86 - make = TreeFactory.instance(context);
93.87 - types = JavacTypes.instance(context);
93.88 - commentHandler = CommentHandlerService.instance(context);
93.89 - model = ASTService.instance(context);
93.90 - this.copy = copy;
93.91 - }
93.92 -
93.93 - /**
93.94 - * Release any instance data created during attach() invocation. This
93.95 - * is necessary because the Java reflection support may cache created
93.96 - * instances, preventing the session data from being garbage-collected.
93.97 - */
93.98 - public void release() {
93.99 - //changes.release(); // enable when async results are supported
93.100 - //result.release()
93.101 - make = null;
93.102 - types = null;
93.103 - this.copy = null;
93.104 - }
93.105 -
93.106 - public void destroy() {}
93.107 -
93.108 - public String getRefactoringDescription() {
93.109 - return refactoringDescription != null ? refactoringDescription : "Unnamed Refactoring";
93.110 - }
93.111 -
93.112 - public void setRefactoringDescription(String description) {
93.113 - refactoringDescription = description;
93.114 - }
93.115 -
93.116 - public void apply(Tree t) {
93.117 - t.accept(this, null);
93.118 - }
93.119 -
93.120 - String getString(String key) {
93.121 - return NbBundle.getBundle(Transformer.class).getString(key); //NOI18N
93.122 - }
93.123 -
93.124 - /**
93.125 - * True if no translation failures occurred.
93.126 - */
93.127 - protected boolean translationSuccessful() {
93.128 - return failureMessage == null;
93.129 - }
93.130 -
93.131 - public final void copyCommentTo(Tree from, Tree to) {
93.132 - if (from != null && to != null) {
93.133 - commentHandler.copyComments(from, to);
93.134 - }
93.135 - }
93.136 -}
94.1 --- a/borrowedtests/src/org/netbeans/modules/java/source/usages/IndexUtil.java Fri Jan 27 13:35:56 2012 +0100
94.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
94.3 @@ -1,58 +0,0 @@
94.4 -/*
94.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
94.6 - *
94.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
94.8 - *
94.9 - * The contents of this file are subject to the terms of either the GNU
94.10 - * General Public License Version 2 only ("GPL") or the Common
94.11 - * Development and Distribution License("CDDL") (collectively, the
94.12 - * "License"). You may not use this file except in compliance with the
94.13 - * License. You can obtain a copy of the License at
94.14 - * http://www.netbeans.org/cddl-gplv2.html
94.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
94.16 - * specific language governing permissions and limitations under the
94.17 - * License. When distributing the software, include this License Header
94.18 - * Notice in each file and include the License file at
94.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
94.20 - * particular file as subject to the "Classpath" exception as provided
94.21 - * by Sun in the GPL Version 2 section of the License file that
94.22 - * accompanied this code. If applicable, add the following below the
94.23 - * License Header, with the fields enclosed by brackets [] replaced by
94.24 - * your own identifying information:
94.25 - * "Portions Copyrighted [year] [name of copyright owner]"
94.26 - *
94.27 - * Contributor(s):
94.28 - *
94.29 - * The Original Software is NetBeans. The Initial Developer of the Original
94.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
94.31 - * Microsystems, Inc. All Rights Reserved.
94.32 - *
94.33 - * If you wish your version of this file to be governed by only the CDDL
94.34 - * or only the GPL Version 2, indicate your decision by adding
94.35 - * "[Contributor] elects to include this software in this distribution
94.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
94.37 - * single choice of license, a recipient has the option to distribute
94.38 - * your version of this file under either the CDDL, the GPL Version 2 or
94.39 - * to extend the choice of license to its licensees as provided above.
94.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
94.41 - * Version 2 license, then the option applies only if the new code is
94.42 - * made subject to such option by the copyright holder.
94.43 - */
94.44 -
94.45 -package org.netbeans.modules.java.source.usages;
94.46 -
94.47 -import java.io.File;
94.48 -import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
94.49 -import org.openide.filesystems.FileUtil;
94.50 -
94.51 -/**
94.52 - *
94.53 - * @author Tomas Zezula
94.54 - */
94.55 -public class IndexUtil {
94.56 -
94.57 - public static void setCacheFolder (final File cacheFolder) {
94.58 - CacheFolder.setCacheFolder(FileUtil.toFileObject(cacheFolder));
94.59 - }
94.60 -
94.61 -}
95.1 --- a/borrowedtests/src/org/netbeans/modules/parsing/impl/indexing/MimeTypes.java Fri Jan 27 13:35:56 2012 +0100
95.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
95.3 @@ -1,66 +0,0 @@
95.4 -/*
95.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
95.6 - *
95.7 - * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
95.8 - *
95.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
95.10 - * Other names may be trademarks of their respective owners.
95.11 - *
95.12 - * The contents of this file are subject to the terms of either the GNU
95.13 - * General Public License Version 2 only ("GPL") or the Common
95.14 - * Development and Distribution License("CDDL") (collectively, the
95.15 - * "License"). You may not use this file except in compliance with the
95.16 - * License. You can obtain a copy of the License at
95.17 - * http://www.netbeans.org/cddl-gplv2.html
95.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
95.19 - * specific language governing permissions and limitations under the
95.20 - * License. When distributing the software, include this License Header
95.21 - * Notice in each file and include the License file at
95.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
95.23 - * particular file as subject to the "Classpath" exception as provided
95.24 - * by Oracle in the GPL Version 2 section of the License file that
95.25 - * accompanied this code. If applicable, add the following below the
95.26 - * License Header, with the fields enclosed by brackets [] replaced by
95.27 - * your own identifying information:
95.28 - * "Portions Copyrighted [year] [name of copyright owner]"
95.29 - *
95.30 - * If you wish your version of this file to be governed by only the CDDL
95.31 - * or only the GPL Version 2, indicate your decision by adding
95.32 - * "[Contributor] elects to include this software in this distribution
95.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
95.34 - * single choice of license, a recipient has the option to distribute
95.35 - * your version of this file under either the CDDL, the GPL Version 2 or
95.36 - * to extend the choice of license to its licensees as provided above.
95.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
95.38 - * Version 2 license, then the option applies only if the new code is
95.39 - * made subject to such option by the copyright holder.
95.40 - *
95.41 - * Contributor(s):
95.42 - *
95.43 - * Portions Copyrighted 2011 Sun Microsystems, Inc.
95.44 - */
95.45 -package org.netbeans.modules.parsing.impl.indexing;
95.46 -
95.47 -import java.util.Set;
95.48 -import org.netbeans.api.annotations.common.CheckForNull;
95.49 -import org.netbeans.api.annotations.common.NonNull;
95.50 -import org.openide.util.Parameters;
95.51 -
95.52 -/**
95.53 - *
95.54 - * @author Tomas Zezula
95.55 - */
95.56 -public class MimeTypes {
95.57 -
95.58 - private MimeTypes() {}
95.59 -
95.60 - public static void setAllMimeTypes(@NonNull final Set<String> allMimeTypes) {
95.61 - Parameters.notNull("allMimeTypes", allMimeTypes); //NOI18N
95.62 - Util.allMimeTypes = allMimeTypes;
95.63 - }
95.64 -
95.65 - @CheckForNull
95.66 - public static Set<String> getAllMimeTypes() {
95.67 - return Util.allMimeTypes;
95.68 - }
95.69 -}
96.1 --- a/borrowedtests/src/org/openide/util/test/AnnotationProcessorTestUtils.java Fri Jan 27 13:35:56 2012 +0100
96.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
96.3 @@ -1,139 +0,0 @@
96.4 -/*
96.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
96.6 - *
96.7 - * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
96.8 - *
96.9 - * The contents of this file are subject to the terms of either the GNU
96.10 - * General Public License Version 2 only ("GPL") or the Common
96.11 - * Development and Distribution License("CDDL") (collectively, the
96.12 - * "License"). You may not use this file except in compliance with the
96.13 - * License. You can obtain a copy of the License at
96.14 - * http://www.netbeans.org/cddl-gplv2.html
96.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
96.16 - * specific language governing permissions and limitations under the
96.17 - * License. When distributing the software, include this License Header
96.18 - * Notice in each file and include the License file at
96.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
96.20 - * particular file as subject to the "Classpath" exception as provided
96.21 - * by Sun in the GPL Version 2 section of the License file that
96.22 - * accompanied this code. If applicable, add the following below the
96.23 - * License Header, with the fields enclosed by brackets [] replaced by
96.24 - * your own identifying information:
96.25 - * "Portions Copyrighted [year] [name of copyright owner]"
96.26 - *
96.27 - * If you wish your version of this file to be governed by only the CDDL
96.28 - * or only the GPL Version 2, indicate your decision by adding
96.29 - * "[Contributor] elects to include this software in this distribution
96.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
96.31 - * single choice of license, a recipient has the option to distribute
96.32 - * your version of this file under either the CDDL, the GPL Version 2 or
96.33 - * to extend the choice of license to its licensees as provided above.
96.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
96.35 - * Version 2 license, then the option applies only if the new code is
96.36 - * made subject to such option by the copyright holder.
96.37 - *
96.38 - * Contributor(s):
96.39 - *
96.40 - * Portions Copyrighted 2008 Sun Microsystems, Inc.
96.41 - */
96.42 -
96.43 -package org.openide.util.test;
96.44 -
96.45 -import java.io.File;
96.46 -import java.io.FileWriter;
96.47 -import java.io.IOException;
96.48 -import java.io.OutputStream;
96.49 -import java.io.PrintWriter;
96.50 -import java.io.Writer;
96.51 -import java.util.ArrayList;
96.52 -import java.util.List;
96.53 -import java.util.regex.Pattern;
96.54 -import javax.tools.JavaCompiler;
96.55 -import javax.tools.ToolProvider;
96.56 -import junit.framework.Assert;
96.57 -
96.58 -/**
96.59 - * Utilities useful to those testing JSR 269 annotation processors.
96.60 - * <p>If you just want to test that the output of the processor is correct,
96.61 - * you do not need to do anything special:
96.62 - * just use the annotation on some sample classes nested inside your unit test.
96.63 - * They will be processed, and you check that your SPI loads them correctly.
96.64 - * These utilities are useful mainly in case you want to check that the processor
96.65 - * rejects erroneous sources, and that any messages it prints are reasonable;
96.66 - * that it behaves correctly on incremental compilations; etc.
96.67 - */
96.68 -public class AnnotationProcessorTestUtils {
96.69 -
96.70 - private AnnotationProcessorTestUtils() {}
96.71 -
96.72 - /**
96.73 - * Create a source file.
96.74 - * @param dir source root
96.75 - * @param clazz a fully-qualified class name
96.76 - * @param content lines of text (skip package decl)
96.77 - */
96.78 - public static void makeSource(File dir, String clazz, String... content) throws IOException {
96.79 - File f = new File(dir, clazz.replace('.', File.separatorChar) + ".java");
96.80 - f.getParentFile().mkdirs();
96.81 - Writer w = new FileWriter(f);
96.82 - try {
96.83 - PrintWriter pw = new PrintWriter(w);
96.84 - String pkg = clazz.replaceFirst("\\.[^.]+$", "");
96.85 - if (!pkg.equals(clazz)) {
96.86 - pw.println("package " + pkg + ";");
96.87 - }
96.88 - for (String line : content) {
96.89 - pw.println(line);
96.90 - }
96.91 - pw.flush();
96.92 - } finally {
96.93 - w.close();
96.94 - }
96.95 - }
96.96 -
96.97 - /**
96.98 - * Run the Java compiler.
96.99 - * (A JSR 199 implementation must be available.)
96.100 - * @param src a source root (runs javac on all *.java it finds matching {@code srcIncludes})
96.101 - * @param srcIncludes a pattern of source files names without path to compile (useful for testing incremental compiles), or null for all
96.102 - * @param dest a dest dir to compile classes to
96.103 - * @param cp classpath entries; if null, use Java classpath of test
96.104 - * @param stderr output stream to print messages to, or null for test console (i.e. do not capture)
96.105 - * @return true if compilation succeeded, false if it failed
96.106 - */
96.107 - public static boolean runJavac(File src, String srcIncludes, File dest, File[] cp, OutputStream stderr) {
96.108 - List<String> args = new ArrayList<String>();
96.109 - args.add("-classpath");
96.110 - if (cp != null) {
96.111 - StringBuffer b = new StringBuffer();
96.112 - for (File entry : cp) {
96.113 - b.append(File.pathSeparatorChar);
96.114 - b.append(entry.getAbsolutePath());
96.115 - }
96.116 - args.add(b.toString());
96.117 - } else {
96.118 - args.add(System.getProperty("java.class.path"));
96.119 - }
96.120 - args.add("-d");
96.121 - args.add(dest.getAbsolutePath());
96.122 - args.add("-sourcepath");
96.123 - args.add(src.getAbsolutePath());
96.124 - dest.mkdirs();
96.125 - scan(args, src, srcIncludes);
96.126 - JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
96.127 - Assert.assertNotNull("no JSR 199 compiler impl found; try e.g.: " +
96.128 - "test.unit.run.cp.extra=${nb_all}/apisupport.harness/external/openjdk-javac-6-b12.jar", compiler);
96.129 - //System.err.println("running javac with args: " + args);
96.130 - return compiler.run(null, null, stderr, args.toArray(new String[args.size()])) == 0;
96.131 - }
96.132 - private static void scan(List<String> names, File f, String includes) {
96.133 - if (f.isDirectory()) {
96.134 - for (File kid : f.listFiles()) {
96.135 - scan(names, kid, includes);
96.136 - }
96.137 - } else if (f.getName().endsWith(".java") && (includes == null || Pattern.compile(includes).matcher(f.getName()).find())) {
96.138 - names.add(f.getAbsolutePath());
96.139 - }
96.140 - }
96.141 -
96.142 -}
97.1 --- a/bridges/apisupport/bridge/org/netbeans/modules/jackpot30/apisupport/bridgeimpl/ProjectDependencyUpgraderImpl.java Fri Jan 27 13:35:56 2012 +0100
97.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
97.3 @@ -1,157 +0,0 @@
97.4 -/*
97.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
97.6 - *
97.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
97.8 - *
97.9 - * The contents of this file are subject to the terms of either the GNU
97.10 - * General Public License Version 2 only ("GPL") or the Common
97.11 - * Development and Distribution License("CDDL") (collectively, the
97.12 - * "License"). You may not use this file except in compliance with the
97.13 - * License. You can obtain a copy of the License at
97.14 - * http://www.netbeans.org/cddl-gplv2.html
97.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
97.16 - * specific language governing permissions and limitations under the
97.17 - * License. When distributing the software, include this License Header
97.18 - * Notice in each file and include the License file at
97.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
97.20 - * particular file as subject to the "Classpath" exception as provided
97.21 - * by Sun in the GPL Version 2 section of the License file that
97.22 - * accompanied this code. If applicable, add the following below the
97.23 - * License Header, with the fields enclosed by brackets [] replaced by
97.24 - * your own identifying information:
97.25 - * "Portions Copyrighted [year] [name of copyright owner]"
97.26 - *
97.27 - * If you wish your version of this file to be governed by only the CDDL
97.28 - * or only the GPL Version 2, indicate your decision by adding
97.29 - * "[Contributor] elects to include this software in this distribution
97.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
97.31 - * single choice of license, a recipient has the option to distribute
97.32 - * your version of this file under either the CDDL, the GPL Version 2 or
97.33 - * to extend the choice of license to its licensees as provided above.
97.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
97.35 - * Version 2 license, then the option applies only if the new code is
97.36 - * made subject to such option by the copyright holder.
97.37 - *
97.38 - * Contributor(s):
97.39 - *
97.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
97.41 - */
97.42 -package org.netbeans.modules.jackpot30.apisupport.bridgeimpl;
97.43 -
97.44 -import java.io.IOException;
97.45 -import org.netbeans.api.project.FileOwnerQuery;
97.46 -import org.netbeans.api.project.Project;
97.47 -import org.netbeans.api.project.ProjectManager;
97.48 -import org.netbeans.api.project.ProjectUtils;
97.49 -import org.netbeans.modules.apisupport.project.ModuleDependency;
97.50 -import org.netbeans.modules.apisupport.project.NbModuleProject;
97.51 -import org.netbeans.modules.apisupport.project.ProjectXMLManager;
97.52 -import org.netbeans.modules.apisupport.project.ProjectXMLManager.CyclicDependencyException;
97.53 -import org.netbeans.modules.apisupport.project.spi.NbModuleProvider;
97.54 -import org.netbeans.modules.apisupport.project.universe.ModuleEntry;
97.55 -import org.netbeans.modules.jackpot30.apisupport.Utilities;
97.56 -import org.netbeans.modules.jackpot30.apisupport.Utilities.ParsedDependency;
97.57 -import org.netbeans.modules.java.hints.jackpot.spi.ProjectDependencyUpgrader;
97.58 -import org.openide.filesystems.FileObject;
97.59 -import org.openide.modules.SpecificationVersion;
97.60 -import org.openide.util.Exceptions;
97.61 -
97.62 -/**
97.63 - *
97.64 - * @author lahvac
97.65 - */
97.66 -public class ProjectDependencyUpgraderImpl extends ProjectDependencyUpgrader {
97.67 -
97.68 - public boolean ensureDependency(Project currentProject, FileObject depFO, SpecificationVersion spec, final boolean canShowUI) {
97.69 - NbModuleProvider currentNbModule = currentProject.getLookup().lookup(NbModuleProvider.class);
97.70 -
97.71 - if (currentNbModule == null) {
97.72 - return false;
97.73 - }
97.74 -
97.75 - Project referedProject = FileOwnerQuery.getOwner(depFO);
97.76 -
97.77 - if (referedProject == null) {
97.78 - return false;
97.79 - }
97.80 -
97.81 - NbModuleProject referedNbProject = referedProject.getLookup().lookup(NbModuleProject.class);
97.82 -
97.83 - if (referedNbProject == null) {
97.84 - return false;
97.85 - }
97.86 -
97.87 - return ensureDependency(currentProject, referedNbProject.getCodeNameBase(), ProjectUtils.getInformation(referedProject).getDisplayName(), null, spec, canShowUI);
97.88 - }
97.89 -
97.90 - private boolean ensureDependency(Project currentProject, String cnb, String displayName, String releaseVersion, SpecificationVersion spec, final boolean canShowUI) {
97.91 - NbModuleProvider currentNbModule = currentProject.getLookup().lookup(NbModuleProvider.class);
97.92 -
97.93 - if (currentNbModule == null) {
97.94 - return false;
97.95 - }
97.96 -
97.97 - try {
97.98 - NbModuleProject currentNbModuleProject = currentProject.getLookup().lookup(NbModuleProject.class);
97.99 -
97.100 - if (currentNbModuleProject == null) {
97.101 - return false;
97.102 - }
97.103 -
97.104 - ProjectXMLManager m = new ProjectXMLManager(currentNbModuleProject);
97.105 - ModuleDependency dep = m.getModuleDependency(cnb);
97.106 -
97.107 - if (dep == null) {
97.108 - if (showDependencyUpgradeDialog(currentProject, displayName, null, spec, false, canShowUI)) {
97.109 - ModuleEntry me = currentNbModuleProject.getModuleList().getEntry(cnb);
97.110 - ModuleDependency nue = new ModuleDependency(me,
97.111 - releaseVersion != null ? releaseVersion : me.getReleaseVersion(),
97.112 - spec != null ? spec.toString() : me.getSpecificationVersion(),
97.113 - true,
97.114 - false);
97.115 -
97.116 - m.addDependency(nue);
97.117 - ProjectManager.getDefault().saveProject(currentProject);
97.118 - }
97.119 -
97.120 - return true;
97.121 - }
97.122 -
97.123 - if (dep.getSpecificationVersion() == null) {
97.124 - //impl.dep?
97.125 - return false;
97.126 - }
97.127 -
97.128 - SpecificationVersion currentDep = new SpecificationVersion(dep.getSpecificationVersion());
97.129 -
97.130 - if (spec != null && (currentDep == null || currentDep.compareTo(spec) < 0)) {
97.131 - if (showDependencyUpgradeDialog(currentProject, displayName, new SpecificationVersion(dep.getSpecificationVersion()), spec, false, canShowUI)) {
97.132 - ModuleDependency nue = new ModuleDependency(dep.getModuleEntry(),
97.133 - releaseVersion != null ? releaseVersion : dep.getReleaseVersion(),
97.134 - spec.toString(),
97.135 - dep.hasCompileDependency(),
97.136 - dep.hasImplementationDependency());
97.137 -
97.138 - m.editDependency(dep, nue);
97.139 - ProjectManager.getDefault().saveProject(currentProject);
97.140 - }
97.141 -
97.142 - return true;
97.143 - }
97.144 - } catch (CyclicDependencyException ex) {
97.145 - Exceptions.printStackTrace(ex);
97.146 - } catch (IOException ex) {
97.147 - Exceptions.printStackTrace(ex);
97.148 - }
97.149 -
97.150 - return false;
97.151 - }
97.152 -
97.153 - @Override
97.154 - public boolean ensureDependency(Project p, String specification, boolean canShowUI) {
97.155 - ParsedDependency dep = Utilities.parseDependency(specification);
97.156 -
97.157 - return ensureDependency(p, dep.cnb, /*TODO: may null and that could put display name their*/specification, dep.releaseVersion, dep.specVersion, canShowUI);
97.158 - }
97.159 -
97.160 -}
98.1 --- a/bridges/apisupport/build.xml Fri Jan 27 13:35:56 2012 +0100
98.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
98.3 @@ -1,25 +0,0 @@
98.4 -<?xml version="1.0" encoding="UTF-8"?>
98.5 -<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
98.6 -<!-- for some information on what you could do (e.g. targets to override). -->
98.7 -<!-- If you delete this file and reopen the project it will be recreated. -->
98.8 -<project name="org.netbeans.modules.jackpot30.apisupport" default="netbeans" basedir=".">
98.9 - <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.apisupport.</description>
98.10 - <import file="nbproject/build-impl.xml"/>
98.11 - <import file="${suite.dir}/findbugs-import.xml"/>
98.12 - <target name="netbeans-extra" depends="init">
98.13 - <mkdir dir="build/bridgeclasses"/>
98.14 - <javac srcdir="bridge" destdir="build/bridgeclasses" source="1.6" target="1.6" debug="true" deprecation="true">
98.15 - <classpath>
98.16 - <path refid="cp"/>
98.17 - <pathelement location="${cluster}/modules/${code.name.base.dashes}.jar"/>
98.18 - </classpath>
98.19 - </javac>
98.20 - <copy todir="build/bridgeclasses">
98.21 - <fileset dir="bridge" excludes="${jar-excludes}"/>
98.22 - </copy>
98.23 - <mkdir dir="${cluster}/modules/ext"/>
98.24 - <jar jarfile="${cluster}/modules/ext/${code.name.base.dashes}.jar" compress="false">
98.25 - <fileset dir="build/bridgeclasses"/>
98.26 - </jar>
98.27 - </target>
98.28 -</project>
99.1 --- a/bridges/apisupport/manifest.mf Fri Jan 27 13:35:56 2012 +0100
99.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
99.3 @@ -1,6 +0,0 @@
99.4 -Manifest-Version: 1.0
99.5 -OpenIDE-Module: org.netbeans.modules.jackpot30.apisupport
99.6 -OpenIDE-Module-Implementation-Version: 1
99.7 -OpenIDE-Module-Install: org/netbeans/modules/jackpot30/apisupport/Installer.class
99.8 -OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/apisupport/Bundle.properties
99.9 -
100.1 --- a/bridges/apisupport/nbproject/build-impl.xml Fri Jan 27 13:35:56 2012 +0100
100.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
100.3 @@ -1,45 +0,0 @@
100.4 -<?xml version="1.0" encoding="UTF-8"?>
100.5 -<!--
100.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
100.7 -*** EDIT ../build.xml INSTEAD ***
100.8 --->
100.9 -<project name="org.netbeans.modules.jackpot30.apisupport-impl" basedir="..">
100.10 - <fail message="Please build using Ant 1.7.1 or higher.">
100.11 - <condition>
100.12 - <not>
100.13 - <antversion atleast="1.7.1"/>
100.14 - </not>
100.15 - </condition>
100.16 - </fail>
100.17 - <property file="nbproject/private/suite-private.properties"/>
100.18 - <property file="nbproject/suite.properties"/>
100.19 - <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
100.20 - <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
100.21 - <property file="${suite.dir}/nbproject/platform.properties"/>
100.22 - <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
100.23 - <attribute name="name"/>
100.24 - <attribute name="value"/>
100.25 - <sequential>
100.26 - <property name="@{name}" value="${@{value}}"/>
100.27 - </sequential>
100.28 - </macrodef>
100.29 - <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
100.30 - <attribute name="property"/>
100.31 - <attribute name="value"/>
100.32 - <sequential>
100.33 - <property name="@{property}" value="@{value}"/>
100.34 - </sequential>
100.35 - </macrodef>
100.36 - <property file="${user.properties.file}"/>
100.37 - <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
100.38 - <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
100.39 - <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
100.40 - <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
100.41 - <condition>
100.42 - <not>
100.43 - <contains string="${cluster.path.evaluated}" substring="platform"/>
100.44 - </not>
100.45 - </condition>
100.46 - </fail>
100.47 - <import file="${harness.dir}/build.xml"/>
100.48 -</project>
101.1 --- a/bridges/apisupport/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
101.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
101.3 @@ -1,8 +0,0 @@
101.4 -build.xml.data.CRC32=c45369e1
101.5 -build.xml.script.CRC32=a2cc69eb
101.6 -build.xml.stylesheet.CRC32=79c3b980@1.40
101.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
101.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
101.9 -nbproject/build-impl.xml.data.CRC32=e186a96e
101.10 -nbproject/build-impl.xml.script.CRC32=83dd2c27
101.11 -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.47
102.1 --- a/bridges/apisupport/nbproject/project.properties Fri Jan 27 13:35:56 2012 +0100
102.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
102.3 @@ -1,5 +0,0 @@
102.4 -is.eager=true
102.5 -javac.source=1.5
102.6 -javac.compilerargs=-Xlint -Xlint:-serial
102.7 -extra.module.files=modules/ext/org-netbeans-modules-jackpot30-apisupport.jar
102.8 -spec.version.base=1.16
103.1 --- a/bridges/apisupport/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
103.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
103.3 @@ -1,85 +0,0 @@
103.4 -<?xml version="1.0" encoding="UTF-8"?>
103.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
103.6 - <type>org.netbeans.modules.apisupport.project</type>
103.7 - <configuration>
103.8 - <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
103.9 - <code-name-base>org.netbeans.modules.jackpot30.apisupport</code-name-base>
103.10 - <suite-component/>
103.11 - <module-dependencies>
103.12 - <dependency>
103.13 - <code-name-base>org.netbeans.modules.apisupport.ant</code-name-base>
103.14 - <build-prerequisite/>
103.15 - <compile-dependency/>
103.16 - </dependency>
103.17 - <dependency>
103.18 - <code-name-base>org.netbeans.modules.apisupport.project</code-name-base>
103.19 - <build-prerequisite/>
103.20 - <compile-dependency/>
103.21 - </dependency>
103.22 - <dependency>
103.23 - <code-name-base>org.netbeans.modules.apisupport.project</code-name-base>
103.24 - <run-dependency>
103.25 - <release-version>1</release-version>
103.26 - </run-dependency>
103.27 - </dependency>
103.28 - <dependency>
103.29 - <code-name-base>org.netbeans.modules.java.hints</code-name-base>
103.30 - <build-prerequisite/>
103.31 - <compile-dependency/>
103.32 - <run-dependency>
103.33 - <release-version>1</release-version>
103.34 - <implementation-version/>
103.35 - </run-dependency>
103.36 - </dependency>
103.37 - <dependency>
103.38 - <code-name-base>org.netbeans.modules.projectapi</code-name-base>
103.39 - <build-prerequisite/>
103.40 - <compile-dependency/>
103.41 - <run-dependency>
103.42 - <release-version>1</release-version>
103.43 - <specification-version>1.29</specification-version>
103.44 - </run-dependency>
103.45 - </dependency>
103.46 - <dependency>
103.47 - <code-name-base>org.openide.filesystems</code-name-base>
103.48 - <build-prerequisite/>
103.49 - <compile-dependency/>
103.50 - <run-dependency>
103.51 - <specification-version>7.33.0.1.1</specification-version>
103.52 - </run-dependency>
103.53 - </dependency>
103.54 - <dependency>
103.55 - <code-name-base>org.openide.modules</code-name-base>
103.56 - <build-prerequisite/>
103.57 - <compile-dependency/>
103.58 - <run-dependency>
103.59 - <specification-version>7.14</specification-version>
103.60 - </run-dependency>
103.61 - </dependency>
103.62 - <dependency>
103.63 - <code-name-base>org.openide.util</code-name-base>
103.64 - <build-prerequisite/>
103.65 - <compile-dependency/>
103.66 - <run-dependency>
103.67 - <specification-version>7.32.0.1</specification-version>
103.68 - </run-dependency>
103.69 - </dependency>
103.70 - <dependency>
103.71 - <code-name-base>org.openide.util.lookup</code-name-base>
103.72 - <build-prerequisite/>
103.73 - <compile-dependency/>
103.74 - <run-dependency>
103.75 - <specification-version>8.2</specification-version>
103.76 - </run-dependency>
103.77 - </dependency>
103.78 - </module-dependencies>
103.79 - <public-packages/>
103.80 - <extra-compilation-unit>
103.81 - <package-root>bridge</package-root>
103.82 - <classpath>${module.classpath}:${cluster}/modules/${code.name.base.dashes}.jar</classpath>
103.83 - <built-to>build/bridgeclasses</built-to>
103.84 - <built-to>${cluster}/modules/ext/${code.name.base.dashes}.jar</built-to>
103.85 - </extra-compilation-unit>
103.86 - </data>
103.87 - </configuration>
103.88 -</project>
104.1 --- a/bridges/apisupport/nbproject/suite.properties Fri Jan 27 13:35:56 2012 +0100
104.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
104.3 @@ -1,1 +0,0 @@
104.4 -suite.dir=${basedir}/../..
105.1 --- a/bridges/apisupport/src/org/netbeans/modules/jackpot30/apisupport/APIProjectDependencyUpgraderImpl.java Fri Jan 27 13:35:56 2012 +0100
105.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
105.3 @@ -1,127 +0,0 @@
105.4 -/*
105.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
105.6 - *
105.7 - * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
105.8 - *
105.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
105.10 - * Other names may be trademarks of their respective owners.
105.11 - *
105.12 - * The contents of this file are subject to the terms of either the GNU General
105.13 - * Public License Version 2 only ("GPL") or the Common Development and
105.14 - * Distribution License("CDDL") (collectively, the "License"). You may not use
105.15 - * this file except in compliance with the License. You can obtain a copy of the
105.16 - * License at http://www.netbeans.org/cddl-gplv2.html or
105.17 - * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
105.18 - * governing permissions and limitations under the License. When distributing
105.19 - * the software, include this License Header Notice in each file and include the
105.20 - * License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
105.21 - * particular file as subject to the "Classpath" exception as provided by Oracle
105.22 - * in the GPL Version 2 section of the License file that accompanied this code.
105.23 - * If applicable, add the following below the License Header, with the fields
105.24 - * enclosed by brackets [] replaced by your own identifying information:
105.25 - * "Portions Copyrighted [year] [name of copyright owner]"
105.26 - *
105.27 - * If you wish your version of this file to be governed by only the CDDL or only
105.28 - * the GPL Version 2, indicate your decision by adding "[Contributor] elects to
105.29 - * include this software in this distribution under the [CDDL or GPL Version 2]
105.30 - * license." If you do not indicate a single choice of license, a recipient has
105.31 - * the option to distribute your version of this file under either the CDDL, the
105.32 - * GPL Version 2 or to extend the choice of license to its licensees as provided
105.33 - * above. However, if you add GPL Version 2 code and therefore, elected the GPL
105.34 - * Version 2 license, then the option applies only if the new code is made
105.35 - * subject to such option by the copyright holder.
105.36 - *
105.37 - * Contributor(s):
105.38 - *
105.39 - * Portions Copyrighted 2011 Sun Microsystems, Inc.
105.40 - */
105.41 -package org.netbeans.modules.jackpot30.apisupport;
105.42 -
105.43 -import java.io.IOException;
105.44 -import org.netbeans.api.project.FileOwnerQuery;
105.45 -import org.netbeans.api.project.Project;
105.46 -import org.netbeans.api.project.ProjectManager;
105.47 -import org.netbeans.api.project.ProjectUtils;
105.48 -import org.netbeans.modules.apisupport.project.spi.NbModuleProvider;
105.49 -import org.netbeans.modules.jackpot30.apisupport.Utilities.ParsedDependency;
105.50 -import org.netbeans.modules.java.hints.jackpot.spi.ProjectDependencyUpgrader;
105.51 -import org.openide.filesystems.FileObject;
105.52 -import org.openide.modules.SpecificationVersion;
105.53 -import org.openide.util.Exceptions;
105.54 -import org.openide.util.lookup.ServiceProvider;
105.55 -
105.56 -/**
105.57 - *
105.58 - * @author lahvac
105.59 - */
105.60 -public class APIProjectDependencyUpgraderImpl extends ProjectDependencyUpgrader {
105.61 -
105.62 - public boolean ensureDependency(Project currentProject, FileObject depFO, SpecificationVersion spec, final boolean canShowUI) {
105.63 - NbModuleProvider currentNbModule = currentProject.getLookup().lookup(NbModuleProvider.class);
105.64 -
105.65 - if (currentNbModule == null) {
105.66 - return false;
105.67 - }
105.68 -
105.69 - Project referedProject = FileOwnerQuery.getOwner(depFO);
105.70 -
105.71 - if (referedProject == null) {
105.72 - return false;
105.73 - }
105.74 -
105.75 - NbModuleProvider referedNbProject = referedProject.getLookup().lookup(NbModuleProvider.class);
105.76 -
105.77 - if (referedNbProject == null) {
105.78 - return false;
105.79 - }
105.80 -
105.81 - return ensureDependency(currentProject, referedNbProject.getCodeNameBase(), ProjectUtils.getInformation(referedProject).getDisplayName(), null, spec, canShowUI);
105.82 - }
105.83 -
105.84 - private boolean ensureDependency(Project currentProject, String cnb, String displayName, String releaseVersion, SpecificationVersion spec, final boolean canShowUI) {
105.85 - NbModuleProvider currentNbModule = currentProject.getLookup().lookup(NbModuleProvider.class);
105.86 -
105.87 - if (currentNbModule == null) {
105.88 - return false;
105.89 - }
105.90 -
105.91 - try {
105.92 - if (!currentNbModule.hasDependency(cnb)) {
105.93 - if (showDependencyUpgradeDialog(currentProject, displayName, null, spec, false, canShowUI)) {
105.94 - currentNbModule.addDependency(cnb, releaseVersion, spec, true);
105.95 - ProjectManager.getDefault().saveProject(currentProject);
105.96 - }
105.97 -
105.98 - return true;
105.99 - }
105.100 -
105.101 - SpecificationVersion currentDep = currentNbModule.getDependencyVersion(cnb);
105.102 -
105.103 - if (currentDep == null) {
105.104 - //impl.dep?
105.105 - return false;
105.106 - }
105.107 -
105.108 - if (spec != null && (currentDep == null || currentDep.compareTo(spec) < 0)) {
105.109 - if (showDependencyUpgradeDialog(currentProject, displayName, currentDep, spec, false, canShowUI)) {
105.110 - currentNbModule.addDependency(cnb, releaseVersion, spec, true);
105.111 - ProjectManager.getDefault().saveProject(currentProject);
105.112 - }
105.113 -
105.114 - return true;
105.115 - }
105.116 - } catch (IOException ex) {
105.117 - Exceptions.printStackTrace(ex);
105.118 - }
105.119 -
105.120 - return false;
105.121 - }
105.122 -
105.123 - @Override
105.124 - public boolean ensureDependency(Project p, String specification, boolean canShowUI) {
105.125 - ParsedDependency dep = Utilities.parseDependency(specification);
105.126 -
105.127 - return ensureDependency(p, dep.cnb, /*TODO: may null and that could put display name their*/specification, dep.releaseVersion, dep.specVersion, canShowUI);
105.128 - }
105.129 -
105.130 -}
106.1 --- a/bridges/apisupport/src/org/netbeans/modules/jackpot30/apisupport/Bundle.properties Fri Jan 27 13:35:56 2012 +0100
106.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
106.3 @@ -1,1 +0,0 @@
106.4 -OpenIDE-Module-Name=Jackpot 3.0 APISupport Bridge
107.1 --- a/bridges/apisupport/src/org/netbeans/modules/jackpot30/apisupport/HackyProjectDependencyUpgraderImpl.java Fri Jan 27 13:35:56 2012 +0100
107.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
107.3 @@ -1,107 +0,0 @@
107.4 -/*
107.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
107.6 - *
107.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
107.8 - *
107.9 - * The contents of this file are subject to the terms of either the GNU
107.10 - * General Public License Version 2 only ("GPL") or the Common
107.11 - * Development and Distribution License("CDDL") (collectively, the
107.12 - * "License"). You may not use this file except in compliance with the
107.13 - * License. You can obtain a copy of the License at
107.14 - * http://www.netbeans.org/cddl-gplv2.html
107.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
107.16 - * specific language governing permissions and limitations under the
107.17 - * License. When distributing the software, include this License Header
107.18 - * Notice in each file and include the License file at
107.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
107.20 - * particular file as subject to the "Classpath" exception as provided
107.21 - * by Sun in the GPL Version 2 section of the License file that
107.22 - * accompanied this code. If applicable, add the following below the
107.23 - * License Header, with the fields enclosed by brackets [] replaced by
107.24 - * your own identifying information:
107.25 - * "Portions Copyrighted [year] [name of copyright owner]"
107.26 - *
107.27 - * If you wish your version of this file to be governed by only the CDDL
107.28 - * or only the GPL Version 2, indicate your decision by adding
107.29 - * "[Contributor] elects to include this software in this distribution
107.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
107.31 - * single choice of license, a recipient has the option to distribute
107.32 - * your version of this file under either the CDDL, the GPL Version 2 or
107.33 - * to extend the choice of license to its licensees as provided above.
107.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
107.35 - * Version 2 license, then the option applies only if the new code is
107.36 - * made subject to such option by the copyright holder.
107.37 - *
107.38 - * Contributor(s):
107.39 - *
107.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
107.41 - */
107.42 -
107.43 -package org.netbeans.modules.jackpot30.apisupport;
107.44 -
107.45 -import java.io.File;
107.46 -import java.net.MalformedURLException;
107.47 -import java.net.URL;
107.48 -import java.net.URLClassLoader;
107.49 -import org.netbeans.api.project.Project;
107.50 -//import org.netbeans.modules.apisupport.project.api.DependencyUpdater;
107.51 -import org.netbeans.modules.java.hints.jackpot.spi.ProjectDependencyUpgrader;
107.52 -import org.openide.filesystems.FileObject;
107.53 -import org.openide.modules.InstalledFileLocator;
107.54 -import org.openide.modules.SpecificationVersion;
107.55 -import org.openide.util.Exceptions;
107.56 -import org.openide.util.Lookup;
107.57 -import org.openide.util.lookup.ServiceProvider;
107.58 -
107.59 -/**
107.60 - *
107.61 - * @author lahvac
107.62 - */
107.63 -public class HackyProjectDependencyUpgraderImpl extends ProjectDependencyUpgrader {
107.64 -
107.65 - public boolean ensureDependency(Project currentProject, FileObject depFO, SpecificationVersion spec, final boolean canShowUI) {
107.66 - File lib = InstalledFileLocator.getDefault().locate("modules/ext/org-netbeans-modules-jackpot30-apisupport.jar", null, false);
107.67 -
107.68 - ClassLoader scl = Lookup.getDefault().lookup(ClassLoader.class);
107.69 - try {
107.70 - URLClassLoader l = new URLClassLoader(new URL[]{lib.toURI().toURL()}, scl);
107.71 - Class<?> u = Class.forName("org.netbeans.modules.jackpot30.apisupport.bridgeimpl.ProjectDependencyUpgraderImpl", false, l);
107.72 -
107.73 - return ((ProjectDependencyUpgrader) u.newInstance()).ensureDependency(currentProject, depFO, spec, canShowUI);
107.74 - } catch (InstantiationException ex) {
107.75 - Exceptions.printStackTrace(ex);
107.76 - } catch (IllegalAccessException ex) {
107.77 - Exceptions.printStackTrace(ex);
107.78 - } catch (ClassNotFoundException ex) {
107.79 - Exceptions.printStackTrace(ex);
107.80 - } catch (MalformedURLException ex) {
107.81 - Exceptions.printStackTrace(ex);
107.82 - }
107.83 -
107.84 - return false;
107.85 - }
107.86 -
107.87 - @Override
107.88 - public boolean ensureDependency(Project p, String specification, boolean b) {
107.89 - File lib = InstalledFileLocator.getDefault().locate("modules/ext/org-netbeans-modules-jackpot30-apisupport.jar", null, false);
107.90 -
107.91 - ClassLoader scl = Lookup.getDefault().lookup(ClassLoader.class);
107.92 - try {
107.93 - URLClassLoader l = new URLClassLoader(new URL[]{lib.toURI().toURL()}, scl);
107.94 - Class<?> u = Class.forName("org.netbeans.modules.jackpot30.apisupport.bridgeimpl.ProjectDependencyUpgraderImpl", false, l);
107.95 -
107.96 - return ((ProjectDependencyUpgrader) u.newInstance()).ensureDependency(p, specification, b);
107.97 - } catch (InstantiationException ex) {
107.98 - Exceptions.printStackTrace(ex);
107.99 - } catch (IllegalAccessException ex) {
107.100 - Exceptions.printStackTrace(ex);
107.101 - } catch (ClassNotFoundException ex) {
107.102 - Exceptions.printStackTrace(ex);
107.103 - } catch (MalformedURLException ex) {
107.104 - Exceptions.printStackTrace(ex);
107.105 - }
107.106 -
107.107 - return false;
107.108 - }
107.109 -
107.110 -}
108.1 --- a/bridges/apisupport/src/org/netbeans/modules/jackpot30/apisupport/Installer.java Fri Jan 27 13:35:56 2012 +0100
108.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
108.3 @@ -1,70 +0,0 @@
108.4 -/*
108.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
108.6 - *
108.7 - * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
108.8 - *
108.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
108.10 - * Other names may be trademarks of their respective owners.
108.11 - *
108.12 - * The contents of this file are subject to the terms of either the GNU General
108.13 - * Public License Version 2 only ("GPL") or the Common Development and
108.14 - * Distribution License("CDDL") (collectively, the "License"). You may not use
108.15 - * this file except in compliance with the License. You can obtain a copy of the
108.16 - * License at http://www.netbeans.org/cddl-gplv2.html or
108.17 - * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
108.18 - * governing permissions and limitations under the License. When distributing
108.19 - * the software, include this License Header Notice in each file and include the
108.20 - * License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
108.21 - * particular file as subject to the "Classpath" exception as provided by Oracle
108.22 - * in the GPL Version 2 section of the License file that accompanied this code.
108.23 - * If applicable, add the following below the License Header, with the fields
108.24 - * enclosed by brackets [] replaced by your own identifying information:
108.25 - * "Portions Copyrighted [year] [name of copyright owner]"
108.26 - *
108.27 - * If you wish your version of this file to be governed by only the CDDL or only
108.28 - * the GPL Version 2, indicate your decision by adding "[Contributor] elects to
108.29 - * include this software in this distribution under the [CDDL or GPL Version 2]
108.30 - * license." If you do not indicate a single choice of license, a recipient has
108.31 - * the option to distribute your version of this file under either the CDDL, the
108.32 - * GPL Version 2 or to extend the choice of license to its licensees as provided
108.33 - * above. However, if you add GPL Version 2 code and therefore, elected the GPL
108.34 - * Version 2 license, then the option applies only if the new code is made
108.35 - * subject to such option by the copyright holder.
108.36 - *
108.37 - * Contributor(s):
108.38 - *
108.39 - * Portions Copyrighted 2011 Sun Microsystems, Inc.
108.40 - */
108.41 -package org.netbeans.modules.jackpot30.apisupport;
108.42 -
108.43 -import java.lang.reflect.Field;
108.44 -import java.lang.reflect.Method;
108.45 -import java.util.Set;
108.46 -import org.openide.modules.ModuleInstall;
108.47 -
108.48 -public class Installer extends ModuleInstall {
108.49 -
108.50 - @Override
108.51 - @SuppressWarnings("unchecked")
108.52 - public void validate() throws IllegalStateException {
108.53 - try {
108.54 - java.lang.Class main = java.lang.Class.forName("org.netbeans.core.startup.Main", false, //NOI18N
108.55 - Thread.currentThread().getContextClassLoader());
108.56 - Method getModuleSystem = main.getMethod("getModuleSystem", new Class[0]); //NOI18N
108.57 - Object moduleSystem = getModuleSystem.invoke(null, new Object[0]);
108.58 - Method getManager = moduleSystem.getClass().getMethod("getManager", new Class[0]); //NOI18N
108.59 - Object moduleManager = getManager.invoke(moduleSystem, new Object[0]);
108.60 - Method moduleMeth = moduleManager.getClass().getMethod("get", new Class[] {String.class}); //NOI18N
108.61 - Object persistence = moduleMeth.invoke(moduleManager, "org.netbeans.modules.apisupport.project"); //NOI18N
108.62 - if (persistence != null) {
108.63 - Field frField = persistence.getClass().getSuperclass().getDeclaredField("friendNames"); //NOI18N
108.64 - frField.setAccessible(true);
108.65 - Set friends = (Set)frField.get(persistence);
108.66 - friends.add("org.netbeans.modules.jackpot30.apisupport"); //NOI18N
108.67 - }
108.68 - } catch (Exception ex) {
108.69 - new IllegalStateException("Cannot fix dependencies for org.netbeans.modules.jackpot30.apisupport.", ex); //NOI18N
108.70 - }
108.71 - super.validate();
108.72 - }
108.73 -}
109.1 --- a/bridges/apisupport/src/org/netbeans/modules/jackpot30/apisupport/ProjectDependencyUpgraderMultiplexor.java Fri Jan 27 13:35:56 2012 +0100
109.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
109.3 @@ -1,63 +0,0 @@
109.4 -/*
109.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
109.6 - *
109.7 - * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
109.8 - *
109.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
109.10 - * Other names may be trademarks of their respective owners.
109.11 - *
109.12 - * The contents of this file are subject to the terms of either the GNU General
109.13 - * Public License Version 2 only ("GPL") or the Common Development and
109.14 - * Distribution License("CDDL") (collectively, the "License"). You may not use
109.15 - * this file except in compliance with the License. You can obtain a copy of the
109.16 - * License at http://www.netbeans.org/cddl-gplv2.html or
109.17 - * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
109.18 - * governing permissions and limitations under the License. When distributing
109.19 - * the software, include this License Header Notice in each file and include the
109.20 - * License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
109.21 - * particular file as subject to the "Classpath" exception as provided by Oracle
109.22 - * in the GPL Version 2 section of the License file that accompanied this code.
109.23 - * If applicable, add the following below the License Header, with the fields
109.24 - * enclosed by brackets [] replaced by your own identifying information:
109.25 - * "Portions Copyrighted [year] [name of copyright owner]"
109.26 - *
109.27 - * If you wish your version of this file to be governed by only the CDDL or only
109.28 - * the GPL Version 2, indicate your decision by adding "[Contributor] elects to
109.29 - * include this software in this distribution under the [CDDL or GPL Version 2]
109.30 - * license." If you do not indicate a single choice of license, a recipient has
109.31 - * the option to distribute your version of this file under either the CDDL, the
109.32 - * GPL Version 2 or to extend the choice of license to its licensees as provided
109.33 - * above. However, if you add GPL Version 2 code and therefore, elected the GPL
109.34 - * Version 2 license, then the option applies only if the new code is made
109.35 - * subject to such option by the copyright holder.
109.36 - *
109.37 - * Contributor(s):
109.38 - *
109.39 - * Portions Copyrighted 2011 Sun Microsystems, Inc.
109.40 - */
109.41 -package org.netbeans.modules.jackpot30.apisupport;
109.42 -
109.43 -import org.netbeans.api.project.Project;
109.44 -import org.netbeans.modules.java.hints.jackpot.spi.ProjectDependencyUpgrader;
109.45 -import org.openide.filesystems.FileObject;
109.46 -import org.openide.modules.SpecificationVersion;
109.47 -import org.openide.util.lookup.ServiceProvider;
109.48 -
109.49 -/**
109.50 - *
109.51 - * @author lahvac
109.52 - */
109.53 -@ServiceProvider(service=ProjectDependencyUpgrader.class)
109.54 -public class ProjectDependencyUpgraderMultiplexor extends ProjectDependencyUpgrader {
109.55 -
109.56 - @Override
109.57 - public boolean ensureDependency(Project p, FileObject dep, SpecificationVersion spec, boolean canShowUI) {
109.58 - return Utilities.UPGRADER.ensureDependency(p, dep, spec, canShowUI);
109.59 - }
109.60 -
109.61 - @Override
109.62 - public boolean ensureDependency(Project p, String specification, boolean b) {
109.63 - return Utilities.UPGRADER.ensureDependency(p, specification, b);
109.64 - }
109.65 -
109.66 -}
110.1 --- a/bridges/apisupport/src/org/netbeans/modules/jackpot30/apisupport/Utilities.java Fri Jan 27 13:35:56 2012 +0100
110.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
110.3 @@ -1,88 +0,0 @@
110.4 -/*
110.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
110.6 - *
110.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
110.8 - *
110.9 - * The contents of this file are subject to the terms of either the GNU
110.10 - * General Public License Version 2 only ("GPL") or the Common
110.11 - * Development and Distribution License("CDDL") (collectively, the
110.12 - * "License"). You may not use this file except in compliance with the
110.13 - * License. You can obtain a copy of the License at
110.14 - * http://www.netbeans.org/cddl-gplv2.html
110.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
110.16 - * specific language governing permissions and limitations under the
110.17 - * License. When distributing the software, include this License Header
110.18 - * Notice in each file and include the License file at
110.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
110.20 - * particular file as subject to the "Classpath" exception as provided
110.21 - * by Sun in the GPL Version 2 section of the License file that
110.22 - * accompanied this code. If applicable, add the following below the
110.23 - * License Header, with the fields enclosed by brackets [] replaced by
110.24 - * your own identifying information:
110.25 - * "Portions Copyrighted [year] [name of copyright owner]"
110.26 - *
110.27 - * If you wish your version of this file to be governed by only the CDDL
110.28 - * or only the GPL Version 2, indicate your decision by adding
110.29 - * "[Contributor] elects to include this software in this distribution
110.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
110.31 - * single choice of license, a recipient has the option to distribute
110.32 - * your version of this file under either the CDDL, the GPL Version 2 or
110.33 - * to extend the choice of license to its licensees as provided above.
110.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
110.35 - * Version 2 license, then the option applies only if the new code is
110.36 - * made subject to such option by the copyright holder.
110.37 - *
110.38 - * Contributor(s):
110.39 - *
110.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
110.41 - */
110.42 -
110.43 -package org.netbeans.modules.jackpot30.apisupport;
110.44 -
110.45 -import org.netbeans.modules.java.hints.jackpot.spi.ProjectDependencyUpgrader;
110.46 -import org.openide.modules.SpecificationVersion;
110.47 -
110.48 -/**
110.49 - *
110.50 - * @author lahvac
110.51 - */
110.52 -public class Utilities {
110.53 -
110.54 - public static final ProjectDependencyUpgrader UPGRADER = Boolean.getBoolean("jackpot.upgrade.apisupport.use.api") ? new APIProjectDependencyUpgraderImpl() : new HackyProjectDependencyUpgraderImpl();
110.55 -
110.56 - public static ParsedDependency parseDependency(String spec) {
110.57 - String cnb;
110.58 - String releaseVersion;
110.59 - SpecificationVersion specVersion;
110.60 -
110.61 - String[] spaceSplit = spec.split(" ");
110.62 - String[] slashSplit = spaceSplit[0].split(" ");
110.63 -
110.64 - cnb = slashSplit[0];
110.65 -
110.66 - if (slashSplit.length > 1) {
110.67 - releaseVersion = slashSplit[1];
110.68 - } else {
110.69 - releaseVersion = null;
110.70 - }
110.71 -
110.72 - if (spaceSplit.length > 1) {
110.73 - specVersion = new SpecificationVersion(spaceSplit[1]);//XXX verify correct format
110.74 - } else {
110.75 - specVersion = null;
110.76 - }
110.77 -
110.78 - return new ParsedDependency(cnb, releaseVersion, specVersion);
110.79 - }
110.80 -
110.81 - public static class ParsedDependency {
110.82 - public final String cnb;
110.83 - public final String releaseVersion;
110.84 - public final SpecificationVersion specVersion;
110.85 - public ParsedDependency(String cnb, String releaseVersion, SpecificationVersion specVersion) {
110.86 - this.cnb = cnb;
110.87 - this.releaseVersion = releaseVersion;
110.88 - this.specVersion = specVersion;
110.89 - }
110.90 - }
110.91 -}
111.1 --- a/bridges/refactoring/build.xml Fri Jan 27 13:35:56 2012 +0100
111.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
111.3 @@ -1,9 +0,0 @@
111.4 -<?xml version="1.0" encoding="UTF-8"?>
111.5 -<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
111.6 -<!-- for some information on what you could do (e.g. targets to override). -->
111.7 -<!-- If you delete this file and reopen the project it will be recreated. -->
111.8 -<project name="org.netbeans.modules.jackpot30.refactoring" default="netbeans" basedir=".">
111.9 - <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.refactoring.</description>
111.10 - <import file="nbproject/build-impl.xml"/>
111.11 - <import file="${suite.dir}/findbugs-import.xml"/>
111.12 -</project>
112.1 --- a/bridges/refactoring/manifest.mf Fri Jan 27 13:35:56 2012 +0100
112.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
112.3 @@ -1,6 +0,0 @@
112.4 -Manifest-Version: 1.0
112.5 -OpenIDE-Module: org.netbeans.modules.jackpot30.refactoring
112.6 -OpenIDE-Module-Implementation-Version: 1
112.7 -OpenIDE-Module-Layer: org/netbeans/modules/jackpot30/refactoring/layer.xml
112.8 -OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/refactoring/Bundle.properties
112.9 -
113.1 --- a/bridges/refactoring/nbproject/build-impl.xml Fri Jan 27 13:35:56 2012 +0100
113.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
113.3 @@ -1,45 +0,0 @@
113.4 -<?xml version="1.0" encoding="UTF-8"?>
113.5 -<!--
113.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
113.7 -*** EDIT ../build.xml INSTEAD ***
113.8 --->
113.9 -<project name="org.netbeans.modules.jackpot30.refactoring-impl" basedir="..">
113.10 - <fail message="Please build using Ant 1.7.1 or higher.">
113.11 - <condition>
113.12 - <not>
113.13 - <antversion atleast="1.7.1"/>
113.14 - </not>
113.15 - </condition>
113.16 - </fail>
113.17 - <property file="nbproject/private/suite-private.properties"/>
113.18 - <property file="nbproject/suite.properties"/>
113.19 - <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
113.20 - <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
113.21 - <property file="${suite.dir}/nbproject/platform.properties"/>
113.22 - <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
113.23 - <attribute name="name"/>
113.24 - <attribute name="value"/>
113.25 - <sequential>
113.26 - <property name="@{name}" value="${@{value}}"/>
113.27 - </sequential>
113.28 - </macrodef>
113.29 - <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
113.30 - <attribute name="property"/>
113.31 - <attribute name="value"/>
113.32 - <sequential>
113.33 - <property name="@{property}" value="@{value}"/>
113.34 - </sequential>
113.35 - </macrodef>
113.36 - <property file="${user.properties.file}"/>
113.37 - <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
113.38 - <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
113.39 - <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
113.40 - <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
113.41 - <condition>
113.42 - <not>
113.43 - <contains string="${cluster.path.evaluated}" substring="platform"/>
113.44 - </not>
113.45 - </condition>
113.46 - </fail>
113.47 - <import file="${harness.dir}/build.xml"/>
113.48 -</project>
114.1 --- a/bridges/refactoring/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
114.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
114.3 @@ -1,8 +0,0 @@
114.4 -build.xml.data.CRC32=46e4f14a
114.5 -build.xml.script.CRC32=4a0f84c4
114.6 -build.xml.stylesheet.CRC32=79c3b980@1.39
114.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
114.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
114.9 -nbproject/build-impl.xml.data.CRC32=2e452477
114.10 -nbproject/build-impl.xml.script.CRC32=fd9920c9
114.11 -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.49
115.1 --- a/bridges/refactoring/nbproject/project.properties Fri Jan 27 13:35:56 2012 +0100
115.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
115.3 @@ -1,4 +0,0 @@
115.4 -is.eager=true
115.5 -javac.source=1.6
115.6 -javac.compilerargs=-Xlint -Xlint:-serial
115.7 -spec.version.base=1.16.0
116.1 --- a/bridges/refactoring/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
116.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
116.3 @@ -1,199 +0,0 @@
116.4 -<?xml version="1.0" encoding="UTF-8"?>
116.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
116.6 - <type>org.netbeans.modules.apisupport.project</type>
116.7 - <configuration>
116.8 - <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
116.9 - <code-name-base>org.netbeans.modules.jackpot30.refactoring</code-name-base>
116.10 - <suite-component/>
116.11 - <module-dependencies>
116.12 - <dependency>
116.13 - <code-name-base>org.netbeans.api.annotations.common</code-name-base>
116.14 - <build-prerequisite/>
116.15 - <compile-dependency/>
116.16 - <run-dependency>
116.17 - <release-version>1</release-version>
116.18 - <specification-version>1.4</specification-version>
116.19 - </run-dependency>
116.20 - </dependency>
116.21 - <dependency>
116.22 - <code-name-base>org.netbeans.api.java.classpath</code-name-base>
116.23 - <build-prerequisite/>
116.24 - <compile-dependency/>
116.25 - <run-dependency>
116.26 - <release-version>1</release-version>
116.27 - <specification-version>1.24</specification-version>
116.28 - </run-dependency>
116.29 - </dependency>
116.30 - <dependency>
116.31 - <code-name-base>org.netbeans.libs.javacapi</code-name-base>
116.32 - <build-prerequisite/>
116.33 - <compile-dependency/>
116.34 - <run-dependency>
116.35 - <specification-version>0.12.0.1</specification-version>
116.36 - </run-dependency>
116.37 - </dependency>
116.38 - <dependency>
116.39 - <code-name-base>org.netbeans.modules.jackpot30.api</code-name-base>
116.40 - <build-prerequisite/>
116.41 - <compile-dependency/>
116.42 - <run-dependency>
116.43 - <specification-version>1.12</specification-version>
116.44 - </run-dependency>
116.45 - </dependency>
116.46 - <dependency>
116.47 - <code-name-base>org.netbeans.modules.java.hints</code-name-base>
116.48 - <build-prerequisite/>
116.49 - <compile-dependency/>
116.50 - <run-dependency>
116.51 - <release-version>1</release-version>
116.52 - <implementation-version/>
116.53 - </run-dependency>
116.54 - </dependency>
116.55 - <dependency>
116.56 - <code-name-base>org.netbeans.modules.java.source</code-name-base>
116.57 - <build-prerequisite/>
116.58 - <compile-dependency/>
116.59 - <run-dependency>
116.60 - <specification-version>0.57.0.9.8.4</specification-version>
116.61 - </run-dependency>
116.62 - </dependency>
116.63 - <dependency>
116.64 - <code-name-base>org.netbeans.modules.java.sourceui</code-name-base>
116.65 - <build-prerequisite/>
116.66 - <compile-dependency/>
116.67 - <run-dependency>
116.68 - <release-version>1</release-version>
116.69 - <specification-version>1.26.0.1.19</specification-version>
116.70 - </run-dependency>
116.71 - </dependency>
116.72 - <dependency>
116.73 - <code-name-base>org.netbeans.modules.queries</code-name-base>
116.74 - <build-prerequisite/>
116.75 - <compile-dependency/>
116.76 - <run-dependency>
116.77 - <release-version>1</release-version>
116.78 - <specification-version>1.18</specification-version>
116.79 - </run-dependency>
116.80 - </dependency>
116.81 - <dependency>
116.82 - <code-name-base>org.netbeans.modules.refactoring.api</code-name-base>
116.83 - <build-prerequisite/>
116.84 - <compile-dependency/>
116.85 - <run-dependency>
116.86 - <specification-version>1.10</specification-version>
116.87 - </run-dependency>
116.88 - </dependency>
116.89 - <dependency>
116.90 - <code-name-base>org.netbeans.modules.refactoring.java</code-name-base>
116.91 - <build-prerequisite/>
116.92 - <compile-dependency/>
116.93 - <run-dependency>
116.94 - <release-version>1</release-version>
116.95 - <implementation-version/>
116.96 - </run-dependency>
116.97 - </dependency>
116.98 - <dependency>
116.99 - <code-name-base>org.openide.awt</code-name-base>
116.100 - <build-prerequisite/>
116.101 - <compile-dependency/>
116.102 - <run-dependency>
116.103 - <specification-version>7.23</specification-version>
116.104 - </run-dependency>
116.105 - </dependency>
116.106 - <dependency>
116.107 - <code-name-base>org.openide.filesystems</code-name-base>
116.108 - <build-prerequisite/>
116.109 - <compile-dependency/>
116.110 - <run-dependency>
116.111 - <specification-version>7.36</specification-version>
116.112 - </run-dependency>
116.113 - </dependency>
116.114 - <dependency>
116.115 - <code-name-base>org.openide.loaders</code-name-base>
116.116 - <build-prerequisite/>
116.117 - <compile-dependency/>
116.118 - <run-dependency>
116.119 - <specification-version>7.16</specification-version>
116.120 - </run-dependency>
116.121 - </dependency>
116.122 - <dependency>
116.123 - <code-name-base>org.openide.nodes</code-name-base>
116.124 - <build-prerequisite/>
116.125 - <compile-dependency/>
116.126 - <run-dependency>
116.127 - <specification-version>7.16</specification-version>
116.128 - </run-dependency>
116.129 - </dependency>
116.130 - <dependency>
116.131 - <code-name-base>org.openide.text</code-name-base>
116.132 - <build-prerequisite/>
116.133 - <compile-dependency/>
116.134 - <run-dependency>
116.135 - <specification-version>6.29</specification-version>
116.136 - </run-dependency>
116.137 - </dependency>
116.138 - <dependency>
116.139 - <code-name-base>org.openide.util</code-name-base>
116.140 - <build-prerequisite/>
116.141 - <compile-dependency/>
116.142 - <run-dependency>
116.143 - <specification-version>8.2</specification-version>
116.144 - </run-dependency>
116.145 - </dependency>
116.146 - <dependency>
116.147 - <code-name-base>org.openide.util.lookup</code-name-base>
116.148 - <build-prerequisite/>
116.149 - <compile-dependency/>
116.150 - <run-dependency>
116.151 - <specification-version>8.2</specification-version>
116.152 - </run-dependency>
116.153 - </dependency>
116.154 - <dependency>
116.155 - <code-name-base>org.openide.windows</code-name-base>
116.156 - <build-prerequisite/>
116.157 - <compile-dependency/>
116.158 - <run-dependency>
116.159 - <specification-version>6.33</specification-version>
116.160 - </run-dependency>
116.161 - </dependency>
116.162 - </module-dependencies>
116.163 - <test-dependencies>
116.164 - <test-type>
116.165 - <name>unit</name>
116.166 - <test-dependency>
116.167 - <code-name-base>org.netbeans.libs.junit4</code-name-base>
116.168 - <compile-dependency/>
116.169 - </test-dependency>
116.170 - <test-dependency>
116.171 - <code-name-base>org.netbeans.modules.jackpot30.api</code-name-base>
116.172 - <recursive/>
116.173 - <compile-dependency/>
116.174 - <test/>
116.175 - </test-dependency>
116.176 - <test-dependency>
116.177 - <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
116.178 - <compile-dependency/>
116.179 - </test-dependency>
116.180 - <test-dependency>
116.181 - <code-name-base>org.netbeans.modules.java.hints.declarative</code-name-base>
116.182 - <compile-dependency/>
116.183 - </test-dependency>
116.184 - <test-dependency>
116.185 - <code-name-base>org.netbeans.modules.junit</code-name-base>
116.186 - <compile-dependency/>
116.187 - </test-dependency>
116.188 - <test-dependency>
116.189 - <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
116.190 - <recursive/>
116.191 - <compile-dependency/>
116.192 - </test-dependency>
116.193 - <test-dependency>
116.194 - <code-name-base>org.netbeans.modules.projectui</code-name-base>
116.195 - <compile-dependency/>
116.196 - </test-dependency>
116.197 - </test-type>
116.198 - </test-dependencies>
116.199 - <public-packages/>
116.200 - </data>
116.201 - </configuration>
116.202 -</project>
117.1 --- a/bridges/refactoring/nbproject/suite.properties Fri Jan 27 13:35:56 2012 +0100
117.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
117.3 @@ -1,1 +0,0 @@
117.4 -suite.dir=${basedir}/../..
118.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/Bundle.properties Fri Jan 27 13:35:56 2012 +0100
118.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
118.3 @@ -1,4 +0,0 @@
118.4 -OpenIDE-Module-Name=Jackpot 3.0 Refactoring Bridge
118.5 -GenerateScriptPanel.generate.text=Generate Jackpot script for automatic upgrade
118.6 -GenerateScriptPanel.makePrivate.text=Make existing element private
118.7 -GenerateScriptPanel.deprecate.text=Deprecate existing element
119.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/ExtraData.java Fri Jan 27 13:35:56 2012 +0100
119.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
119.3 @@ -1,58 +0,0 @@
119.4 -/*
119.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
119.6 - *
119.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
119.8 - *
119.9 - * The contents of this file are subject to the terms of either the GNU
119.10 - * General Public License Version 2 only ("GPL") or the Common
119.11 - * Development and Distribution License("CDDL") (collectively, the
119.12 - * "License"). You may not use this file except in compliance with the
119.13 - * License. You can obtain a copy of the License at
119.14 - * http://www.netbeans.org/cddl-gplv2.html
119.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
119.16 - * specific language governing permissions and limitations under the
119.17 - * License. When distributing the software, include this License Header
119.18 - * Notice in each file and include the License file at
119.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
119.20 - * particular file as subject to the "Classpath" exception as provided
119.21 - * by Sun in the GPL Version 2 section of the License file that
119.22 - * accompanied this code. If applicable, add the following below the
119.23 - * License Header, with the fields enclosed by brackets [] replaced by
119.24 - * your own identifying information:
119.25 - * "Portions Copyrighted [year] [name of copyright owner]"
119.26 - *
119.27 - * If you wish your version of this file to be governed by only the CDDL
119.28 - * or only the GPL Version 2, indicate your decision by adding
119.29 - * "[Contributor] elects to include this software in this distribution
119.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
119.31 - * single choice of license, a recipient has the option to distribute
119.32 - * your version of this file under either the CDDL, the GPL Version 2 or
119.33 - * to extend the choice of license to its licensees as provided above.
119.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
119.35 - * Version 2 license, then the option applies only if the new code is
119.36 - * made subject to such option by the copyright holder.
119.37 - *
119.38 - * Contributor(s):
119.39 - *
119.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
119.41 - */
119.42 -
119.43 -package org.netbeans.modules.jackpot30.refactoring;
119.44 -
119.45 -/**
119.46 - *
119.47 - * @author lahvac
119.48 - */
119.49 -public final class ExtraData {
119.50 -
119.51 - public final boolean generateUpgradeScript;
119.52 - public final boolean makeOriginalPrivate;
119.53 - public final boolean makeOriginalDeprecated;
119.54 -
119.55 - public ExtraData(boolean generateUpgradeScript, boolean makeOriginalPrivate, boolean makeOriginalDeprecated) {
119.56 - this.generateUpgradeScript = generateUpgradeScript;
119.57 - this.makeOriginalPrivate = makeOriginalPrivate;
119.58 - this.makeOriginalDeprecated = makeOriginalDeprecated;
119.59 - }
119.60 -
119.61 -}
120.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/GenerateScriptPanel.form Fri Jan 27 13:35:56 2012 +0100
120.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
120.3 @@ -1,77 +0,0 @@
120.4 -<?xml version="1.0" encoding="UTF-8" ?>
120.5 -
120.6 -<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
120.7 - <AuxValues>
120.8 - <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
120.9 - <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
120.10 - <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
120.11 - <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
120.12 - <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
120.13 - <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
120.14 - <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
120.15 - <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
120.16 - <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
120.17 - </AuxValues>
120.18 -
120.19 - <Layout>
120.20 - <DimensionLayout dim="0">
120.21 - <Group type="103" groupAlignment="0" attributes="0">
120.22 - <Group type="102" attributes="0">
120.23 - <Group type="103" groupAlignment="0" attributes="0">
120.24 - <Group type="102" alignment="0" attributes="0">
120.25 - <EmptySpace min="-2" pref="29" max="-2" attributes="0"/>
120.26 - <Group type="103" groupAlignment="0" attributes="0">
120.27 - <Component id="deprecate" alignment="0" min="-2" max="-2" attributes="0"/>
120.28 - <Component id="makePrivate" alignment="0" min="-2" max="-2" attributes="0"/>
120.29 - </Group>
120.30 - </Group>
120.31 - <Group type="102" alignment="0" attributes="0">
120.32 - <EmptySpace max="-2" attributes="0"/>
120.33 - <Component id="generate" min="-2" max="-2" attributes="0"/>
120.34 - </Group>
120.35 - </Group>
120.36 - <EmptySpace pref="79" max="32767" attributes="0"/>
120.37 - </Group>
120.38 - </Group>
120.39 - </DimensionLayout>
120.40 - <DimensionLayout dim="1">
120.41 - <Group type="103" groupAlignment="0" attributes="0">
120.42 - <Group type="102" alignment="0" attributes="0">
120.43 - <EmptySpace max="-2" attributes="0"/>
120.44 - <Component id="generate" min="-2" max="-2" attributes="0"/>
120.45 - <EmptySpace max="-2" attributes="0"/>
120.46 - <Component id="makePrivate" min="-2" max="-2" attributes="0"/>
120.47 - <EmptySpace max="-2" attributes="0"/>
120.48 - <Component id="deprecate" min="-2" max="-2" attributes="0"/>
120.49 - <EmptySpace pref="223" max="32767" attributes="0"/>
120.50 - </Group>
120.51 - </Group>
120.52 - </DimensionLayout>
120.53 - </Layout>
120.54 - <SubComponents>
120.55 - <Component class="javax.swing.JCheckBox" name="generate">
120.56 - <Properties>
120.57 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
120.58 - <ResourceString bundle="org/netbeans/modules/jackpot30/refactoring/Bundle.properties" key="GenerateScriptPanel.generate.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
120.59 - </Property>
120.60 - </Properties>
120.61 - <Events>
120.62 - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="generateActionPerformed"/>
120.63 - </Events>
120.64 - </Component>
120.65 - <Component class="javax.swing.JCheckBox" name="makePrivate">
120.66 - <Properties>
120.67 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
120.68 - <ResourceString bundle="org/netbeans/modules/jackpot30/refactoring/Bundle.properties" key="GenerateScriptPanel.makePrivate.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
120.69 - </Property>
120.70 - </Properties>
120.71 - </Component>
120.72 - <Component class="javax.swing.JCheckBox" name="deprecate">
120.73 - <Properties>
120.74 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
120.75 - <ResourceString bundle="org/netbeans/modules/jackpot30/refactoring/Bundle.properties" key="GenerateScriptPanel.deprecate.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
120.76 - </Property>
120.77 - </Properties>
120.78 - </Component>
120.79 - </SubComponents>
120.80 -</Form>
121.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/GenerateScriptPanel.java Fri Jan 27 13:35:56 2012 +0100
121.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
121.3 @@ -1,174 +0,0 @@
121.4 -/*
121.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
121.6 - *
121.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
121.8 - *
121.9 - * The contents of this file are subject to the terms of either the GNU
121.10 - * General Public License Version 2 only ("GPL") or the Common
121.11 - * Development and Distribution License("CDDL") (collectively, the
121.12 - * "License"). You may not use this file except in compliance with the
121.13 - * License. You can obtain a copy of the License at
121.14 - * http://www.netbeans.org/cddl-gplv2.html
121.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
121.16 - * specific language governing permissions and limitations under the
121.17 - * License. When distributing the software, include this License Header
121.18 - * Notice in each file and include the License file at
121.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
121.20 - * particular file as subject to the "Classpath" exception as provided
121.21 - * by Sun in the GPL Version 2 section of the License file that
121.22 - * accompanied this code. If applicable, add the following below the
121.23 - * License Header, with the fields enclosed by brackets [] replaced by
121.24 - * your own identifying information:
121.25 - * "Portions Copyrighted [year] [name of copyright owner]"
121.26 - *
121.27 - * If you wish your version of this file to be governed by only the CDDL
121.28 - * or only the GPL Version 2, indicate your decision by adding
121.29 - * "[Contributor] elects to include this software in this distribution
121.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
121.31 - * single choice of license, a recipient has the option to distribute
121.32 - * your version of this file under either the CDDL, the GPL Version 2 or
121.33 - * to extend the choice of license to its licensees as provided above.
121.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
121.35 - * Version 2 license, then the option applies only if the new code is
121.36 - * made subject to such option by the copyright holder.
121.37 - *
121.38 - * Contributor(s):
121.39 - *
121.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
121.41 - */
121.42 -package org.netbeans.modules.jackpot30.refactoring;
121.43 -
121.44 -import java.util.prefs.Preferences;
121.45 -import org.openide.util.NbPreferences;
121.46 -
121.47 -/**
121.48 - *
121.49 - * @author lahvac
121.50 - */
121.51 -public class GenerateScriptPanel extends javax.swing.JPanel {
121.52 -
121.53 - private final boolean supported;
121.54 -
121.55 - public GenerateScriptPanel(boolean supported) {
121.56 - this.supported = supported;
121.57 - initComponents();
121.58 - loadDefaults();
121.59 - }
121.60 -
121.61 - /** This method is called from within the constructor to
121.62 - * initialize the form.
121.63 - * WARNING: Do NOT modify this code. The content of this method is
121.64 - * always regenerated by the Form Editor.
121.65 - */
121.66 - @SuppressWarnings("unchecked")
121.67 - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
121.68 - private void initComponents() {
121.69 -
121.70 - generate = new javax.swing.JCheckBox();
121.71 - makePrivate = new javax.swing.JCheckBox();
121.72 - deprecate = new javax.swing.JCheckBox();
121.73 -
121.74 - generate.setText(org.openide.util.NbBundle.getMessage(GenerateScriptPanel.class, "GenerateScriptPanel.generate.text")); // NOI18N
121.75 - generate.addActionListener(new java.awt.event.ActionListener() {
121.76 - public void actionPerformed(java.awt.event.ActionEvent evt) {
121.77 - generateActionPerformed(evt);
121.78 - }
121.79 - });
121.80 -
121.81 - makePrivate.setText(org.openide.util.NbBundle.getMessage(GenerateScriptPanel.class, "GenerateScriptPanel.makePrivate.text")); // NOI18N
121.82 -
121.83 - deprecate.setText(org.openide.util.NbBundle.getMessage(GenerateScriptPanel.class, "GenerateScriptPanel.deprecate.text")); // NOI18N
121.84 -
121.85 - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
121.86 - this.setLayout(layout);
121.87 - layout.setHorizontalGroup(
121.88 - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
121.89 - .addGroup(layout.createSequentialGroup()
121.90 - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
121.91 - .addGroup(layout.createSequentialGroup()
121.92 - .addGap(29, 29, 29)
121.93 - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
121.94 - .addComponent(deprecate)
121.95 - .addComponent(makePrivate)))
121.96 - .addGroup(layout.createSequentialGroup()
121.97 - .addContainerGap()
121.98 - .addComponent(generate)))
121.99 - .addContainerGap(79, Short.MAX_VALUE))
121.100 - );
121.101 - layout.setVerticalGroup(
121.102 - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
121.103 - .addGroup(layout.createSequentialGroup()
121.104 - .addContainerGap()
121.105 - .addComponent(generate)
121.106 - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
121.107 - .addComponent(makePrivate)
121.108 - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
121.109 - .addComponent(deprecate)
121.110 - .addContainerGap(223, Short.MAX_VALUE))
121.111 - );
121.112 - }// </editor-fold>//GEN-END:initComponents
121.113 -
121.114 - private void generateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generateActionPerformed
121.115 - updateState();
121.116 - }//GEN-LAST:event_generateActionPerformed
121.117 -
121.118 - private static final String KEY_DO_GENERATE_SCRIPT = "generate-script";
121.119 - private static final boolean DEF_DO_GENERATE_SCRIPT = true;
121.120 - private static final String KEY_MAKE_PRIVATE = "make-private";
121.121 - private static final boolean DEF_MAKE_PRIVATE = true;
121.122 - private static final String KEY_DEPRECATE = "deprecate";
121.123 - private static final boolean DEF_DEPRECATE = false;
121.124 -
121.125 - private Preferences getPreferencesStorage() {
121.126 - return NbPreferences.forModule(GenerateScriptPanel.class).node(GenerateScriptPanel.class.getSimpleName());
121.127 - }
121.128 -
121.129 - private void loadDefaults() {
121.130 - if (supported) {
121.131 - Preferences p = getPreferencesStorage();
121.132 - generate.setSelected(p.getBoolean(KEY_DO_GENERATE_SCRIPT, DEF_DO_GENERATE_SCRIPT));
121.133 - makePrivate.setSelected(p.getBoolean(KEY_MAKE_PRIVATE, DEF_MAKE_PRIVATE));
121.134 - deprecate.setSelected(p.getBoolean(KEY_DEPRECATE, DEF_DEPRECATE));
121.135 - } else {
121.136 - generate.setSelected(false);
121.137 - makePrivate.setSelected(false);
121.138 - deprecate.setSelected(false);
121.139 - }
121.140 -
121.141 - updateState();
121.142 - }
121.143 -
121.144 - public void saveDefaults() {
121.145 - Preferences p = getPreferencesStorage();
121.146 - boolean doGenerate = generate.isSelected();
121.147 -
121.148 - p.putBoolean(KEY_DO_GENERATE_SCRIPT, doGenerate);
121.149 -
121.150 - if (doGenerate) {
121.151 - p.putBoolean(KEY_MAKE_PRIVATE, makePrivate.isSelected());
121.152 - p.putBoolean(KEY_DEPRECATE, deprecate.isSelected());
121.153 - }
121.154 - }
121.155 -
121.156 - private void updateState() {
121.157 - if (supported) {
121.158 - generate.setEnabled(true);
121.159 - makePrivate.setEnabled(generate.isSelected());
121.160 - deprecate.setEnabled(generate.isSelected());
121.161 - } else {
121.162 - generate.setEnabled(false);
121.163 - makePrivate.setEnabled(false);
121.164 - deprecate.setEnabled(false);
121.165 - }
121.166 - }
121.167 -
121.168 - // Variables declaration - do not modify//GEN-BEGIN:variables
121.169 - private javax.swing.JCheckBox deprecate;
121.170 - private javax.swing.JCheckBox generate;
121.171 - private javax.swing.JCheckBox makePrivate;
121.172 - // End of variables declaration//GEN-END:variables
121.173 -
121.174 - public ExtraData getData() {
121.175 - return new ExtraData(generate.isSelected(), makePrivate.isSelected(), deprecate.isSelected());
121.176 - }
121.177 -}
122.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/RefactoringActionsProviderExt.java Fri Jan 27 13:35:56 2012 +0100
122.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
122.3 @@ -1,238 +0,0 @@
122.4 -/*
122.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
122.6 - *
122.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
122.8 - *
122.9 - * The contents of this file are subject to the terms of either the GNU
122.10 - * General Public License Version 2 only ("GPL") or the Common
122.11 - * Development and Distribution License("CDDL") (collectively, the
122.12 - * "License"). You may not use this file except in compliance with the
122.13 - * License. You can obtain a copy of the License at
122.14 - * http://www.netbeans.org/cddl-gplv2.html
122.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
122.16 - * specific language governing permissions and limitations under the
122.17 - * License. When distributing the software, include this License Header
122.18 - * Notice in each file and include the License file at
122.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
122.20 - * particular file as subject to the "Classpath" exception as provided
122.21 - * by Sun in the GPL Version 2 section of the License file that
122.22 - * accompanied this code. If applicable, add the following below the
122.23 - * License Header, with the fields enclosed by brackets [] replaced by
122.24 - * your own identifying information:
122.25 - * "Portions Copyrighted [year] [name of copyright owner]"
122.26 - *
122.27 - * If you wish your version of this file to be governed by only the CDDL
122.28 - * or only the GPL Version 2, indicate your decision by adding
122.29 - * "[Contributor] elects to include this software in this distribution
122.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
122.31 - * single choice of license, a recipient has the option to distribute
122.32 - * your version of this file under either the CDDL, the GPL Version 2 or
122.33 - * to extend the choice of license to its licensees as provided above.
122.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
122.35 - * Version 2 license, then the option applies only if the new code is
122.36 - * made subject to such option by the copyright holder.
122.37 - *
122.38 - * Contributor(s):
122.39 - *
122.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
122.41 - */
122.42 -package org.netbeans.modules.jackpot30.refactoring;
122.43 -
122.44 -import java.util.Collection;
122.45 -import java.util.HashSet;
122.46 -import java.util.logging.Logger;
122.47 -import javax.lang.model.element.Element;
122.48 -import javax.lang.model.element.ElementKind;
122.49 -import javax.lang.model.element.ExecutableElement;
122.50 -import javax.lang.model.element.VariableElement;
122.51 -import javax.lang.model.type.TypeKind;
122.52 -import org.netbeans.api.java.source.CompilationInfo;
122.53 -import org.netbeans.api.java.source.TreePathHandle;
122.54 -import org.netbeans.api.java.source.ui.ScanDialog;
122.55 -import org.netbeans.modules.jackpot30.refactoring.invertboolean.InvertBooleanRefactoringUI;
122.56 -import org.netbeans.modules.jackpot30.refactoring.noconstructor.ReplaceConstructorRefactoringUI;
122.57 -import org.netbeans.modules.refactoring.api.RenameRefactoring;
122.58 -import org.netbeans.modules.refactoring.java.RefactoringUtils;
122.59 -import org.netbeans.modules.refactoring.java.ui.RefactoringActionsProvider;
122.60 -import org.netbeans.modules.refactoring.spi.ui.ActionsImplementationProvider;
122.61 -import org.netbeans.modules.refactoring.spi.ui.RefactoringUI;
122.62 -import org.openide.cookies.EditorCookie;
122.63 -import org.openide.filesystems.FileObject;
122.64 -import org.openide.loaders.DataObject;
122.65 -import org.openide.nodes.Node;
122.66 -import org.openide.text.CloneableEditorSupport;
122.67 -import org.openide.util.Lookup;
122.68 -import org.openide.util.lookup.ServiceProvider;
122.69 -import org.openide.windows.TopComponent;
122.70 -
122.71 -
122.72 -/**
122.73 - *
122.74 - * @author lahvac
122.75 - */
122.76 -@ServiceProvider(service=ActionsImplementationProvider.class, supersedes="org.netbeans.modules.refactoring.java.ui.RefactoringActionsProvider")
122.77 -public class RefactoringActionsProviderExt extends RefactoringActionsProvider {
122.78 -
122.79 - private static RefactoringUI doReplaceConstructorImpl(TreePathHandle selectedElement, CompilationInfo info) {
122.80 - Element selected = selectedElement.resolveElement(info);
122.81 - if (selected==null) {
122.82 -// logger().log(Level.INFO, "doRename: " + selectedElement, new NullPointerException("selected")); // NOI18N
122.83 - return null;
122.84 - }
122.85 - if (selected.getKind() == ElementKind.CONSTRUCTOR) {
122.86 - return new ReplaceConstructorRefactoringUI(selectedElement);
122.87 - }
122.88 -
122.89 - return null;
122.90 - }
122.91 -
122.92 - public static void doReplaceConstructor(final Lookup lookup) {
122.93 - Runnable task;
122.94 - EditorCookie ec = lookup.lookup(EditorCookie.class);
122.95 - if (isFromEditor(ec)) {
122.96 - task = new TextComponentTask(ec) {
122.97 - @Override
122.98 - protected RefactoringUI createRefactoringUI(TreePathHandle selectedElement,int startOffset,int endOffset, final CompilationInfo info) {
122.99 - return doReplaceConstructorImpl(selectedElement, info);
122.100 - }
122.101 - };
122.102 - } else {
122.103 - task = new TreePathHandleTask(new HashSet<Node>(lookup.lookupAll(Node.class)), true) {
122.104 -
122.105 - RefactoringUI ui;
122.106 -
122.107 - @Override
122.108 - protected void treePathHandleResolved(TreePathHandle handle, CompilationInfo javac) {
122.109 - ui = doReplaceConstructorImpl(handle, javac);
122.110 - }
122.111 -
122.112 - @Override
122.113 - protected RefactoringUI createRefactoringUI(Collection<TreePathHandle> handles) {
122.114 - return ui;
122.115 - }
122.116 -
122.117 - };
122.118 - }
122.119 -
122.120 - ScanDialog.runWhenScanFinished(task, "Remove Constructor");//getActionName(RefactoringActionsFactory.renameAction()));
122.121 - }
122.122 -
122.123 - private static RefactoringUI doInvertBooleanImpl(TreePathHandle selectedElement, CompilationInfo info) {
122.124 - Element selected = selectedElement.resolveElement(info);
122.125 - if (selected==null) {
122.126 -// logger().log(Level.INFO, "doRename: " + selectedElement, new NullPointerException("selected")); // NOI18N
122.127 - return null;
122.128 - }
122.129 - if (selected.getKind().isField() && ((VariableElement) selected).asType().getKind() == TypeKind.BOOLEAN) {
122.130 - return new InvertBooleanRefactoringUI(selectedElement, ((VariableElement) selected).getSimpleName().toString());
122.131 - }
122.132 - if (selected.getKind() == ElementKind.METHOD && ((ExecutableElement) selected).getReturnType().getKind() == TypeKind.BOOLEAN) {
122.133 - return new InvertBooleanRefactoringUI(selectedElement, ((ExecutableElement) selected).getSimpleName().toString());
122.134 - }
122.135 -
122.136 - return null;
122.137 - }
122.138 -
122.139 - public static void doInvertBoolean(final Lookup lookup) {
122.140 - Runnable task;
122.141 - EditorCookie ec = lookup.lookup(EditorCookie.class);
122.142 - if (isFromEditor(ec)) {
122.143 - task = new TextComponentTask(ec) {
122.144 - @Override
122.145 - protected RefactoringUI createRefactoringUI(TreePathHandle selectedElement,int startOffset,int endOffset, final CompilationInfo info) {
122.146 - return doInvertBooleanImpl(selectedElement, info);
122.147 - }
122.148 - };
122.149 - } else {
122.150 - task = new TreePathHandleTask(new HashSet<Node>(lookup.lookupAll(Node.class)), true) {
122.151 -
122.152 - RefactoringUI ui;
122.153 -
122.154 - @Override
122.155 - protected void treePathHandleResolved(TreePathHandle handle, CompilationInfo javac) {
122.156 - ui = doInvertBooleanImpl(handle, javac);
122.157 - }
122.158 -
122.159 - @Override
122.160 - protected RefactoringUI createRefactoringUI(Collection<TreePathHandle> handles) {
122.161 - return ui;
122.162 - }
122.163 -
122.164 - };
122.165 - }
122.166 -
122.167 - ScanDialog.runWhenScanFinished(task, "Remove Constructor");//getActionName(RefactoringActionsFactory.renameAction()));
122.168 - }
122.169 -
122.170 -// static String getActionName(Action action) {
122.171 -// String arg = (String) action.getValue(Action.NAME);
122.172 -// arg = arg.replace("&", ""); // NOI18N
122.173 -// return arg.replace("...", ""); // NOI18N
122.174 -// }
122.175 -
122.176 -
122.177 - public static boolean canReplaceConstructor(Lookup lookup) {
122.178 - return canRefactor(lookup);
122.179 - }
122.180 -
122.181 - public static boolean canInvertBoolean(Lookup lookup) {
122.182 - return canRefactor(lookup);
122.183 - }
122.184 -
122.185 - private static boolean canRefactor(Lookup lookup) {
122.186 - Collection<? extends Node> nodes = new HashSet<Node>(lookup.lookupAll(Node.class));
122.187 - if(nodes.size() != 1)
122.188 - return false;
122.189 - Node node = nodes.iterator().next();
122.190 - TreePathHandle tph = node.getLookup().lookup(TreePathHandle.class);
122.191 - if (tph != null) {
122.192 - return RefactoringUtils.isRefactorable(tph.getFileObject());
122.193 - }
122.194 - DataObject dObj = node.getCookie(DataObject.class);
122.195 - if(null == dObj)
122.196 - return false;
122.197 - FileObject fileObj = dObj.getPrimaryFile();
122.198 - if(null == fileObj || !RefactoringUtils.isRefactorable(fileObj))
122.199 - return false;
122.200 -
122.201 - EditorCookie ec = lookup.lookup(EditorCookie.class);
122.202 - if (isFromEditor(ec)) {
122.203 - return true;
122.204 - }
122.205 - return false;
122.206 - }
122.207 -
122.208 - @Override
122.209 - protected RefactoringUI wrap(RefactoringUI orig) {
122.210 - if (orig.getRefactoring() instanceof RenameRefactoring) {
122.211 - return new RenameRefactoringWrapper(orig, ((RenameRefactoring) orig.getRefactoring()));
122.212 - }
122.213 -
122.214 - return super.wrap(orig);
122.215 - }
122.216 -
122.217 -
122.218 - //XXX: copied from RefactoringActionsProvider:\
122.219 - static boolean isFromEditor(EditorCookie ec) {
122.220 - if (ec != null && ec.getOpenedPanes() != null) {
122.221 - TopComponent activetc = TopComponent.getRegistry().getActivated();
122.222 - if (activetc instanceof CloneableEditorSupport.Pane) {
122.223 - return true;
122.224 - }
122.225 - }
122.226 - return false;
122.227 - }
122.228 -
122.229 - static boolean nodeHandle(Lookup lookup) {
122.230 - Node n = lookup.lookup(Node.class);
122.231 - if (n!=null) {
122.232 - if (n.getLookup().lookup(TreePathHandle.class)!=null)
122.233 - return true;
122.234 - }
122.235 - return false;
122.236 - }
122.237 -
122.238 - private static Logger logger() {
122.239 - return Logger.getLogger(RefactoringActionsProvider.class.getName());
122.240 - }
122.241 -}
123.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/RefactoringElementImpl.java Fri Jan 27 13:35:56 2012 +0100
123.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
123.3 @@ -1,227 +0,0 @@
123.4 -/*
123.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
123.6 - *
123.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
123.8 - *
123.9 - * The contents of this file are subject to the terms of either the GNU
123.10 - * General Public License Version 2 only ("GPL") or the Common
123.11 - * Development and Distribution License("CDDL") (collectively, the
123.12 - * "License"). You may not use this file except in compliance with the
123.13 - * License. You can obtain a copy of the License at
123.14 - * http://www.netbeans.org/cddl-gplv2.html
123.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
123.16 - * specific language governing permissions and limitations under the
123.17 - * License. When distributing the software, include this License Header
123.18 - * Notice in each file and include the License file at
123.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
123.20 - * particular file as subject to the "Classpath" exception as provided
123.21 - * by Sun in the GPL Version 2 section of the License file that
123.22 - * accompanied this code. If applicable, add the following below the
123.23 - * License Header, with the fields enclosed by brackets [] replaced by
123.24 - * your own identifying information:
123.25 - * "Portions Copyrighted [year] [name of copyright owner]"
123.26 - *
123.27 - * If you wish your version of this file to be governed by only the CDDL
123.28 - * or only the GPL Version 2, indicate your decision by adding
123.29 - * "[Contributor] elects to include this software in this distribution
123.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
123.31 - * single choice of license, a recipient has the option to distribute
123.32 - * your version of this file under either the CDDL, the GPL Version 2 or
123.33 - * to extend the choice of license to its licensees as provided above.
123.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
123.35 - * Version 2 license, then the option applies only if the new code is
123.36 - * made subject to such option by the copyright holder.
123.37 - *
123.38 - * Contributor(s):
123.39 - *
123.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
123.41 - */
123.42 -
123.43 -package org.netbeans.modules.jackpot30.refactoring;
123.44 -
123.45 -import java.io.File;
123.46 -import java.io.FileInputStream;
123.47 -import java.io.IOException;
123.48 -import java.io.InputStreamReader;
123.49 -import java.io.OutputStreamWriter;
123.50 -import java.io.Reader;
123.51 -import java.io.Writer;
123.52 -import java.nio.charset.Charset;
123.53 -import org.netbeans.api.queries.FileEncodingQuery;
123.54 -import org.netbeans.modules.refactoring.spi.BackupFacility;
123.55 -import org.netbeans.modules.refactoring.spi.BackupFacility.Handle;
123.56 -import org.netbeans.modules.refactoring.spi.SimpleRefactoringElementImplementation;
123.57 -import org.openide.filesystems.FileObject;
123.58 -import org.openide.filesystems.FileUtil;
123.59 -import org.openide.text.PositionBounds;
123.60 -import org.openide.util.Exceptions;
123.61 -import org.openide.util.Lookup;
123.62 -
123.63 -/**
123.64 - *
123.65 - * @author lahvac
123.66 - */
123.67 -public class RefactoringElementImpl extends SimpleRefactoringElementImplementation {
123.68 -
123.69 - private final File target;
123.70 - private final String rule;
123.71 -
123.72 - public RefactoringElementImpl(File target, String rule) {
123.73 - this.target = target;
123.74 - this.rule = rule;
123.75 - }
123.76 -
123.77 - @Override
123.78 - public String getText() {
123.79 - return "Jackpot 3.0 rule";
123.80 - }
123.81 -
123.82 - @Override
123.83 - public String getDisplayText() {
123.84 - return "Jackpot 3.0 rule";
123.85 - }
123.86 -
123.87 - private Handle backup;
123.88 -
123.89 - @Override
123.90 - public void performChange() {
123.91 - try {
123.92 - FileObject fo = FileUtil.toFileObject(target);
123.93 - Charset encoding = FileEncodingQuery.getEncoding(getParentFile());
123.94 - String current;
123.95 -
123.96 - if (fo != null) {
123.97 - backup = BackupFacility.getDefault().backup(fo);
123.98 - current = read(target, encoding).toString();
123.99 - } else {
123.100 - if (!target.exists()) {
123.101 - backup = new Handle() {
123.102 - @Override
123.103 - public void restore() throws IOException {
123.104 - FileObject fo = FileUtil.toFileObject(target);
123.105 -
123.106 - fo.delete();
123.107 - }
123.108 - };
123.109 - current = "";
123.110 - } else {
123.111 - //XXX: log
123.112 - current = read(target, encoding).toString();
123.113 - }
123.114 - }
123.115 -
123.116 - current += rule;
123.117 - current += "\n";
123.118 -
123.119 - write(target, encoding, current);
123.120 - } catch (IOException ex) {
123.121 - Exceptions.printStackTrace(ex);
123.122 - }
123.123 - }
123.124 -
123.125 - @Override
123.126 - public void undoChange() {
123.127 - if (backup != null) {
123.128 - try {
123.129 - backup.restore();
123.130 - } catch (IOException ex) {
123.131 - Exceptions.printStackTrace(ex);
123.132 - }
123.133 - }
123.134 - backup = null;
123.135 - }
123.136 -
123.137 - @Override
123.138 - protected String getNewFileContent() {
123.139 - try {
123.140 - Charset encoding = FileEncodingQuery.getEncoding(getParentFile());
123.141 - String current;
123.142 -
123.143 - if (!target.exists()) {
123.144 - current = "";
123.145 - } else {
123.146 - //XXX: log
123.147 - current = read(target, encoding).toString();
123.148 - }
123.149 -
123.150 - current += rule;
123.151 - current += "\n";
123.152 -
123.153 - return current;
123.154 - } catch (IOException ex) {
123.155 - Exceptions.printStackTrace(ex);
123.156 - return null;
123.157 - }
123.158 - }
123.159 -
123.160 - @Override
123.161 - public Lookup getLookup() {
123.162 - return Lookup.EMPTY;
123.163 - }
123.164 -
123.165 - @Override
123.166 - public FileObject getParentFile() {
123.167 - File f = target;
123.168 -
123.169 - while (true) {
123.170 - FileObject fo = FileUtil.toFileObject(f);
123.171 -
123.172 - if (fo != null) {
123.173 - return fo;
123.174 - }
123.175 -
123.176 - f = f.getParentFile();
123.177 - }
123.178 - }
123.179 -
123.180 - @Override
123.181 - public PositionBounds getPosition() {
123.182 - //XXX:
123.183 - return null;
123.184 - }
123.185 -
123.186 - private CharSequence read(File f, Charset encoding) throws IOException {
123.187 - Reader in = null;
123.188 - StringBuilder result = new StringBuilder();
123.189 -
123.190 - try {
123.191 - in = new InputStreamReader(new FileInputStream(f), encoding);
123.192 -
123.193 - int r;
123.194 -
123.195 - while ((r = in.read()) != (-1)) {
123.196 - result.append((char) r);
123.197 - }
123.198 - } finally {
123.199 - if (in != null) {
123.200 - try {
123.201 - in.close();
123.202 - } catch (IOException ex) {
123.203 - Exceptions.printStackTrace(ex);
123.204 - }
123.205 - }
123.206 - }
123.207 -
123.208 - return result;
123.209 - }
123.210 -
123.211 - private void write(File f, Charset encoding, CharSequence text) throws IOException {
123.212 - Writer out = null;
123.213 -
123.214 - try {
123.215 - FileObject fo = FileUtil.createData(f);
123.216 - out = new OutputStreamWriter(fo.getOutputStream(), encoding);
123.217 -
123.218 - out.write(text.toString());
123.219 - } finally {
123.220 - if (out != null) {
123.221 - try {
123.222 - out.close();
123.223 - } catch (IOException ex) {
123.224 - Exceptions.printStackTrace(ex);
123.225 - }
123.226 - }
123.227 - }
123.228 - }
123.229 -
123.230 -}
124.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/RefactoringPluginFactoryImpl.java Fri Jan 27 13:35:56 2012 +0100
124.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
124.3 @@ -1,75 +0,0 @@
124.4 -/*
124.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
124.6 - *
124.7 - * Copyright 2008-2010 Sun Microsystems, Inc. All rights reserved.
124.8 - *
124.9 - * The contents of this file are subject to the terms of either the GNU
124.10 - * General Public License Version 2 only ("GPL") or the Common
124.11 - * Development and Distribution License("CDDL") (collectively, the
124.12 - * "License"). You may not use this file except in compliance with the
124.13 - * License. You can obtain a copy of the License at
124.14 - * http://www.netbeans.org/cddl-gplv2.html
124.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
124.16 - * specific language governing permissions and limitations under the
124.17 - * License. When distributing the software, include this License Header
124.18 - * Notice in each file and include the License file at
124.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
124.20 - * particular file as subject to the "Classpath" exception as provided
124.21 - * by Sun in the GPL Version 2 section of the License file that
124.22 - * accompanied this code. If applicable, add the following below the
124.23 - * License Header, with the fields enclosed by brackets [] replaced by
124.24 - * your own identifying information:
124.25 - * "Portions Copyrighted [year] [name of copyright owner]"
124.26 - *
124.27 - * If you wish your version of this file to be governed by only the CDDL
124.28 - * or only the GPL Version 2, indicate your decision by adding
124.29 - * "[Contributor] elects to include this software in this distribution
124.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
124.31 - * single choice of license, a recipient has the option to distribute
124.32 - * your version of this file under either the CDDL, the GPL Version 2 or
124.33 - * to extend the choice of license to its licensees as provided above.
124.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
124.35 - * Version 2 license, then the option applies only if the new code is
124.36 - * made subject to such option by the copyright holder.
124.37 - *
124.38 - * Contributor(s):
124.39 - *
124.40 - * Portions Copyrighted 2008-2010 Sun Microsystems, Inc.
124.41 - */
124.42 -
124.43 -package org.netbeans.modules.jackpot30.refactoring;
124.44 -
124.45 -import org.netbeans.modules.jackpot30.refactoring.invertboolean.InvertBooleanRefactoring;
124.46 -import org.netbeans.modules.jackpot30.refactoring.invertboolean.InvertBooleanRefactoringPluginImpl;
124.47 -import org.netbeans.modules.jackpot30.refactoring.noconstructor.ReplaceConstructorRefactoring;
124.48 -import org.netbeans.modules.jackpot30.refactoring.noconstructor.ReplaceConstructorRefactoringPluginImpl;
124.49 -import org.netbeans.modules.refactoring.api.AbstractRefactoring;
124.50 -import org.netbeans.modules.refactoring.api.RenameRefactoring;
124.51 -import org.netbeans.modules.refactoring.spi.RefactoringPlugin;
124.52 -import org.netbeans.modules.refactoring.spi.RefactoringPluginFactory;
124.53 -import org.openide.util.lookup.ServiceProvider;
124.54 -
124.55 -/**
124.56 - *
124.57 - * @author Jan Lahoda
124.58 - */
124.59 -@ServiceProvider(service=RefactoringPluginFactory.class)
124.60 -public class RefactoringPluginFactoryImpl implements RefactoringPluginFactory {
124.61 -
124.62 - public RefactoringPlugin createInstance(AbstractRefactoring refactoring) {
124.63 - if (refactoring instanceof RenameRefactoring) {
124.64 - return new RenameRefactoringPluginImpl((RenameRefactoring) refactoring);
124.65 - }
124.66 -
124.67 - if (refactoring instanceof ReplaceConstructorRefactoring) {
124.68 - return new ReplaceConstructorRefactoringPluginImpl((ReplaceConstructorRefactoring) refactoring);
124.69 - }
124.70 -
124.71 - if (refactoring instanceof InvertBooleanRefactoring) {
124.72 - return new InvertBooleanRefactoringPluginImpl((InvertBooleanRefactoring) refactoring);
124.73 - }
124.74 -
124.75 - return null;
124.76 - }
124.77 -
124.78 -}
125.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/RenameRefactoringPluginImpl.java Fri Jan 27 13:35:56 2012 +0100
125.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
125.3 @@ -1,209 +0,0 @@
125.4 -/*
125.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
125.6 - *
125.7 - * Copyright 2008-2010 Sun Microsystems, Inc. All rights reserved.
125.8 - *
125.9 - * The contents of this file are subject to the terms of either the GNU
125.10 - * General Public License Version 2 only ("GPL") or the Common
125.11 - * Development and Distribution License("CDDL") (collectively, the
125.12 - * "License"). You may not use this file except in compliance with the
125.13 - * License. You can obtain a copy of the License at
125.14 - * http://www.netbeans.org/cddl-gplv2.html
125.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
125.16 - * specific language governing permissions and limitations under the
125.17 - * License. When distributing the software, include this License Header
125.18 - * Notice in each file and include the License file at
125.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
125.20 - * particular file as subject to the "Classpath" exception as provided
125.21 - * by Sun in the GPL Version 2 section of the License file that
125.22 - * accompanied this code. If applicable, add the following below the
125.23 - * License Header, with the fields enclosed by brackets [] replaced by
125.24 - * your own identifying information:
125.25 - * "Portions Copyrighted [year] [name of copyright owner]"
125.26 - *
125.27 - * If you wish your version of this file to be governed by only the CDDL
125.28 - * or only the GPL Version 2, indicate your decision by adding
125.29 - * "[Contributor] elects to include this software in this distribution
125.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
125.31 - * single choice of license, a recipient has the option to distribute
125.32 - * your version of this file under either the CDDL, the GPL Version 2 or
125.33 - * to extend the choice of license to its licensees as provided above.
125.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
125.35 - * Version 2 license, then the option applies only if the new code is
125.36 - * made subject to such option by the copyright holder.
125.37 - *
125.38 - * Contributor(s):
125.39 - *
125.40 - * Portions Copyrighted 2008-2010 Sun Microsystems, Inc.
125.41 - */
125.42 -
125.43 -package org.netbeans.modules.jackpot30.refactoring;
125.44 -
125.45 -import com.sun.source.tree.BlockTree;
125.46 -import com.sun.source.tree.ClassTree;
125.47 -import com.sun.source.tree.ExpressionTree;
125.48 -import com.sun.source.tree.MethodInvocationTree;
125.49 -import com.sun.source.tree.MethodTree;
125.50 -import com.sun.source.tree.ModifiersTree;
125.51 -import com.sun.source.tree.StatementTree;
125.52 -import com.sun.source.tree.VariableTree;
125.53 -import com.sun.source.util.TreePath;
125.54 -import java.io.File;
125.55 -import java.util.Collections;
125.56 -import java.util.EnumSet;
125.57 -import java.util.LinkedList;
125.58 -import java.util.List;
125.59 -import java.util.Set;
125.60 -import javax.lang.model.element.Element;
125.61 -import javax.lang.model.element.ElementKind;
125.62 -import javax.lang.model.element.ExecutableElement;
125.63 -import javax.lang.model.element.Modifier;
125.64 -import javax.lang.model.element.TypeElement;
125.65 -import javax.lang.model.type.TypeKind;
125.66 -import org.netbeans.api.java.source.CancellableTask;
125.67 -import org.netbeans.api.java.source.ClasspathInfo.PathKind;
125.68 -import org.netbeans.api.java.source.JavaSource;
125.69 -import org.netbeans.api.java.source.TreeMaker;
125.70 -import org.netbeans.api.java.source.TreePathHandle;
125.71 -import org.netbeans.api.java.source.WorkingCopy;
125.72 -import org.netbeans.modules.refactoring.api.Problem;
125.73 -import org.netbeans.modules.refactoring.api.RenameRefactoring;
125.74 -import org.netbeans.modules.refactoring.java.spi.JavaRefactoringPlugin;
125.75 -import org.netbeans.modules.refactoring.spi.RefactoringElementsBag;
125.76 -import org.openide.filesystems.FileObject;
125.77 -import org.openide.filesystems.FileUtil;
125.78 -import org.openide.util.Lookup;
125.79 -
125.80 -/**
125.81 - *
125.82 - * @author Jan Lahoda
125.83 - */
125.84 -public class RenameRefactoringPluginImpl extends JavaRefactoringPlugin {
125.85 -
125.86 - private final RenameRefactoring rr;
125.87 -
125.88 - public RenameRefactoringPluginImpl(RenameRefactoring rr) {
125.89 - this.rr = rr;
125.90 - }
125.91 -
125.92 - @Override
125.93 - public Problem preCheck() {
125.94 - return null;
125.95 - }
125.96 -
125.97 - @Override
125.98 - public Problem checkParameters() {
125.99 - return null;
125.100 - }
125.101 -
125.102 - @Override
125.103 - public Problem fastCheckParameters() {
125.104 - return null;
125.105 - }
125.106 -
125.107 - @Override
125.108 - public void cancelRequest() {
125.109 - }
125.110 -
125.111 - public Problem prepare(final RefactoringElementsBag refactoringElements) {
125.112 - final ExtraData data = rr.getContext().lookup(ExtraData.class);
125.113 -
125.114 - if (data == null || !data.generateUpgradeScript) {
125.115 - return null;
125.116 - }
125.117 -
125.118 - Lookup source = rr.getRefactoringSource();
125.119 - final TreePathHandle toRename = source.lookup(TreePathHandle.class);
125.120 -
125.121 - if (toRename == null) {
125.122 - return null;
125.123 - }
125.124 -
125.125 - JavaSource js = JavaSource.forFileObject(toRename.getFileObject());
125.126 -
125.127 - if (js != null) {
125.128 - CancellableTask<WorkingCopy> work = new CancellableTask<WorkingCopy>() {
125.129 - public void run(WorkingCopy parameter) throws Exception {
125.130 - parameter.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
125.131 - TreePath tp = toRename.resolve(parameter);
125.132 -
125.133 - if (tp == null) {
125.134 - return ;
125.135 - }
125.136 -
125.137 - Element e = parameter.getTrees().getElement(tp);
125.138 -
125.139 - if (e == null || e.getKind() != ElementKind.METHOD) {
125.140 - return ;
125.141 - }
125.142 -
125.143 - MethodTree m = (MethodTree) tp.getLeaf();
125.144 - ClassTree ct = (ClassTree) tp.getParentPath().getLeaf();
125.145 -
125.146 - TreeMaker make = parameter.getTreeMaker();
125.147 -
125.148 - List<ExpressionTree> args = new LinkedList<ExpressionTree>();
125.149 -
125.150 - for (VariableTree vt : m.getParameters()) {
125.151 - args.add(make.Identifier(vt.getName()));
125.152 - }
125.153 -
125.154 - MethodInvocationTree mit = make.MethodInvocation(Collections.<ExpressionTree>emptyList(), make.Identifier(rr.getNewName()), args);
125.155 -
125.156 - StatementTree invoke;
125.157 -
125.158 - if (((ExecutableElement) e).getReturnType().getKind() == TypeKind.VOID) {
125.159 - invoke = make.ExpressionStatement(mit);
125.160 - } else {
125.161 - invoke = make.Return(mit);
125.162 - }
125.163 -
125.164 - BlockTree body = make.Block(Collections.<StatementTree>singletonList(invoke), false);
125.165 -// ModifiersTree mods = make.addModifiersAnnotation(m.getModifiers(), constructTransformation(parameter, make, rr.getNewName(), (ExecutableElement) e));
125.166 - ModifiersTree mods = m.getModifiers();
125.167 -
125.168 - if (data.makeOriginalDeprecated) {
125.169 - mods = make.addModifiersAnnotation(mods, make.Annotation(make.QualIdent(parameter.getElements().getTypeElement("java.lang.Deprecated")), Collections.<ExpressionTree>emptyList()));
125.170 - }
125.171 -
125.172 - if (data.makeOriginalPrivate) {
125.173 - Set<Modifier> modSet = EnumSet.noneOf(Modifier.class);
125.174 -
125.175 - modSet.addAll(mods.getFlags());
125.176 - modSet.removeAll(EnumSet.of(Modifier.PUBLIC, Modifier.PROTECTED));
125.177 - modSet.add(Modifier.PRIVATE);
125.178 -
125.179 - mods = make.Modifiers(modSet, mods.getAnnotations());
125.180 - }
125.181 -
125.182 - MethodTree nue = make.Method(mods, m.getName(), m.getReturnType(), m.getTypeParameters(), m.getParameters(), m.getThrows(), body, null);
125.183 -
125.184 - ClassTree nueClass = make.insertClassMember(ct, ct.getMembers().indexOf(m), nue);
125.185 -
125.186 - parameter.rewrite(ct, nueClass);
125.187 -
125.188 - FileObject root = parameter.getClasspathInfo().getClassPath(PathKind.SOURCE).findOwnerRoot(parameter.getFileObject());
125.189 -
125.190 - if (root != null) {
125.191 - File f = FileUtil.toFile(root);
125.192 - String rule = ScriptGenerator.constructRenameRule(parameter, rr.getNewName(), e);
125.193 - File ruleFile = new File(f, "META-INF/upgrade/" + ((TypeElement) e.getEnclosingElement()).getQualifiedName().toString() + ".hint");
125.194 -
125.195 - refactoringElements.add(rr, new RefactoringElementImpl( ruleFile, rule));
125.196 - }
125.197 - }
125.198 - public void cancel() {}
125.199 - };
125.200 -
125.201 - createAndAddElements(Collections.singleton(toRename.getFileObject()), work, refactoringElements, rr);
125.202 - }
125.203 -
125.204 - return null;
125.205 - }
125.206 -
125.207 - @Override
125.208 - protected JavaSource getJavaSource(Phase p) {
125.209 - return null;
125.210 - }
125.211 -
125.212 -}
126.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/RenameRefactoringWrapper.java Fri Jan 27 13:35:56 2012 +0100
126.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
126.3 @@ -1,162 +0,0 @@
126.4 -/*
126.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
126.6 - *
126.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
126.8 - *
126.9 - * The contents of this file are subject to the terms of either the GNU
126.10 - * General Public License Version 2 only ("GPL") or the Common
126.11 - * Development and Distribution License("CDDL") (collectively, the
126.12 - * "License"). You may not use this file except in compliance with the
126.13 - * License. You can obtain a copy of the License at
126.14 - * http://www.netbeans.org/cddl-gplv2.html
126.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
126.16 - * specific language governing permissions and limitations under the
126.17 - * License. When distributing the software, include this License Header
126.18 - * Notice in each file and include the License file at
126.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
126.20 - * particular file as subject to the "Classpath" exception as provided
126.21 - * by Sun in the GPL Version 2 section of the License file that
126.22 - * accompanied this code. If applicable, add the following below the
126.23 - * License Header, with the fields enclosed by brackets [] replaced by
126.24 - * your own identifying information:
126.25 - * "Portions Copyrighted [year] [name of copyright owner]"
126.26 - *
126.27 - * If you wish your version of this file to be governed by only the CDDL
126.28 - * or only the GPL Version 2, indicate your decision by adding
126.29 - * "[Contributor] elects to include this software in this distribution
126.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
126.31 - * single choice of license, a recipient has the option to distribute
126.32 - * your version of this file under either the CDDL, the GPL Version 2 or
126.33 - * to extend the choice of license to its licensees as provided above.
126.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
126.35 - * Version 2 license, then the option applies only if the new code is
126.36 - * made subject to such option by the copyright holder.
126.37 - *
126.38 - * Contributor(s):
126.39 - *
126.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
126.41 - */
126.42 -
126.43 -package org.netbeans.modules.jackpot30.refactoring;
126.44 -
126.45 -import com.sun.source.tree.Tree.Kind;
126.46 -import java.awt.BorderLayout;
126.47 -import java.awt.Component;
126.48 -import javax.swing.JComponent;
126.49 -import javax.swing.JPanel;
126.50 -import javax.swing.border.EmptyBorder;
126.51 -import javax.swing.event.ChangeListener;
126.52 -import org.netbeans.api.java.source.TreePathHandle;
126.53 -import org.netbeans.modules.refactoring.api.AbstractRefactoring;
126.54 -import org.netbeans.modules.refactoring.api.Problem;
126.55 -import org.netbeans.modules.refactoring.api.RenameRefactoring;
126.56 -import org.netbeans.modules.refactoring.spi.ui.CustomRefactoringPanel;
126.57 -import org.netbeans.modules.refactoring.spi.ui.RefactoringUI;
126.58 -import org.openide.util.HelpCtx;
126.59 -import org.openide.util.Lookup;
126.60 -
126.61 -/**
126.62 - *
126.63 - * @author lahvac
126.64 - */
126.65 -public class RenameRefactoringWrapper implements RefactoringUI {
126.66 -
126.67 - private final RefactoringUI delegate;
126.68 - private final RenameRefactoring refactoring;
126.69 -
126.70 - public RenameRefactoringWrapper(RefactoringUI delegate, RenameRefactoring refactoring) {
126.71 - this.delegate = delegate;
126.72 - this.refactoring = refactoring;
126.73 - }
126.74 -
126.75 - @Override
126.76 - public String getName() {
126.77 - return delegate.getName();
126.78 - }
126.79 -
126.80 - @Override
126.81 - public String getDescription() {
126.82 - return delegate.getDescription();
126.83 - }
126.84 -
126.85 - @Override
126.86 - public boolean isQuery() {
126.87 - return delegate.isQuery();
126.88 - }
126.89 -
126.90 - private GenerateScriptPanel gsp;
126.91 - private CustomRefactoringPanel crp;
126.92 -
126.93 - @Override
126.94 - public CustomRefactoringPanel getPanel(ChangeListener parent) {
126.95 - if (crp == null) {
126.96 - Lookup source = refactoring.getRefactoringSource();
126.97 - TreePathHandle toRename = source.lookup(TreePathHandle.class);
126.98 -
126.99 - gsp = new GenerateScriptPanel(toRename != null && toRename.getKind() == Kind.METHOD);
126.100 - crp = new CustomRefactoringPanelImpl(gsp, delegate.getPanel(parent));
126.101 - }
126.102 -
126.103 - return crp;
126.104 - }
126.105 -
126.106 - @Override
126.107 - public Problem setParameters() {
126.108 - gsp.saveDefaults();
126.109 - refactoring.getContext().add(gsp.getData());
126.110 - return delegate.setParameters();
126.111 - }
126.112 -
126.113 - @Override
126.114 - public Problem checkParameters() {
126.115 - return delegate.checkParameters();
126.116 - }
126.117 -
126.118 - @Override
126.119 - public boolean hasParameters() {
126.120 - return true;
126.121 - }
126.122 -
126.123 - @Override
126.124 - public AbstractRefactoring getRefactoring() {
126.125 - return refactoring;
126.126 - }
126.127 -
126.128 - @Override
126.129 - public HelpCtx getHelpCtx() {
126.130 - return delegate.getHelpCtx();
126.131 - }
126.132 -
126.133 - private static final class CustomRefactoringPanelImpl implements CustomRefactoringPanel {
126.134 - private final CustomRefactoringPanel delegate;
126.135 - private final JComponent component;
126.136 - public CustomRefactoringPanelImpl(final GenerateScriptPanel panel, CustomRefactoringPanel delegate) {
126.137 - this.delegate = delegate;
126.138 - final Component delegateComponent = delegate.getComponent();
126.139 - this.component = new JPanel(new BorderLayout()) {
126.140 - {
126.141 - add(delegateComponent, BorderLayout.CENTER);
126.142 - panel.setBorder(new EmptyBorder(0, 5, 0, 0));
126.143 - add(panel, BorderLayout.SOUTH);
126.144 - delegateComponent.requestFocus();
126.145 - }
126.146 - @Override
126.147 - public void requestFocus() {
126.148 - delegateComponent.requestFocus();
126.149 - }
126.150 - };
126.151 - }
126.152 -
126.153 - @Override
126.154 - public void initialize() {
126.155 - delegate.initialize();
126.156 - }
126.157 -
126.158 - @Override
126.159 - public Component getComponent() {
126.160 - return component;
126.161 - }
126.162 -
126.163 - }
126.164 -
126.165 -}
127.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/ScriptGenerator.java Fri Jan 27 13:35:56 2012 +0100
127.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
127.3 @@ -1,113 +0,0 @@
127.4 -/*
127.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
127.6 - *
127.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
127.8 - *
127.9 - * The contents of this file are subject to the terms of either the GNU
127.10 - * General Public License Version 2 only ("GPL") or the Common
127.11 - * Development and Distribution License("CDDL") (collectively, the
127.12 - * "License"). You may not use this file except in compliance with the
127.13 - * License. You can obtain a copy of the License at
127.14 - * http://www.netbeans.org/cddl-gplv2.html
127.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
127.16 - * specific language governing permissions and limitations under the
127.17 - * License. When distributing the software, include this License Header
127.18 - * Notice in each file and include the License file at
127.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
127.20 - * particular file as subject to the "Classpath" exception as provided
127.21 - * by Sun in the GPL Version 2 section of the License file that
127.22 - * accompanied this code. If applicable, add the following below the
127.23 - * License Header, with the fields enclosed by brackets [] replaced by
127.24 - * your own identifying information:
127.25 - * "Portions Copyrighted [year] [name of copyright owner]"
127.26 - *
127.27 - * If you wish your version of this file to be governed by only the CDDL
127.28 - * or only the GPL Version 2, indicate your decision by adding
127.29 - * "[Contributor] elects to include this software in this distribution
127.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
127.31 - * single choice of license, a recipient has the option to distribute
127.32 - * your version of this file under either the CDDL, the GPL Version 2 or
127.33 - * to extend the choice of license to its licensees as provided above.
127.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
127.35 - * Version 2 license, then the option applies only if the new code is
127.36 - * made subject to such option by the copyright holder.
127.37 - *
127.38 - * Contributor(s):
127.39 - *
127.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
127.41 - */
127.42 -
127.43 -package org.netbeans.modules.jackpot30.refactoring;
127.44 -
127.45 -import javax.lang.model.element.Element;
127.46 -import javax.lang.model.element.ExecutableElement;
127.47 -import javax.lang.model.element.Modifier;
127.48 -import javax.lang.model.element.TypeElement;
127.49 -import javax.lang.model.element.VariableElement;
127.50 -import org.netbeans.api.annotations.common.NonNull;
127.51 -import org.netbeans.api.java.source.WorkingCopy;
127.52 -
127.53 -/**
127.54 - *
127.55 - * @author lahvac
127.56 - */
127.57 -public class ScriptGenerator {
127.58 -
127.59 - public static @NonNull String constructRenameRule(@NonNull WorkingCopy wc, @NonNull String newName, @NonNull Element original) {
127.60 - switch (original.getKind()) {
127.61 - case METHOD: return constructRenameRule(wc, newName, (ExecutableElement) original);
127.62 - default: throw new UnsupportedOperationException();
127.63 - }
127.64 - }
127.65 -
127.66 - private static String constructRenameRule(WorkingCopy wc, String newName, ExecutableElement method) {
127.67 - //XXX: type parameters?
127.68 - StringBuilder pattern = new StringBuilder();
127.69 - StringBuilder constraints = new StringBuilder();
127.70 - StringBuilder target = new StringBuilder();
127.71 -
127.72 - TypeElement clazz = (TypeElement) method.getEnclosingElement();
127.73 -
127.74 - if (method.getModifiers().contains(Modifier.STATIC)) {
127.75 - pattern.append(clazz.getQualifiedName().toString()).append(".");
127.76 - target.append(clazz.getQualifiedName().toString()).append(".");
127.77 - } else {
127.78 - pattern.append("$0.");
127.79 - constraints.append(" :: $0 instanceof " + clazz.getQualifiedName().toString());
127.80 - target.append("$0.");
127.81 - }
127.82 -
127.83 - pattern.append(method.getSimpleName().toString());
127.84 - target.append(newName);
127.85 - pattern.append("(");
127.86 - target.append("(");
127.87 -
127.88 - int count = 1;
127.89 -
127.90 - for (VariableElement p : method.getParameters()) {
127.91 - if (count++ > 1) {
127.92 - pattern.append(", ");
127.93 - target.append(", ");
127.94 - }
127.95 -
127.96 - String name = "$" + p.getSimpleName().toString();
127.97 -
127.98 - pattern.append(name);
127.99 - target.append(name);
127.100 -
127.101 - if (constraints.length() == 0) {
127.102 - constraints.append(" :: ");
127.103 - } else {
127.104 - constraints.append(" && ");
127.105 - }
127.106 -
127.107 - constraints.append(name).append(" instanceof ").append(p.asType());
127.108 - }
127.109 -
127.110 - pattern.append(")");
127.111 - target.append(")");
127.112 -
127.113 - return " " + pattern + constraints + "\n=> " + target + "\n;;";
127.114 - }
127.115 -
127.116 -}
128.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/invertboolean/Bundle.properties Fri Jan 27 13:35:56 2012 +0100
128.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
128.3 @@ -1,2 +0,0 @@
128.4 -InvertBooleanRefactoringPanel.nameField.text=
128.5 -InvertBooleanRefactoringPanel.jLabel1.text=New name:
129.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/invertboolean/InvertBooleanAction.java Fri Jan 27 13:35:56 2012 +0100
129.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
129.3 @@ -1,75 +0,0 @@
129.4 -/*
129.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
129.6 - *
129.7 - * Copyright 2010-2011 Sun Microsystems, Inc. All rights reserved.
129.8 - *
129.9 - * The contents of this file are subject to the terms of either the GNU
129.10 - * General Public License Version 2 only ("GPL") or the Common
129.11 - * Development and Distribution License("CDDL") (collectively, the
129.12 - * "License"). You may not use this file except in compliance with the
129.13 - * License. You can obtain a copy of the License at
129.14 - * http://www.netbeans.org/cddl-gplv2.html
129.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
129.16 - * specific language governing permissions and limitations under the
129.17 - * License. When distributing the software, include this License Header
129.18 - * Notice in each file and include the License file at
129.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
129.20 - * particular file as subject to the "Classpath" exception as provided
129.21 - * by Sun in the GPL Version 2 section of the License file that
129.22 - * accompanied this code. If applicable, add the following below the
129.23 - * License Header, with the fields enclosed by brackets [] replaced by
129.24 - * your own identifying information:
129.25 - * "Portions Copyrighted [year] [name of copyright owner]"
129.26 - *
129.27 - * If you wish your version of this file to be governed by only the CDDL
129.28 - * or only the GPL Version 2, indicate your decision by adding
129.29 - * "[Contributor] elects to include this software in this distribution
129.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
129.31 - * single choice of license, a recipient has the option to distribute
129.32 - * your version of this file under either the CDDL, the GPL Version 2 or
129.33 - * to extend the choice of license to its licensees as provided above.
129.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
129.35 - * Version 2 license, then the option applies only if the new code is
129.36 - * made subject to such option by the copyright holder.
129.37 - *
129.38 - * Contributor(s):
129.39 - *
129.40 - * Portions Copyrighted 2010-2011 Sun Microsystems, Inc.
129.41 - */
129.42 -package org.netbeans.modules.jackpot30.refactoring.invertboolean;
129.43 -
129.44 -import javax.swing.Action;
129.45 -import org.netbeans.modules.jackpot30.refactoring.RefactoringActionsProviderExt;
129.46 -import org.netbeans.modules.refactoring.java.ui.JavaRefactoringGlobalAction;
129.47 -import org.openide.util.HelpCtx;
129.48 -import org.openide.util.Lookup;
129.49 -import org.openide.util.NbBundle.Messages;
129.50 -
129.51 -public final class InvertBooleanAction extends JavaRefactoringGlobalAction {
129.52 -
129.53 - @Messages("LBL_InvertBooleanAction=Invert Boolean")
129.54 - public InvertBooleanAction() {
129.55 - super(Bundle.LBL_InvertBooleanAction(), null); // NOI18N
129.56 - putValue("noIconInMenu", Boolean.TRUE); // NOI18N
129.57 - }
129.58 -
129.59 - public final void performAction(Lookup context) {
129.60 - RefactoringActionsProviderExt.doInvertBoolean(context);
129.61 - }
129.62 -
129.63 - public org.openide.util.HelpCtx getHelpCtx() {
129.64 - return HelpCtx.DEFAULT_HELP;
129.65 - }
129.66 -
129.67 - protected boolean asynchronous() {
129.68 - return false;
129.69 - }
129.70 -
129.71 - protected boolean enable(Lookup context) {
129.72 - return RefactoringActionsProviderExt.canInvertBoolean(context);
129.73 - }
129.74 -
129.75 - public static Action create() {
129.76 - return InvertBooleanAction.findObject(InvertBooleanAction.class, true);
129.77 - }
129.78 -}
130.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/invertboolean/InvertBooleanRefactoring.java Fri Jan 27 13:35:56 2012 +0100
130.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
130.3 @@ -1,69 +0,0 @@
130.4 -/*
130.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
130.6 - *
130.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
130.8 - *
130.9 - * The contents of this file are subject to the terms of either the GNU
130.10 - * General Public License Version 2 only ("GPL") or the Common
130.11 - * Development and Distribution License("CDDL") (collectively, the
130.12 - * "License"). You may not use this file except in compliance with the
130.13 - * License. You can obtain a copy of the License at
130.14 - * http://www.netbeans.org/cddl-gplv2.html
130.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
130.16 - * specific language governing permissions and limitations under the
130.17 - * License. When distributing the software, include this License Header
130.18 - * Notice in each file and include the License file at
130.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
130.20 - * particular file as subject to the "Classpath" exception as provided
130.21 - * by Sun in the GPL Version 2 section of the License file that
130.22 - * accompanied this code. If applicable, add the following below the
130.23 - * License Header, with the fields enclosed by brackets [] replaced by
130.24 - * your own identifying information:
130.25 - * "Portions Copyrighted [year] [name of copyright owner]"
130.26 - *
130.27 - * If you wish your version of this file to be governed by only the CDDL
130.28 - * or only the GPL Version 2, indicate your decision by adding
130.29 - * "[Contributor] elects to include this software in this distribution
130.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
130.31 - * single choice of license, a recipient has the option to distribute
130.32 - * your version of this file under either the CDDL, the GPL Version 2 or
130.33 - * to extend the choice of license to its licensees as provided above.
130.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
130.35 - * Version 2 license, then the option applies only if the new code is
130.36 - * made subject to such option by the copyright holder.
130.37 - *
130.38 - * Contributor(s):
130.39 - *
130.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
130.41 - */
130.42 -
130.43 -package org.netbeans.modules.jackpot30.refactoring.invertboolean;
130.44 -
130.45 -import org.netbeans.api.java.source.TreePathHandle;
130.46 -import org.netbeans.modules.refactoring.api.AbstractRefactoring;
130.47 -import org.openide.util.lookup.Lookups;
130.48 -
130.49 -/**
130.50 - *
130.51 - * @author lahvac
130.52 - */
130.53 -public class InvertBooleanRefactoring extends AbstractRefactoring {
130.54 -
130.55 - private final TreePathHandle original;
130.56 - private final String newName;
130.57 -
130.58 - public InvertBooleanRefactoring(TreePathHandle original, String newName) {
130.59 - super(Lookups.singleton(original));
130.60 - this.original = original;
130.61 - this.newName = newName;
130.62 - }
130.63 -
130.64 - public TreePathHandle getOriginal() {
130.65 - return original;
130.66 - }
130.67 -
130.68 - public String getNewName() {
130.69 - return newName;
130.70 - }
130.71 -
130.72 -}
131.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/invertboolean/InvertBooleanRefactoringPanel.form Fri Jan 27 13:35:56 2012 +0100
131.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
131.3 @@ -1,58 +0,0 @@
131.4 -<?xml version="1.1" encoding="UTF-8" ?>
131.5 -
131.6 -<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
131.7 - <AuxValues>
131.8 - <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
131.9 - <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
131.10 - <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
131.11 - <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
131.12 - <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
131.13 - <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
131.14 - <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
131.15 - <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
131.16 - <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
131.17 - </AuxValues>
131.18 -
131.19 - <Layout>
131.20 - <DimensionLayout dim="0">
131.21 - <Group type="103" groupAlignment="0" attributes="0">
131.22 - <Group type="102" alignment="0" attributes="0">
131.23 - <EmptySpace max="-2" attributes="0"/>
131.24 - <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
131.25 - <EmptySpace max="-2" attributes="0"/>
131.26 - <Component id="nameField" pref="249" max="32767" attributes="0"/>
131.27 - <EmptySpace max="-2" attributes="0"/>
131.28 - </Group>
131.29 - </Group>
131.30 - </DimensionLayout>
131.31 - <DimensionLayout dim="1">
131.32 - <Group type="103" groupAlignment="0" attributes="0">
131.33 - <Group type="102" alignment="0" attributes="0">
131.34 - <EmptySpace max="-2" attributes="0"/>
131.35 - <Group type="103" groupAlignment="3" attributes="0">
131.36 - <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
131.37 - <Component id="nameField" alignment="3" min="-2" max="-2" attributes="0"/>
131.38 - </Group>
131.39 - <EmptySpace max="32767" attributes="0"/>
131.40 - </Group>
131.41 - </Group>
131.42 - </DimensionLayout>
131.43 - </Layout>
131.44 - <SubComponents>
131.45 - <Component class="javax.swing.JLabel" name="jLabel1">
131.46 - <Properties>
131.47 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
131.48 - <ResourceString bundle="org/netbeans/modules/jackpot30/refactoring/noconstructor/Bundle.properties" key="InvertBooleanRefactoringPanel.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
131.49 - </Property>
131.50 - </Properties>
131.51 - </Component>
131.52 - <Component class="javax.swing.JTextField" name="nameField">
131.53 - <Properties>
131.54 - <Property name="columns" type="int" value="15"/>
131.55 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
131.56 - <ResourceString bundle="org/netbeans/modules/jackpot30/refactoring/noconstructor/Bundle.properties" key="InvertBooleanRefactoringPanel.nameField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
131.57 - </Property>
131.58 - </Properties>
131.59 - </Component>
131.60 - </SubComponents>
131.61 -</Form>
132.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/invertboolean/InvertBooleanRefactoringPanel.java Fri Jan 27 13:35:56 2012 +0100
132.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
132.3 @@ -1,124 +0,0 @@
132.4 -/*
132.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
132.6 - *
132.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
132.8 - *
132.9 - * The contents of this file are subject to the terms of either the GNU
132.10 - * General Public License Version 2 only ("GPL") or the Common
132.11 - * Development and Distribution License("CDDL") (collectively, the
132.12 - * "License"). You may not use this file except in compliance with the
132.13 - * License. You can obtain a copy of the License at
132.14 - * http://www.netbeans.org/cddl-gplv2.html
132.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
132.16 - * specific language governing permissions and limitations under the
132.17 - * License. When distributing the software, include this License Header
132.18 - * Notice in each file and include the License file at
132.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
132.20 - * particular file as subject to the "Classpath" exception as provided
132.21 - * by Sun in the GPL Version 2 section of the License file that
132.22 - * accompanied this code. If applicable, add the following below the
132.23 - * License Header, with the fields enclosed by brackets [] replaced by
132.24 - * your own identifying information:
132.25 - * "Portions Copyrighted [year] [name of copyright owner]"
132.26 - *
132.27 - * If you wish your version of this file to be governed by only the CDDL
132.28 - * or only the GPL Version 2, indicate your decision by adding
132.29 - * "[Contributor] elects to include this software in this distribution
132.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
132.31 - * single choice of license, a recipient has the option to distribute
132.32 - * your version of this file under either the CDDL, the GPL Version 2 or
132.33 - * to extend the choice of license to its licensees as provided above.
132.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
132.35 - * Version 2 license, then the option applies only if the new code is
132.36 - * made subject to such option by the copyright holder.
132.37 - *
132.38 - * Contributor(s):
132.39 - *
132.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
132.41 - */
132.42 -
132.43 -package org.netbeans.modules.jackpot30.refactoring.invertboolean;
132.44 -
132.45 -import javax.swing.event.ChangeEvent;
132.46 -import javax.swing.event.ChangeListener;
132.47 -import javax.swing.event.DocumentEvent;
132.48 -import javax.swing.event.DocumentListener;
132.49 -import org.netbeans.api.annotations.common.NonNull;
132.50 -
132.51 -/**
132.52 - *
132.53 - * @author lahvac
132.54 - */
132.55 -public class InvertBooleanRefactoringPanel extends javax.swing.JPanel {
132.56 -
132.57 - public InvertBooleanRefactoringPanel(final @NonNull ChangeListener parent) {
132.58 - initComponents();
132.59 - nameField.getDocument().addDocumentListener(new DocumentListener() {
132.60 - @Override
132.61 - public void insertUpdate(DocumentEvent e) {
132.62 - parent.stateChanged(new ChangeEvent(InvertBooleanRefactoringPanel.this));
132.63 - }
132.64 - @Override
132.65 - public void removeUpdate(DocumentEvent e) {
132.66 - parent.stateChanged(new ChangeEvent(InvertBooleanRefactoringPanel.this));
132.67 - }
132.68 - @Override
132.69 - public void changedUpdate(DocumentEvent e) {}
132.70 - });
132.71 - }
132.72 -
132.73 - /** This method is called from within the constructor to
132.74 - * initialize the form.
132.75 - * WARNING: Do NOT modify this code. The content of this method is
132.76 - * always regenerated by the Form Editor.
132.77 - */
132.78 - @SuppressWarnings("unchecked")
132.79 - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
132.80 - private void initComponents() {
132.81 -
132.82 - jLabel1 = new javax.swing.JLabel();
132.83 - nameField = new javax.swing.JTextField();
132.84 -
132.85 - jLabel1.setText(org.openide.util.NbBundle.getMessage(InvertBooleanRefactoringPanel.class, "InvertBooleanRefactoringPanel.jLabel1.text")); // NOI18N
132.86 -
132.87 - nameField.setColumns(15);
132.88 - nameField.setText(org.openide.util.NbBundle.getMessage(InvertBooleanRefactoringPanel.class, "InvertBooleanRefactoringPanel.nameField.text")); // NOI18N
132.89 -
132.90 - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
132.91 - this.setLayout(layout);
132.92 - layout.setHorizontalGroup(
132.93 - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
132.94 - .addGroup(layout.createSequentialGroup()
132.95 - .addContainerGap()
132.96 - .addComponent(jLabel1)
132.97 - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
132.98 - .addComponent(nameField, javax.swing.GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE)
132.99 - .addContainerGap())
132.100 - );
132.101 - layout.setVerticalGroup(
132.102 - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
132.103 - .addGroup(layout.createSequentialGroup()
132.104 - .addContainerGap()
132.105 - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
132.106 - .addComponent(jLabel1)
132.107 - .addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
132.108 - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
132.109 - );
132.110 - }// </editor-fold>//GEN-END:initComponents
132.111 -
132.112 -
132.113 - // Variables declaration - do not modify//GEN-BEGIN:variables
132.114 - private javax.swing.JLabel jLabel1;
132.115 - private javax.swing.JTextField nameField;
132.116 - // End of variables declaration//GEN-END:variables
132.117 -
132.118 - public void initialize(String origName) {
132.119 - nameField.setText(origName);
132.120 - nameField.setSelectionStart(0);
132.121 - nameField.setSelectionStart(origName.length());
132.122 - }
132.123 -
132.124 - public String getName() {
132.125 - return nameField.getText();
132.126 - }
132.127 -}
133.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/invertboolean/InvertBooleanRefactoringPluginImpl.java Fri Jan 27 13:35:56 2012 +0100
133.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
133.3 @@ -1,250 +0,0 @@
133.4 -/*
133.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
133.6 - *
133.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
133.8 - *
133.9 - * The contents of this file are subject to the terms of either the GNU
133.10 - * General Public License Version 2 only ("GPL") or the Common
133.11 - * Development and Distribution License("CDDL") (collectively, the
133.12 - * "License"). You may not use this file except in compliance with the
133.13 - * License. You can obtain a copy of the License at
133.14 - * http://www.netbeans.org/cddl-gplv2.html
133.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
133.16 - * specific language governing permissions and limitations under the
133.17 - * License. When distributing the software, include this License Header
133.18 - * Notice in each file and include the License file at
133.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
133.20 - * particular file as subject to the "Classpath" exception as provided
133.21 - * by Sun in the GPL Version 2 section of the License file that
133.22 - * accompanied this code. If applicable, add the following below the
133.23 - * License Header, with the fields enclosed by brackets [] replaced by
133.24 - * your own identifying information:
133.25 - * "Portions Copyrighted [year] [name of copyright owner]"
133.26 - *
133.27 - * If you wish your version of this file to be governed by only the CDDL
133.28 - * or only the GPL Version 2, indicate your decision by adding
133.29 - * "[Contributor] elects to include this software in this distribution
133.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
133.31 - * single choice of license, a recipient has the option to distribute
133.32 - * your version of this file under either the CDDL, the GPL Version 2 or
133.33 - * to extend the choice of license to its licensees as provided above.
133.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
133.35 - * Version 2 license, then the option applies only if the new code is
133.36 - * made subject to such option by the copyright holder.
133.37 - *
133.38 - * Contributor(s):
133.39 - *
133.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
133.41 - */
133.42 -
133.43 -package org.netbeans.modules.jackpot30.refactoring.invertboolean;
133.44 -
133.45 -import com.sun.source.tree.ClassTree;
133.46 -import com.sun.source.tree.MethodTree;
133.47 -import com.sun.source.tree.ReturnTree;
133.48 -import com.sun.source.tree.Tree;
133.49 -import com.sun.source.tree.Tree.Kind;
133.50 -import com.sun.source.tree.VariableTree;
133.51 -import com.sun.source.util.TreePath;
133.52 -import com.sun.source.util.TreePathScanner;
133.53 -import java.io.IOException;
133.54 -import java.util.HashMap;
133.55 -import java.util.Map;
133.56 -import javax.lang.model.element.Modifier;
133.57 -import javax.lang.model.element.TypeElement;
133.58 -import javax.lang.model.type.TypeMirror;
133.59 -import org.netbeans.api.java.source.JavaSource;
133.60 -import org.netbeans.api.java.source.JavaSource.Phase;
133.61 -import org.netbeans.api.java.source.ModificationResult;
133.62 -import org.netbeans.api.java.source.Task;
133.63 -import org.netbeans.api.java.source.TreePathHandle;
133.64 -import org.netbeans.api.java.source.WorkingCopy;
133.65 -import org.netbeans.modules.jackpot30.spi.Hacks;
133.66 -import org.netbeans.modules.jackpot30.spi.refactoring.JackpotBasedRefactoring;
133.67 -import org.netbeans.modules.java.hints.jackpot.spi.PatternConvertor;
133.68 -import org.netbeans.modules.refactoring.api.Problem;
133.69 -import org.openide.util.Exceptions;
133.70 -import org.openide.util.MapFormat;
133.71 -
133.72 -/**
133.73 - *
133.74 - * @author lahvac
133.75 - */
133.76 -public class InvertBooleanRefactoringPluginImpl extends JackpotBasedRefactoring {
133.77 -
133.78 - private final InvertBooleanRefactoring invertBooleanRefactoring;
133.79 -
133.80 - public InvertBooleanRefactoringPluginImpl(InvertBooleanRefactoring replaceConstructorRefactoring) {
133.81 - super(replaceConstructorRefactoring);
133.82 - this.invertBooleanRefactoring = replaceConstructorRefactoring;
133.83 - }
133.84 -
133.85 - @Override
133.86 - public Problem preCheck() {
133.87 - return null;
133.88 - }
133.89 -
133.90 - @Override
133.91 - public Problem checkParameters() {
133.92 - return null;
133.93 - }
133.94 -
133.95 - @Override
133.96 - public Problem fastCheckParameters() {
133.97 - return null;
133.98 - }
133.99 -
133.100 - private static final String INVERT_FIXES =
133.101 - "=> ${newName-with-enclosing}$ $left != $right; :: matchesWithBind($val, \"$left == $right\")\n" +
133.102 - "=> ${newName-with-enclosing}$ $left == $right; :: matchesWithBind($val, \"$left != $right\")\n" +
133.103 - "=> ${newName-with-enclosing}$ $op; :: matchesWithBind($val, \"!($op)\")" +
133.104 - "=> ${newName-with-enclosing}$ $op; :: matchesWithBind($val, \"(!$op)\")" +
133.105 - "=> ${newName-with-enclosing}$ $op; :: !matchesAny($val, \"!($op)\") && matchesWithBind($val, \"!$op\")\n" +
133.106 - "=> ${newName-with-enclosing}$ false; :: matchesAny($val, \"true\")\n" +
133.107 - "=> ${newName-with-enclosing}$ true; :: matchesAny($val, \"false\")\n" +
133.108 - "=> ${newName-with-enclosing}$ !$val; :: otherwise\n";
133.109 -
133.110 - private static final String VAR_SCRIPT_TEMPLATE =
133.111 - " $enclosing.${originalName}$ :: $enclosing instanceof ${enclosing}$ && !parentMatches(\"$enclosing.${originalName}$ = $newVal\") && !parentMatches(\"!$enclosing.${originalName}$\")\n" +
133.112 - "=> !$enclosing.${newName}$\n" +
133.113 - ";;\n" +
133.114 - " !$enclosing.${originalName}$ :: $enclosing instanceof ${enclosing}$\n" +
133.115 - "=> $enclosing.${newName}$\n" +
133.116 - ";;\n" +
133.117 - " $enclosing.${originalName}$ = $val :: $enclosing instanceof ${enclosing}$ && !matchesAny($val, \"!$enclosing.${originalName}$\")\n" +
133.118 - INVERT_FIXES.replace(";", "").replace("${newName-with-enclosing}$", "$enclosing.${newName}$ =") +
133.119 - ";;\n";
133.120 -
133.121 - private static final String VAR_SCRIPT_TEMPLATE_STATIC =
133.122 - " ${enclosing}$.${originalName}$ :: !parentMatches(\"$enclosing.${originalName}$ = $newVal\") && !parentMatches(\"!$enclosing.${originalName}$\")\n" +
133.123 - "=> !${enclosing}$.${newName}$\n" +
133.124 - ";;\n" +
133.125 - " !${enclosing}$.${originalName}$\n" +
133.126 - "=> ${enclosing}$.${newName}$\n" +
133.127 - ";;\n" +
133.128 - " ${enclosing}$.${originalName}$ = $val :: !matchesAny($val, \"!$enclosing.${originalName}$\")\n" +
133.129 - INVERT_FIXES.replace(";", "").replace("${newName-with-enclosing}$", "${enclosing}$.${newName}$ =") +
133.130 - ";;\n";
133.131 -
133.132 - private static final String VAR_INIT =
133.133 - " $mods$ $type ${originalName}$ = $val;" +
133.134 - INVERT_FIXES.replace("${newName-with-enclosing}$", "$mods$ $type ${newName}$ =") +
133.135 - ";;";
133.136 -
133.137 - private static final String MTH_INIT =
133.138 - " return $val;" +
133.139 - INVERT_FIXES.replace("${newName-with-enclosing}$", "return ") +
133.140 - ";;";
133.141 -
133.142 - @Override
133.143 - protected void prepareAndConstructRule(final Context result) {
133.144 - final TreePathHandle original = invertBooleanRefactoring.getOriginal();
133.145 -
133.146 - try {
133.147 - ModificationResult mod = JavaSource.forFileObject(original.getFileObject()).runModificationTask(new Task<WorkingCopy>() {
133.148 -
133.149 - @Override
133.150 - public void run(final WorkingCopy parameter) throws Exception {
133.151 - parameter.toPhase(Phase.RESOLVED);
133.152 -
133.153 - final TreePath path = original.resolve(parameter);
133.154 - Map<String, String> arguments = new HashMap<String, String>();
133.155 - String scriptTemplate;
133.156 - Tree leaf = path.getLeaf();
133.157 - TypeElement parent = (TypeElement) parameter.getTrees().getElement(path.getParentPath());
133.158 -
133.159 - arguments.put("newName", invertBooleanRefactoring.getNewName());
133.160 - arguments.put("enclosing", parent.getQualifiedName().toString());
133.161 -
133.162 - if (leaf.getKind() == Kind.VARIABLE) {
133.163 - VariableTree var = (VariableTree) leaf;
133.164 -
133.165 - scriptTemplate = var.getModifiers().getFlags().contains(Modifier.STATIC) ? VAR_SCRIPT_TEMPLATE_STATIC : VAR_SCRIPT_TEMPLATE;
133.166 - arguments.put("originalName", var.getName().toString());
133.167 -
133.168 - if (var.getInitializer() != null) {
133.169 - MapFormat format = new MapFormat(arguments);
133.170 - format.setLeftBrace("${");
133.171 - format.setRightBrace("}$");
133.172 - String initFormat = format.format(VAR_INIT);
133.173 -
133.174 - Hacks.findHintsAndApplyFixes(parameter, PatternConvertor.create(initFormat), path, cancel);
133.175 - }
133.176 - } else if (leaf.getKind() == Kind.METHOD) {
133.177 - MethodTree mt = (MethodTree) leaf;
133.178 -
133.179 - arguments.put("originalName", mt.getName().toString());
133.180 -
133.181 - MapFormat format = new MapFormat(arguments);
133.182 - format.setLeftBrace("${");
133.183 - format.setRightBrace("}$");
133.184 - final String mthFormat = format.format(MTH_INIT);
133.185 -
133.186 - new TreePathScanner<Void, Void>() {
133.187 - @Override public Void visitReturn(ReturnTree node, Void p) {
133.188 - Hacks.findHintsAndApplyFixes(parameter, PatternConvertor.create(mthFormat), getCurrentPath(), cancel);
133.189 - return super.visitReturn(node, p);
133.190 - }
133.191 - @Override public Void visitClass(ClassTree node, Void p) {
133.192 - return null;
133.193 - }
133.194 - }.scan(path, null);
133.195 -
133.196 - parameter.rewrite(leaf, parameter.getTreeMaker().setLabel(leaf, invertBooleanRefactoring.getNewName()));
133.197 -
133.198 - StringBuilder parameters = new StringBuilder();
133.199 - StringBuilder constraints = new StringBuilder();
133.200 - int count = 1;
133.201 - for (VariableTree vt : mt.getParameters()) {
133.202 - if (count > 1) {
133.203 - parameters.append(", ");
133.204 - constraints.append(" && ");
133.205 - }
133.206 - parameters.append("$").append(count);
133.207 - TypeMirror type = parameter.getTrees().getTypeMirror(new TreePath(new TreePath(path, vt), vt.getType()));
133.208 - type = parameter.getTypes().erasure(type);
133.209 - constraints.append("$").append(count).append(" instanceof ").append(type);
133.210 - count++;
133.211 - }
133.212 -
133.213 - String andConstraints = (constraints.length() > 0 ? " && " : "") + constraints;
133.214 -
133.215 - StringBuilder script = new StringBuilder();
133.216 -
133.217 - if (mt.getModifiers().getFlags().contains(Modifier.STATIC)) {
133.218 - script.append(" ${enclosing}$.<$T$>${originalName}$(").append(parameters).append(") :: !parentMatches(\"!$enclosing.${originalName}$($args$)\") ").append(andConstraints);
133.219 - script.append("=> !${enclosing}$.<$T$>${newName}$(").append(parameters).append(")\n");
133.220 - script.append(";;\n");
133.221 - script.append(" !${enclosing}$.<$T$>${originalName}$(").append(parameters).append(") :: ").append(constraints);
133.222 - script.append("=> ${enclosing}$.<$T$>${newName}$(").append(parameters).append(")\n");
133.223 - script.append(";;\n");
133.224 - } else {
133.225 - script.append(" $enclosing.<$T$>${originalName}$(").append(parameters).append(") :: $enclosing instanceof ${enclosing}$ && !parentMatches(\"!$enclosing.${originalName}$($args$)\") ").append(andConstraints);
133.226 - script.append("=> !$enclosing.<$T$>${newName}$(").append(parameters).append(")\n");
133.227 - script.append(";;\n");
133.228 - script.append(" !$enclosing.<$T$>${originalName}$(").append(parameters).append(") :: $enclosing instanceof ${enclosing}$ ").append(andConstraints);
133.229 - script.append("=> $enclosing.<$T$>${newName}$(").append(parameters).append(")\n");
133.230 - script.append(";;\n");
133.231 - }
133.232 -
133.233 - scriptTemplate = script.toString();
133.234 - } else {
133.235 - throw new UnsupportedOperationException();
133.236 - }
133.237 -
133.238 - MapFormat format = new MapFormat(arguments);
133.239 -
133.240 - format.setLeftBrace("${");
133.241 - format.setRightBrace("}$");
133.242 -
133.243 - result.addScript(parent.getQualifiedName().toString(), format.format(scriptTemplate), ScriptOptions.RUN/*, ScriptOptions.STORE*/);
133.244 - }
133.245 - });
133.246 -
133.247 - result.addModificationResult(mod);
133.248 - } catch (IOException ex) {
133.249 - Exceptions.printStackTrace(ex);
133.250 - }
133.251 - }
133.252 -
133.253 -}
134.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/invertboolean/InvertBooleanRefactoringUI.java Fri Jan 27 13:35:56 2012 +0100
134.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
134.3 @@ -1,133 +0,0 @@
134.4 -/*
134.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
134.6 - *
134.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
134.8 - *
134.9 - * The contents of this file are subject to the terms of either the GNU
134.10 - * General Public License Version 2 only ("GPL") or the Common
134.11 - * Development and Distribution License("CDDL") (collectively, the
134.12 - * "License"). You may not use this file except in compliance with the
134.13 - * License. You can obtain a copy of the License at
134.14 - * http://www.netbeans.org/cddl-gplv2.html
134.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
134.16 - * specific language governing permissions and limitations under the
134.17 - * License. When distributing the software, include this License Header
134.18 - * Notice in each file and include the License file at
134.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
134.20 - * particular file as subject to the "Classpath" exception as provided
134.21 - * by Sun in the GPL Version 2 section of the License file that
134.22 - * accompanied this code. If applicable, add the following below the
134.23 - * License Header, with the fields enclosed by brackets [] replaced by
134.24 - * your own identifying information:
134.25 - * "Portions Copyrighted [year] [name of copyright owner]"
134.26 - *
134.27 - * If you wish your version of this file to be governed by only the CDDL
134.28 - * or only the GPL Version 2, indicate your decision by adding
134.29 - * "[Contributor] elects to include this software in this distribution
134.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
134.31 - * single choice of license, a recipient has the option to distribute
134.32 - * your version of this file under either the CDDL, the GPL Version 2 or
134.33 - * to extend the choice of license to its licensees as provided above.
134.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
134.35 - * Version 2 license, then the option applies only if the new code is
134.36 - * made subject to such option by the copyright holder.
134.37 - *
134.38 - * Contributor(s):
134.39 - *
134.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
134.41 - */
134.42 -
134.43 -package org.netbeans.modules.jackpot30.refactoring.invertboolean;
134.44 -
134.45 -import java.awt.Component;
134.46 -import javax.lang.model.SourceVersion;
134.47 -import javax.swing.event.ChangeListener;
134.48 -import org.netbeans.api.java.source.TreePathHandle;
134.49 -import org.netbeans.modules.refactoring.api.AbstractRefactoring;
134.50 -import org.netbeans.modules.refactoring.api.Problem;
134.51 -import org.netbeans.modules.refactoring.spi.ui.CustomRefactoringPanel;
134.52 -import org.netbeans.modules.refactoring.spi.ui.RefactoringUI;
134.53 -import org.openide.util.HelpCtx;
134.54 -
134.55 -/**
134.56 - *
134.57 - * @author lahvac
134.58 - */
134.59 -public class InvertBooleanRefactoringUI implements RefactoringUI {
134.60 -
134.61 - private final TreePathHandle path;
134.62 - private String name;
134.63 - private InvertBooleanRefactoringPanel panel;
134.64 -
134.65 - public InvertBooleanRefactoringUI(TreePathHandle path, String name) {
134.66 - this.path = path;
134.67 - this.name = name;
134.68 - }
134.69 -
134.70 - @Override
134.71 - public String getName() {
134.72 - return "InvertBooleanRefactoringUI";
134.73 - }
134.74 -
134.75 - @Override
134.76 - public String getDescription() {
134.77 - return "InvertBooleanRefactoringUI";
134.78 - }
134.79 -
134.80 - @Override
134.81 - public boolean isQuery() {
134.82 - return false;
134.83 - }
134.84 -
134.85 - @Override
134.86 - public CustomRefactoringPanel getPanel(final ChangeListener parent) {
134.87 - return new CustomRefactoringPanel() {
134.88 - @Override
134.89 - public void initialize() {
134.90 - panel.initialize(name);
134.91 - }
134.92 - @Override
134.93 - public Component getComponent() {
134.94 - if (panel == null) {
134.95 - panel = new InvertBooleanRefactoringPanel(parent);
134.96 - }
134.97 - return panel;
134.98 - }
134.99 - };
134.100 - }
134.101 -
134.102 - @Override
134.103 - public Problem setParameters() {
134.104 - this.name = panel.getName();
134.105 - return null;
134.106 - }
134.107 -
134.108 - @Override
134.109 - public Problem checkParameters() {
134.110 - String name = this.name != null ? this.name : panel.getName();
134.111 -
134.112 - if (name == null || name.length() == 0) {
134.113 - return new Problem(true, "No factory method name specified.");
134.114 - }
134.115 - if (!SourceVersion.isIdentifier(name)) {
134.116 - return new Problem(true, name + " is not an identifier.");
134.117 - }
134.118 - return null;
134.119 - }
134.120 -
134.121 - @Override
134.122 - public boolean hasParameters() {
134.123 - return true;
134.124 - }
134.125 -
134.126 - @Override
134.127 - public AbstractRefactoring getRefactoring() {
134.128 - return new InvertBooleanRefactoring(path, name);
134.129 - }
134.130 -
134.131 - @Override
134.132 - public HelpCtx getHelpCtx() {
134.133 - return null;
134.134 - }
134.135 -
134.136 -}
135.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/layer.xml Fri Jan 27 13:35:56 2012 +0100
135.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
135.3 @@ -1,34 +0,0 @@
135.4 -<?xml version="1.0" encoding="UTF-8"?>
135.5 -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
135.6 -<filesystem>
135.7 - <folder name="Actions">
135.8 - <folder name="Refactoring">
135.9 - <file name="org-netbeans-modules-jackpot30-refactoring-noconstructor-ReplaceConstructorAction.instance">
135.10 - <attr name="instanceCreate" methodvalue="org.netbeans.modules.jackpot30.refactoring.noconstructor.ReplaceConstructorAction.create"/>
135.11 - </file>
135.12 - <file name="org-netbeans-modules-jackpot30-refactoring-invertboolean-InvertBooleanAction.instance">
135.13 - <attr name="instanceCreate" methodvalue="org.netbeans.modules.jackpot30.refactoring.invertboolean.InvertBooleanAction.create"/>
135.14 - </file>
135.15 - </folder>
135.16 - </folder>
135.17 - <folder name="Menu">
135.18 - <folder name="Refactoring">
135.19 - <file name="org-netbeans-modules-jackpot30-refactoring-noconstructor-ReplaceConstructorAction-separatorAfter.instance">
135.20 - <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
135.21 - <attr name="position" intvalue="2175"/>
135.22 - </file>
135.23 - <file name="org-netbeans-modules-jackpot30-refactoring-noconstructor-ReplaceConstructorAction-separatorBefore.instance">
135.24 - <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
135.25 - <attr name="position" intvalue="2125"/>
135.26 - </file>
135.27 - <file name="org-netbeans-modules-jackpot30-refactoring-noconstructor-ReplaceConstructorAction.shadow">
135.28 - <attr name="originalFile" stringvalue="Actions/Refactoring/org-netbeans-modules-jackpot30-refactoring-noconstructor-ReplaceConstructorAction.instance"/>
135.29 - <attr name="position" intvalue="2150"/>
135.30 - </file>
135.31 - <file name="org-netbeans-modules-jackpot30-refactoring-invertboolean-InvertBooleanAction.shadow">
135.32 - <attr name="originalFile" stringvalue="Actions/Refactoring/org-netbeans-modules-jackpot30-refactoring-invertboolean-InvertBooleanAction.instance"/>
135.33 - <attr name="position" intvalue="2152"/>
135.34 - </file>
135.35 - </folder>
135.36 - </folder>
135.37 -</filesystem>
136.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/noconstructor/Bundle.properties Fri Jan 27 13:35:56 2012 +0100
136.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
136.3 @@ -1,4 +0,0 @@
136.4 -LBL_ReplaceConstructorAction=Replace C&onstructor with Factory
136.5 -CTL_ReplaceConstructorAction=Replace Constructor
136.6 -ReplaceConstructorWithFactory.jLabel1.text=Factory method name:
136.7 -ReplaceConstructorWithFactory.nameField.text=
137.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/noconstructor/ReplaceConstructorAction.java Fri Jan 27 13:35:56 2012 +0100
137.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
137.3 @@ -1,74 +0,0 @@
137.4 -/*
137.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
137.6 - *
137.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
137.8 - *
137.9 - * The contents of this file are subject to the terms of either the GNU
137.10 - * General Public License Version 2 only ("GPL") or the Common
137.11 - * Development and Distribution License("CDDL") (collectively, the
137.12 - * "License"). You may not use this file except in compliance with the
137.13 - * License. You can obtain a copy of the License at
137.14 - * http://www.netbeans.org/cddl-gplv2.html
137.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
137.16 - * specific language governing permissions and limitations under the
137.17 - * License. When distributing the software, include this License Header
137.18 - * Notice in each file and include the License file at
137.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
137.20 - * particular file as subject to the "Classpath" exception as provided
137.21 - * by Sun in the GPL Version 2 section of the License file that
137.22 - * accompanied this code. If applicable, add the following below the
137.23 - * License Header, with the fields enclosed by brackets [] replaced by
137.24 - * your own identifying information:
137.25 - * "Portions Copyrighted [year] [name of copyright owner]"
137.26 - *
137.27 - * If you wish your version of this file to be governed by only the CDDL
137.28 - * or only the GPL Version 2, indicate your decision by adding
137.29 - * "[Contributor] elects to include this software in this distribution
137.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
137.31 - * single choice of license, a recipient has the option to distribute
137.32 - * your version of this file under either the CDDL, the GPL Version 2 or
137.33 - * to extend the choice of license to its licensees as provided above.
137.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
137.35 - * Version 2 license, then the option applies only if the new code is
137.36 - * made subject to such option by the copyright holder.
137.37 - *
137.38 - * Contributor(s):
137.39 - *
137.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
137.41 - */
137.42 -package org.netbeans.modules.jackpot30.refactoring.noconstructor;
137.43 -
137.44 -import javax.swing.Action;
137.45 -import org.netbeans.modules.jackpot30.refactoring.RefactoringActionsProviderExt;
137.46 -import org.netbeans.modules.refactoring.java.ui.JavaRefactoringGlobalAction;
137.47 -import org.openide.util.HelpCtx;
137.48 -import org.openide.util.Lookup;
137.49 -import org.openide.util.NbBundle;
137.50 -
137.51 -public final class ReplaceConstructorAction extends JavaRefactoringGlobalAction {
137.52 -
137.53 - public ReplaceConstructorAction() {
137.54 - super(NbBundle.getMessage(ReplaceConstructorAction.class, "LBL_ReplaceConstructorAction"), null); // NOI18N
137.55 - putValue("noIconInMenu", Boolean.TRUE); // NOI18N
137.56 - }
137.57 -
137.58 - public final void performAction(Lookup context) {
137.59 - RefactoringActionsProviderExt.doReplaceConstructor(context);
137.60 - }
137.61 -
137.62 - public org.openide.util.HelpCtx getHelpCtx() {
137.63 - return HelpCtx.DEFAULT_HELP;
137.64 - }
137.65 -
137.66 - protected boolean asynchronous() {
137.67 - return false;
137.68 - }
137.69 -
137.70 - protected boolean enable(Lookup context) {
137.71 - return RefactoringActionsProviderExt.canReplaceConstructor(context);
137.72 - }
137.73 -
137.74 - public static Action create() {
137.75 - return ReplaceConstructorAction.findObject(ReplaceConstructorAction.class, true);
137.76 - }
137.77 -}
138.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/noconstructor/ReplaceConstructorRefactoring.java Fri Jan 27 13:35:56 2012 +0100
138.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
138.3 @@ -1,69 +0,0 @@
138.4 -/*
138.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
138.6 - *
138.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
138.8 - *
138.9 - * The contents of this file are subject to the terms of either the GNU
138.10 - * General Public License Version 2 only ("GPL") or the Common
138.11 - * Development and Distribution License("CDDL") (collectively, the
138.12 - * "License"). You may not use this file except in compliance with the
138.13 - * License. You can obtain a copy of the License at
138.14 - * http://www.netbeans.org/cddl-gplv2.html
138.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
138.16 - * specific language governing permissions and limitations under the
138.17 - * License. When distributing the software, include this License Header
138.18 - * Notice in each file and include the License file at
138.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
138.20 - * particular file as subject to the "Classpath" exception as provided
138.21 - * by Sun in the GPL Version 2 section of the License file that
138.22 - * accompanied this code. If applicable, add the following below the
138.23 - * License Header, with the fields enclosed by brackets [] replaced by
138.24 - * your own identifying information:
138.25 - * "Portions Copyrighted [year] [name of copyright owner]"
138.26 - *
138.27 - * If you wish your version of this file to be governed by only the CDDL
138.28 - * or only the GPL Version 2, indicate your decision by adding
138.29 - * "[Contributor] elects to include this software in this distribution
138.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
138.31 - * single choice of license, a recipient has the option to distribute
138.32 - * your version of this file under either the CDDL, the GPL Version 2 or
138.33 - * to extend the choice of license to its licensees as provided above.
138.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
138.35 - * Version 2 license, then the option applies only if the new code is
138.36 - * made subject to such option by the copyright holder.
138.37 - *
138.38 - * Contributor(s):
138.39 - *
138.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
138.41 - */
138.42 -
138.43 -package org.netbeans.modules.jackpot30.refactoring.noconstructor;
138.44 -
138.45 -import org.netbeans.api.java.source.TreePathHandle;
138.46 -import org.netbeans.modules.refactoring.api.AbstractRefactoring;
138.47 -import org.openide.util.lookup.Lookups;
138.48 -
138.49 -/**
138.50 - *
138.51 - * @author lahvac
138.52 - */
138.53 -public class ReplaceConstructorRefactoring extends AbstractRefactoring {
138.54 -
138.55 - private final TreePathHandle constructor;
138.56 - private final String factoryName;
138.57 -
138.58 - public ReplaceConstructorRefactoring(TreePathHandle constructor, String factoryName) {
138.59 - super(Lookups.singleton(constructor));
138.60 - this.constructor = constructor;
138.61 - this.factoryName = factoryName;
138.62 - }
138.63 -
138.64 - public TreePathHandle getConstructor() {
138.65 - return constructor;
138.66 - }
138.67 -
138.68 - public String getFactoryName() {
138.69 - return factoryName;
138.70 - }
138.71 -
138.72 -}
139.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/noconstructor/ReplaceConstructorRefactoringPluginImpl.java Fri Jan 27 13:35:56 2012 +0100
139.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
139.3 @@ -1,144 +0,0 @@
139.4 -/*
139.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
139.6 - *
139.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
139.8 - *
139.9 - * The contents of this file are subject to the terms of either the GNU
139.10 - * General Public License Version 2 only ("GPL") or the Common
139.11 - * Development and Distribution License("CDDL") (collectively, the
139.12 - * "License"). You may not use this file except in compliance with the
139.13 - * License. You can obtain a copy of the License at
139.14 - * http://www.netbeans.org/cddl-gplv2.html
139.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
139.16 - * specific language governing permissions and limitations under the
139.17 - * License. When distributing the software, include this License Header
139.18 - * Notice in each file and include the License file at
139.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
139.20 - * particular file as subject to the "Classpath" exception as provided
139.21 - * by Sun in the GPL Version 2 section of the License file that
139.22 - * accompanied this code. If applicable, add the following below the
139.23 - * License Header, with the fields enclosed by brackets [] replaced by
139.24 - * your own identifying information:
139.25 - * "Portions Copyrighted [year] [name of copyright owner]"
139.26 - *
139.27 - * If you wish your version of this file to be governed by only the CDDL
139.28 - * or only the GPL Version 2, indicate your decision by adding
139.29 - * "[Contributor] elects to include this software in this distribution
139.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
139.31 - * single choice of license, a recipient has the option to distribute
139.32 - * your version of this file under either the CDDL, the GPL Version 2 or
139.33 - * to extend the choice of license to its licensees as provided above.
139.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
139.35 - * Version 2 license, then the option applies only if the new code is
139.36 - * made subject to such option by the copyright holder.
139.37 - *
139.38 - * Contributor(s):
139.39 - *
139.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
139.41 - */
139.42 -
139.43 -package org.netbeans.modules.jackpot30.refactoring.noconstructor;
139.44 -
139.45 -import com.sun.source.tree.ClassTree;
139.46 -import com.sun.source.tree.ExpressionTree;
139.47 -import com.sun.source.tree.MethodTree;
139.48 -import com.sun.source.tree.TypeParameterTree;
139.49 -import com.sun.source.tree.VariableTree;
139.50 -import com.sun.source.util.TreePath;
139.51 -import java.io.IOException;
139.52 -import java.util.Collections;
139.53 -import java.util.EnumSet;
139.54 -import javax.lang.model.element.Modifier;
139.55 -import javax.lang.model.element.TypeElement;
139.56 -import org.netbeans.api.java.source.GeneratorUtilities;
139.57 -import org.netbeans.api.java.source.JavaSource;
139.58 -import org.netbeans.api.java.source.JavaSource.Phase;
139.59 -import org.netbeans.api.java.source.ModificationResult;
139.60 -import org.netbeans.api.java.source.Task;
139.61 -import org.netbeans.api.java.source.TreeMaker;
139.62 -import org.netbeans.api.java.source.TreePathHandle;
139.63 -import org.netbeans.api.java.source.WorkingCopy;
139.64 -import org.netbeans.modules.jackpot30.spi.refactoring.JackpotBasedRefactoring;
139.65 -import org.netbeans.modules.refactoring.api.Problem;
139.66 -import org.openide.util.Exceptions;
139.67 -
139.68 -/**
139.69 - *
139.70 - * @author lahvac
139.71 - */
139.72 -public class ReplaceConstructorRefactoringPluginImpl extends JackpotBasedRefactoring {
139.73 -
139.74 - private final ReplaceConstructorRefactoring replaceConstructorRefactoring;
139.75 -
139.76 - public ReplaceConstructorRefactoringPluginImpl(ReplaceConstructorRefactoring replaceConstructorRefactoring) {
139.77 - super(replaceConstructorRefactoring);
139.78 - this.replaceConstructorRefactoring = replaceConstructorRefactoring;
139.79 - }
139.80 -
139.81 - @Override
139.82 - public Problem preCheck() {
139.83 - return null;
139.84 - }
139.85 -
139.86 - @Override
139.87 - public Problem checkParameters() {
139.88 - return null;
139.89 - }
139.90 -
139.91 - @Override
139.92 - public Problem fastCheckParameters() {
139.93 - return null;
139.94 - }
139.95 -
139.96 - @Override
139.97 - protected void prepareAndConstructRule(final Context result) {
139.98 - final TreePathHandle constr = replaceConstructorRefactoring.getConstructor();
139.99 -
139.100 - try {
139.101 - ModificationResult mod = JavaSource.forFileObject(constr.getFileObject()).runModificationTask(new Task<WorkingCopy>() {
139.102 -
139.103 - @Override
139.104 - public void run(WorkingCopy parameter) throws Exception {
139.105 - parameter.toPhase(Phase.RESOLVED);
139.106 - TreePath constrPath = constr.resolve(parameter);
139.107 - MethodTree constructor = (MethodTree) constrPath.getLeaf();
139.108 - TypeElement parent = (TypeElement) parameter.getTrees().getElement(constrPath.getParentPath());
139.109 - TreeMaker make = parameter.getTreeMaker();
139.110 - StringBuilder parameters = new StringBuilder();
139.111 - StringBuilder constraints = new StringBuilder();
139.112 - StringBuilder realParameters = new StringBuilder();
139.113 - int count = 1;
139.114 - for (VariableTree vt : constructor.getParameters()) {
139.115 - if (count > 1) {
139.116 - parameters.append(", ");
139.117 - constraints.append(" && ");
139.118 - realParameters.append(", ");
139.119 - }
139.120 - realParameters.append(vt.getName());
139.121 - parameters.append("$").append(count);
139.122 - constraints.append("$").append(count).append(" instanceof ").append(parameter.getTrees().getTypeMirror(new TreePath(new TreePath(constrPath, vt), vt.getType())));
139.123 - count++;
139.124 - }
139.125 - EnumSet<Modifier> factoryMods = EnumSet.of(Modifier.STATIC);
139.126 - factoryMods.addAll(constructor.getModifiers().getFlags());
139.127 - MethodTree factory = make.Method(make.Modifiers(factoryMods), replaceConstructorRefactoring.getFactoryName(), make.QualIdent(parent), Collections.<TypeParameterTree>emptyList(), constructor.getParameters(), Collections.<ExpressionTree>emptyList(), "{ return new " + parent.getSimpleName() + "(" + realParameters + "); }", null);
139.128 - parameter.rewrite(constrPath.getParentPath().getLeaf(), GeneratorUtilities.get(parameter).insertClassMember((ClassTree) constrPath.getParentPath().getLeaf(), factory));
139.129 - EnumSet<Modifier> constructorMods = EnumSet.of(Modifier.PRIVATE);
139.130 - parameter.rewrite(constructor.getModifiers(), make.Modifiers(constructorMods));
139.131 - StringBuilder rule = new StringBuilder();
139.132 - rule.append("new ").append(parent.getQualifiedName()).append("(").append(parameters).append(")");
139.133 - if (constraints.length() > 0) {
139.134 - rule.append(" :: ").append(constraints);
139.135 - }
139.136 - rule.append(" => ").append(parent.getQualifiedName()).append(".").append(replaceConstructorRefactoring.getFactoryName()).append("(").append(parameters).append(");;");
139.137 - result.addScript(parent.getQualifiedName().toString(), rule.toString(), ScriptOptions.RUN, ScriptOptions.STORE);
139.138 - }
139.139 - });
139.140 -
139.141 - result.addModificationResult(mod);
139.142 - } catch (IOException ex) {
139.143 - Exceptions.printStackTrace(ex);
139.144 - }
139.145 - }
139.146 -
139.147 -}
140.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/noconstructor/ReplaceConstructorRefactoringUI.java Fri Jan 27 13:35:56 2012 +0100
140.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
140.3 @@ -1,132 +0,0 @@
140.4 -/*
140.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
140.6 - *
140.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
140.8 - *
140.9 - * The contents of this file are subject to the terms of either the GNU
140.10 - * General Public License Version 2 only ("GPL") or the Common
140.11 - * Development and Distribution License("CDDL") (collectively, the
140.12 - * "License"). You may not use this file except in compliance with the
140.13 - * License. You can obtain a copy of the License at
140.14 - * http://www.netbeans.org/cddl-gplv2.html
140.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
140.16 - * specific language governing permissions and limitations under the
140.17 - * License. When distributing the software, include this License Header
140.18 - * Notice in each file and include the License file at
140.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
140.20 - * particular file as subject to the "Classpath" exception as provided
140.21 - * by Sun in the GPL Version 2 section of the License file that
140.22 - * accompanied this code. If applicable, add the following below the
140.23 - * License Header, with the fields enclosed by brackets [] replaced by
140.24 - * your own identifying information:
140.25 - * "Portions Copyrighted [year] [name of copyright owner]"
140.26 - *
140.27 - * If you wish your version of this file to be governed by only the CDDL
140.28 - * or only the GPL Version 2, indicate your decision by adding
140.29 - * "[Contributor] elects to include this software in this distribution
140.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
140.31 - * single choice of license, a recipient has the option to distribute
140.32 - * your version of this file under either the CDDL, the GPL Version 2 or
140.33 - * to extend the choice of license to its licensees as provided above.
140.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
140.35 - * Version 2 license, then the option applies only if the new code is
140.36 - * made subject to such option by the copyright holder.
140.37 - *
140.38 - * Contributor(s):
140.39 - *
140.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
140.41 - */
140.42 -
140.43 -package org.netbeans.modules.jackpot30.refactoring.noconstructor;
140.44 -
140.45 -import java.awt.Component;
140.46 -import javax.lang.model.SourceVersion;
140.47 -import javax.swing.event.ChangeListener;
140.48 -import org.netbeans.api.java.source.TreePathHandle;
140.49 -import org.netbeans.modules.refactoring.api.AbstractRefactoring;
140.50 -import org.netbeans.modules.refactoring.api.Problem;
140.51 -import org.netbeans.modules.refactoring.spi.ui.CustomRefactoringPanel;
140.52 -import org.netbeans.modules.refactoring.spi.ui.RefactoringUI;
140.53 -import org.openide.util.HelpCtx;
140.54 -
140.55 -/**
140.56 - *
140.57 - * @author lahvac
140.58 - */
140.59 -public class ReplaceConstructorRefactoringUI implements RefactoringUI {
140.60 -
140.61 - private final TreePathHandle constructor;
140.62 - private String factoryName;
140.63 - private ReplaceConstructorWithFactory panel;
140.64 -
140.65 - public ReplaceConstructorRefactoringUI(TreePathHandle constructor) {
140.66 - this.constructor = constructor;
140.67 - }
140.68 -
140.69 - @Override
140.70 - public String getName() {
140.71 - return "ReplaceConstructorRefactoringUI";
140.72 - }
140.73 -
140.74 - @Override
140.75 - public String getDescription() {
140.76 - return "ReplaceConstructorRefactoringUI";
140.77 - }
140.78 -
140.79 - @Override
140.80 - public boolean isQuery() {
140.81 - return false;
140.82 - }
140.83 -
140.84 - @Override
140.85 - public CustomRefactoringPanel getPanel(final ChangeListener parent) {
140.86 - return new CustomRefactoringPanel() {
140.87 - @Override
140.88 - public void initialize() {
140.89 - panel.initialize();
140.90 - }
140.91 - @Override
140.92 - public Component getComponent() {
140.93 - if (panel == null) {
140.94 - panel = new ReplaceConstructorWithFactory(parent);
140.95 - }
140.96 - return panel;
140.97 - }
140.98 - };
140.99 - }
140.100 -
140.101 - @Override
140.102 - public Problem setParameters() {
140.103 - this.factoryName = panel.getFactoryName();
140.104 - return null;
140.105 - }
140.106 -
140.107 - @Override
140.108 - public Problem checkParameters() {
140.109 - String factoryName = this.factoryName != null ? this.factoryName : panel.getFactoryName();
140.110 -
140.111 - if (factoryName == null || factoryName.length() == 0) {
140.112 - return new Problem(true, "No factory method name specified.");
140.113 - }
140.114 - if (!SourceVersion.isIdentifier(factoryName)) {
140.115 - return new Problem(true, factoryName + " is not an identifier.");
140.116 - }
140.117 - return null;
140.118 - }
140.119 -
140.120 - @Override
140.121 - public boolean hasParameters() {
140.122 - return true;
140.123 - }
140.124 -
140.125 - @Override
140.126 - public AbstractRefactoring getRefactoring() {
140.127 - return new ReplaceConstructorRefactoring(constructor, factoryName);
140.128 - }
140.129 -
140.130 - @Override
140.131 - public HelpCtx getHelpCtx() {
140.132 - return null;
140.133 - }
140.134 -
140.135 -}
141.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/noconstructor/ReplaceConstructorWithFactory.form Fri Jan 27 13:35:56 2012 +0100
141.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
141.3 @@ -1,58 +0,0 @@
141.4 -<?xml version="1.1" encoding="UTF-8" ?>
141.5 -
141.6 -<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
141.7 - <AuxValues>
141.8 - <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
141.9 - <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
141.10 - <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
141.11 - <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
141.12 - <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
141.13 - <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
141.14 - <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
141.15 - <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
141.16 - <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
141.17 - </AuxValues>
141.18 -
141.19 - <Layout>
141.20 - <DimensionLayout dim="0">
141.21 - <Group type="103" groupAlignment="0" attributes="0">
141.22 - <Group type="102" alignment="0" attributes="0">
141.23 - <EmptySpace max="-2" attributes="0"/>
141.24 - <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
141.25 - <EmptySpace max="-2" attributes="0"/>
141.26 - <Component id="nameField" min="-2" max="-2" attributes="0"/>
141.27 - <EmptySpace max="32767" attributes="0"/>
141.28 - </Group>
141.29 - </Group>
141.30 - </DimensionLayout>
141.31 - <DimensionLayout dim="1">
141.32 - <Group type="103" groupAlignment="0" attributes="0">
141.33 - <Group type="102" alignment="0" attributes="0">
141.34 - <EmptySpace max="-2" attributes="0"/>
141.35 - <Group type="103" groupAlignment="3" attributes="0">
141.36 - <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
141.37 - <Component id="nameField" alignment="3" min="-2" max="-2" attributes="0"/>
141.38 - </Group>
141.39 - <EmptySpace max="32767" attributes="0"/>
141.40 - </Group>
141.41 - </Group>
141.42 - </DimensionLayout>
141.43 - </Layout>
141.44 - <SubComponents>
141.45 - <Component class="javax.swing.JLabel" name="jLabel1">
141.46 - <Properties>
141.47 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
141.48 - <ResourceString bundle="org/netbeans/modules/jackpot30/refactoring/noconstructor/Bundle.properties" key="ReplaceConstructorWithFactory.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
141.49 - </Property>
141.50 - </Properties>
141.51 - </Component>
141.52 - <Component class="javax.swing.JTextField" name="nameField">
141.53 - <Properties>
141.54 - <Property name="columns" type="int" value="15"/>
141.55 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
141.56 - <ResourceString bundle="org/netbeans/modules/jackpot30/refactoring/noconstructor/Bundle.properties" key="ReplaceConstructorWithFactory.nameField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
141.57 - </Property>
141.58 - </Properties>
141.59 - </Component>
141.60 - </SubComponents>
141.61 -</Form>
142.1 --- a/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/noconstructor/ReplaceConstructorWithFactory.java Fri Jan 27 13:35:56 2012 +0100
142.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
142.3 @@ -1,123 +0,0 @@
142.4 -/*
142.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
142.6 - *
142.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
142.8 - *
142.9 - * The contents of this file are subject to the terms of either the GNU
142.10 - * General Public License Version 2 only ("GPL") or the Common
142.11 - * Development and Distribution License("CDDL") (collectively, the
142.12 - * "License"). You may not use this file except in compliance with the
142.13 - * License. You can obtain a copy of the License at
142.14 - * http://www.netbeans.org/cddl-gplv2.html
142.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
142.16 - * specific language governing permissions and limitations under the
142.17 - * License. When distributing the software, include this License Header
142.18 - * Notice in each file and include the License file at
142.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
142.20 - * particular file as subject to the "Classpath" exception as provided
142.21 - * by Sun in the GPL Version 2 section of the License file that
142.22 - * accompanied this code. If applicable, add the following below the
142.23 - * License Header, with the fields enclosed by brackets [] replaced by
142.24 - * your own identifying information:
142.25 - * "Portions Copyrighted [year] [name of copyright owner]"
142.26 - *
142.27 - * If you wish your version of this file to be governed by only the CDDL
142.28 - * or only the GPL Version 2, indicate your decision by adding
142.29 - * "[Contributor] elects to include this software in this distribution
142.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
142.31 - * single choice of license, a recipient has the option to distribute
142.32 - * your version of this file under either the CDDL, the GPL Version 2 or
142.33 - * to extend the choice of license to its licensees as provided above.
142.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
142.35 - * Version 2 license, then the option applies only if the new code is
142.36 - * made subject to such option by the copyright holder.
142.37 - *
142.38 - * Contributor(s):
142.39 - *
142.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
142.41 - */
142.42 -
142.43 -package org.netbeans.modules.jackpot30.refactoring.noconstructor;
142.44 -
142.45 -import javax.swing.event.ChangeEvent;
142.46 -import javax.swing.event.ChangeListener;
142.47 -import javax.swing.event.DocumentEvent;
142.48 -import javax.swing.event.DocumentListener;
142.49 -import org.netbeans.api.annotations.common.NonNull;
142.50 -
142.51 -/**
142.52 - *
142.53 - * @author lahvac
142.54 - */
142.55 -public class ReplaceConstructorWithFactory extends javax.swing.JPanel {
142.56 -
142.57 - public ReplaceConstructorWithFactory(final @NonNull ChangeListener parent) {
142.58 - initComponents();
142.59 - nameField.getDocument().addDocumentListener(new DocumentListener() {
142.60 - @Override
142.61 - public void insertUpdate(DocumentEvent e) {
142.62 - parent.stateChanged(new ChangeEvent(ReplaceConstructorWithFactory.this));
142.63 - }
142.64 - @Override
142.65 - public void removeUpdate(DocumentEvent e) {
142.66 - parent.stateChanged(new ChangeEvent(ReplaceConstructorWithFactory.this));
142.67 - }
142.68 - @Override
142.69 - public void changedUpdate(DocumentEvent e) {}
142.70 - });
142.71 - }
142.72 -
142.73 - /** This method is called from within the constructor to
142.74 - * initialize the form.
142.75 - * WARNING: Do NOT modify this code. The content of this method is
142.76 - * always regenerated by the Form Editor.
142.77 - */
142.78 - @SuppressWarnings("unchecked")
142.79 - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
142.80 - private void initComponents() {
142.81 -
142.82 - jLabel1 = new javax.swing.JLabel();
142.83 - nameField = new javax.swing.JTextField();
142.84 -
142.85 - jLabel1.setText(org.openide.util.NbBundle.getMessage(ReplaceConstructorWithFactory.class, "ReplaceConstructorWithFactory.jLabel1.text")); // NOI18N
142.86 -
142.87 - nameField.setColumns(15);
142.88 - nameField.setText(org.openide.util.NbBundle.getMessage(ReplaceConstructorWithFactory.class, "ReplaceConstructorWithFactory.nameField.text")); // NOI18N
142.89 -
142.90 - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
142.91 - this.setLayout(layout);
142.92 - layout.setHorizontalGroup(
142.93 - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
142.94 - .addGroup(layout.createSequentialGroup()
142.95 - .addContainerGap()
142.96 - .addComponent(jLabel1)
142.97 - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
142.98 - .addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
142.99 - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
142.100 - );
142.101 - layout.setVerticalGroup(
142.102 - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
142.103 - .addGroup(layout.createSequentialGroup()
142.104 - .addContainerGap()
142.105 - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
142.106 - .addComponent(jLabel1)
142.107 - .addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
142.108 - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
142.109 - );
142.110 - }// </editor-fold>//GEN-END:initComponents
142.111 -
142.112 -
142.113 - // Variables declaration - do not modify//GEN-BEGIN:variables
142.114 - private javax.swing.JLabel jLabel1;
142.115 - private javax.swing.JTextField nameField;
142.116 - // End of variables declaration//GEN-END:variables
142.117 -
142.118 - public void initialize() {
142.119 - //TODO: more meaningful name(s)?
142.120 - nameField.setText("create");
142.121 - }
142.122 -
142.123 - public String getFactoryName() {
142.124 - return nameField.getText();
142.125 - }
142.126 -}
143.1 --- a/bridges/refactoring/test/unit/src/org/netbeans/modules/jackpot30/refactoring/RefactoringTestBase.java Fri Jan 27 13:35:56 2012 +0100
143.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
143.3 @@ -1,251 +0,0 @@
143.4 -/*
143.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
143.6 - *
143.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
143.8 - *
143.9 - * The contents of this file are subject to the terms of either the GNU
143.10 - * General Public License Version 2 only ("GPL") or the Common
143.11 - * Development and Distribution License("CDDL") (collectively, the
143.12 - * "License"). You may not use this file except in compliance with the
143.13 - * License. You can obtain a copy of the License at
143.14 - * http://www.netbeans.org/cddl-gplv2.html
143.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
143.16 - * specific language governing permissions and limitations under the
143.17 - * License. When distributing the software, include this License Header
143.18 - * Notice in each file and include the License file at
143.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
143.20 - * particular file as subject to the "Classpath" exception as provided
143.21 - * by Sun in the GPL Version 2 section of the License file that
143.22 - * accompanied this code. If applicable, add the following below the
143.23 - * License Header, with the fields enclosed by brackets [] replaced by
143.24 - * your own identifying information:
143.25 - * "Portions Copyrighted [year] [name of copyright owner]"
143.26 - *
143.27 - * If you wish your version of this file to be governed by only the CDDL
143.28 - * or only the GPL Version 2, indicate your decision by adding
143.29 - * "[Contributor] elects to include this software in this distribution
143.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
143.31 - * single choice of license, a recipient has the option to distribute
143.32 - * your version of this file under either the CDDL, the GPL Version 2 or
143.33 - * to extend the choice of license to its licensees as provided above.
143.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
143.35 - * Version 2 license, then the option applies only if the new code is
143.36 - * made subject to such option by the copyright holder.
143.37 - *
143.38 - * Contributor(s):
143.39 - *
143.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
143.41 - */
143.42 -package org.netbeans.modules.jackpot30.refactoring;
143.43 -
143.44 -import java.io.IOException;
143.45 -import java.util.Arrays;
143.46 -import java.util.Collections;
143.47 -import java.util.HashMap;
143.48 -import java.util.HashSet;
143.49 -import java.util.LinkedList;
143.50 -import java.util.List;
143.51 -import java.util.Map;
143.52 -import java.util.Set;
143.53 -import org.netbeans.api.editor.mimelookup.MimePath;
143.54 -import org.netbeans.api.java.classpath.ClassPath;
143.55 -import org.netbeans.api.java.classpath.GlobalPathRegistry;
143.56 -import org.netbeans.api.java.source.SourceUtils;
143.57 -import org.netbeans.api.java.source.SourceUtilsTestUtil;
143.58 -import org.netbeans.api.java.source.TestUtilities;
143.59 -import org.netbeans.api.project.Project;
143.60 -import org.netbeans.api.project.ProjectManager;
143.61 -import org.netbeans.core.startup.Main;
143.62 -import org.netbeans.junit.NbTestCase;
143.63 -import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
143.64 -import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
143.65 -import org.netbeans.modules.parsing.impl.indexing.MimeTypes;
143.66 -import org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater;
143.67 -import org.netbeans.modules.refactoring.api.AbstractRefactoring;
143.68 -import org.netbeans.modules.refactoring.api.RefactoringSession;
143.69 -import org.netbeans.spi.editor.mimelookup.MimeDataProvider;
143.70 -import org.netbeans.spi.java.classpath.ClassPathProvider;
143.71 -import org.netbeans.spi.java.classpath.support.ClassPathSupport;
143.72 -import org.netbeans.spi.project.ProjectFactory;
143.73 -import org.netbeans.spi.project.ProjectState;
143.74 -import org.openide.filesystems.FileObject;
143.75 -import org.openide.filesystems.FileUtil;
143.76 -import org.openide.util.Lookup;
143.77 -import org.openide.util.lookup.Lookups;
143.78 -import org.openide.util.lookup.ServiceProvider;
143.79 -
143.80 -public class RefactoringTestBase extends NbTestCase {
143.81 -
143.82 - public RefactoringTestBase(String name) {
143.83 - super(name);
143.84 - }
143.85 -
143.86 - protected static void writeFilesAndWaitForScan(FileObject sourceRoot, File... files) throws Exception {
143.87 - for (FileObject c : sourceRoot.getChildren()) {
143.88 - c.delete();
143.89 - }
143.90 -
143.91 - for (File f : files) {
143.92 - FileObject fo = FileUtil.createData(sourceRoot, f.filename);
143.93 - TestUtilities.copyStringToFile(fo, f.content);
143.94 - }
143.95 -
143.96 - SourceUtils.waitScanFinished();
143.97 - }
143.98 -
143.99 - protected static final class File {
143.100 - public final String filename;
143.101 - public final String content;
143.102 -
143.103 - public File(String filename, String content) {
143.104 - this.filename = filename;
143.105 - this.content = content;
143.106 - }
143.107 - }
143.108 -
143.109 - protected FileObject src;
143.110 - protected Project prj;
143.111 -
143.112 - @Override
143.113 - protected void setUp() throws Exception {
143.114 - SourceUtilsTestUtil.prepareTest(new String[0], new Object[] {
143.115 - new ClassPathProvider() {
143.116 - public ClassPath findClassPath(FileObject file, String type) {
143.117 - if (src != null && (file == src || FileUtil.isParentOf(src, file))) {
143.118 - if (ClassPath.BOOT.equals(type)) {
143.119 - return ClassPathSupport.createClassPath(System.getProperty("sun.boot.class.path"));
143.120 - }
143.121 - if (ClassPath.COMPILE.equals(type)) {
143.122 - return ClassPathSupport.createClassPath(new FileObject[0]);
143.123 - }
143.124 - if (ClassPath.SOURCE.equals(type)) {
143.125 - return ClassPathSupport.createClassPath(src);
143.126 - }
143.127 - }
143.128 -
143.129 - return null;
143.130 - }
143.131 - },
143.132 - new ProjectFactory() {
143.133 - public boolean isProject(FileObject projectDirectory) {
143.134 - return src == projectDirectory;
143.135 - }
143.136 - public Project loadProject(final FileObject projectDirectory, ProjectState state) throws IOException {
143.137 - if (!isProject(projectDirectory)) return null;
143.138 - return new Project() {
143.139 - public FileObject getProjectDirectory() {
143.140 - return projectDirectory;
143.141 - }
143.142 - public Lookup getLookup() {
143.143 - return Lookup.EMPTY;
143.144 - }
143.145 - };
143.146 - }
143.147 - public void saveProject(Project project) throws IOException, ClassCastException {}
143.148 - }
143.149 - });
143.150 - Main.initializeURLFactory();
143.151 - org.netbeans.api.project.ui.OpenProjects.getDefault().getOpenProjects();
143.152 - prepareTest();
143.153 - org.netbeans.api.project.ui.OpenProjects.getDefault().open(new Project[] {prj = ProjectManager.getDefault().findProject(src)}, false);
143.154 - MimeTypes.setAllMimeTypes(Collections.singleton("text/x-java"));
143.155 - GlobalPathRegistry.getDefault().register(ClassPath.SOURCE, new ClassPath[] {ClassPathSupport.createClassPath(src)});
143.156 - RepositoryUpdater.getDefault().start(true);
143.157 - super.setUp();
143.158 - }
143.159 -
143.160 - @Override
143.161 - protected void tearDown() throws Exception {
143.162 - super.tearDown();
143.163 - org.netbeans.api.project.ui.OpenProjects.getDefault().open(new Project[] {prj}, false);
143.164 - prj = null;
143.165 - }
143.166 -
143.167 - private void prepareTest() throws Exception {
143.168 - FileObject workdir = SourceUtilsTestUtil.makeScratchDir(this);
143.169 -
143.170 - src = FileUtil.createFolder(workdir, "src");
143.171 -
143.172 - FileObject cache = FileUtil.createFolder(workdir, "cache");
143.173 -
143.174 - CacheFolder.setCacheFolder(cache);
143.175 - }
143.176 -
143.177 - protected void performRefactoring(AbstractRefactoring r, File... verify) throws IOException {
143.178 - Map<FileObject, String> originalContent = new HashMap<FileObject, String>();
143.179 -
143.180 - for (FileObject file : recursive(src)) {
143.181 - originalContent.put(file, readFile(file));
143.182 - }
143.183 -
143.184 - RefactoringSession rs = RefactoringSession.create("Session");
143.185 -
143.186 - r.prepare(rs);
143.187 -
143.188 - assertNull(rs.doRefactoring(true));
143.189 -
143.190 -// IndexingManager.getDefault().refreshIndex(src.getURL(), null);
143.191 -// SourceUtils.waitScanFinished();
143.192 -// assertEquals(false, TaskCache.getDefault().isInError(src, true));
143.193 -
143.194 - for (File v : verify) {
143.195 - FileObject file = src.getFileObject(v.filename);
143.196 -
143.197 - assertNotNull(v.filename, file);
143.198 -
143.199 - String content = readFile(file);
143.200 -
143.201 - assertEquals(v.content.replaceAll("[ \n\t]+", " "), content.replaceAll("[ \n\t]+", " "));
143.202 - }
143.203 -
143.204 - rs.undoRefactoring(true);
143.205 -
143.206 - for (FileObject file : recursive(src)) {
143.207 - String content = originalContent.remove(file);
143.208 -
143.209 - assertNotNull(FileUtil.getFileDisplayName(file), content);
143.210 - assertEquals(content, readFile(file));
143.211 - }
143.212 -
143.213 - assertTrue(originalContent.toString(), originalContent.isEmpty());
143.214 - }
143.215 -
143.216 - private String readFile(FileObject file) throws IOException {
143.217 - return TestUtilities.copyFileToString(FileUtil.toFile(file));
143.218 - }
143.219 -
143.220 - private static Iterable<? extends FileObject> recursive(FileObject r) {
143.221 - Set<FileObject> result = new HashSet<FileObject>();
143.222 - List<FileObject> queue = new LinkedList<FileObject>();
143.223 -
143.224 - queue.add(r);
143.225 -
143.226 - while (!queue.isEmpty()) {
143.227 - FileObject c = queue.remove(0);
143.228 -
143.229 - if (c.isData()) {
143.230 - result.add(c);
143.231 - } else {
143.232 - queue.addAll(Arrays.asList(c.getChildren()));
143.233 - }
143.234 - }
143.235 -
143.236 - return result;
143.237 - }
143.238 -
143.239 - @ServiceProvider(service=MimeDataProvider.class)
143.240 - public static final class MimeDataProviderImpl implements MimeDataProvider {
143.241 -
143.242 - private static final Lookup L = Lookups.singleton(new JavaCustomIndexer.Factory());
143.243 -
143.244 - public Lookup getLookup(MimePath mimePath) {
143.245 - if ("text/x-java".equals(mimePath.getPath())) {
143.246 - return L;
143.247 - }
143.248 -
143.249 - return null;
143.250 - }
143.251 -
143.252 - }
143.253 -
143.254 -}
144.1 --- a/bridges/refactoring/test/unit/src/org/netbeans/modules/jackpot30/refactoring/RenameRefactoringPluginImplTest.java Fri Jan 27 13:35:56 2012 +0100
144.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
144.3 @@ -1,111 +0,0 @@
144.4 -/*
144.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
144.6 - *
144.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
144.8 - *
144.9 - * The contents of this file are subject to the terms of either the GNU
144.10 - * General Public License Version 2 only ("GPL") or the Common
144.11 - * Development and Distribution License("CDDL") (collectively, the
144.12 - * "License"). You may not use this file except in compliance with the
144.13 - * License. You can obtain a copy of the License at
144.14 - * http://www.netbeans.org/cddl-gplv2.html
144.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
144.16 - * specific language governing permissions and limitations under the
144.17 - * License. When distributing the software, include this License Header
144.18 - * Notice in each file and include the License file at
144.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
144.20 - * particular file as subject to the "Classpath" exception as provided
144.21 - * by Sun in the GPL Version 2 section of the License file that
144.22 - * accompanied this code. If applicable, add the following below the
144.23 - * License Header, with the fields enclosed by brackets [] replaced by
144.24 - * your own identifying information:
144.25 - * "Portions Copyrighted [year] [name of copyright owner]"
144.26 - *
144.27 - * If you wish your version of this file to be governed by only the CDDL
144.28 - * or only the GPL Version 2, indicate your decision by adding
144.29 - * "[Contributor] elects to include this software in this distribution
144.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
144.31 - * single choice of license, a recipient has the option to distribute
144.32 - * your version of this file under either the CDDL, the GPL Version 2 or
144.33 - * to extend the choice of license to its licensees as provided above.
144.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
144.35 - * Version 2 license, then the option applies only if the new code is
144.36 - * made subject to such option by the copyright holder.
144.37 - *
144.38 - * Contributor(s):
144.39 - *
144.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
144.41 - */
144.42 -package org.netbeans.modules.jackpot30.refactoring;
144.43 -
144.44 -import com.sun.source.tree.ClassTree;
144.45 -import com.sun.source.tree.CompilationUnitTree;
144.46 -import com.sun.source.tree.MethodTree;
144.47 -import com.sun.source.util.TreePath;
144.48 -import org.netbeans.api.java.source.CompilationController;
144.49 -import org.netbeans.api.java.source.JavaSource;
144.50 -import org.netbeans.api.java.source.Task;
144.51 -import org.netbeans.api.java.source.TreePathHandle;
144.52 -import org.netbeans.modules.refactoring.api.RenameRefactoring;
144.53 -import org.openide.util.lookup.Lookups;
144.54 -
144.55 -public class RenameRefactoringPluginImplTest extends RefactoringTestBase {
144.56 -
144.57 - public RenameRefactoringPluginImplTest(String name) {
144.58 - super(name);
144.59 - }
144.60 -
144.61 - public void testSimple1() throws Exception {
144.62 - writeFilesAndWaitForScan(src,
144.63 - new File("t/A.java", "package t; public class A {\n public void test() {\n}\n }"));
144.64 - final RenameRefactoring[] r = new RenameRefactoring[1];
144.65 -
144.66 - JavaSource.forFileObject(src.getFileObject("t/A.java")).runUserActionTask(new Task<CompilationController>() {
144.67 -
144.68 - public void run(CompilationController parameter) throws Exception {
144.69 - parameter.toPhase(JavaSource.Phase.RESOLVED);
144.70 - CompilationUnitTree cut = parameter.getCompilationUnit();
144.71 -
144.72 - MethodTree var = (MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(1);
144.73 -
144.74 - TreePath tp = TreePath.getPath(cut, var);
144.75 - r[0] = new RenameRefactoring(Lookups.singleton(TreePathHandle.create(tp, parameter)));
144.76 - }
144.77 - }, true);
144.78 -
144.79 - r[0].setNewName("foo");
144.80 - r[0].getContext().add(new ExtraData(true, true, true));
144.81 -
144.82 - performRefactoring(r[0],
144.83 - new File("t/A.java", "package t; public class A { @Deprecated private void test() { foo(); } public void foo() { } }"),
144.84 - new File("META-INF/upgrade/t.A.hint", " $0.test() :: $0 instanceof t.A => $0.foo() ;; "));
144.85 - }
144.86 -
144.87 - public void testSimple2() throws Exception {
144.88 - writeFilesAndWaitForScan(src,
144.89 - new File("t/A.java", "package t; public class A {\n public void test() {\n}\n }"),
144.90 - new File("META-INF/upgrade/t.A.hint", "$0.isDirectory();; "));
144.91 - final RenameRefactoring[] r = new RenameRefactoring[1];
144.92 -
144.93 - JavaSource.forFileObject(src.getFileObject("t/A.java")).runUserActionTask(new Task<CompilationController>() {
144.94 -
144.95 - public void run(CompilationController parameter) throws Exception {
144.96 - parameter.toPhase(JavaSource.Phase.RESOLVED);
144.97 - CompilationUnitTree cut = parameter.getCompilationUnit();
144.98 -
144.99 - MethodTree var = (MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(1);
144.100 -
144.101 - TreePath tp = TreePath.getPath(cut, var);
144.102 - r[0] = new RenameRefactoring(Lookups.singleton(TreePathHandle.create(tp, parameter)));
144.103 - }
144.104 - }, true);
144.105 -
144.106 - r[0].setNewName("foo");
144.107 - r[0].getContext().add(new ExtraData(true, /*XXX: false will fail badly here!!*/true, false));
144.108 -
144.109 - performRefactoring(r[0],
144.110 - new File("t/A.java", "package t; public class A { private void test() { foo(); } public void foo() { } }"),
144.111 - new File("META-INF/upgrade/t.A.hint", "$0.isDirectory();; $0.test() :: $0 instanceof t.A => $0.foo() ;; "));
144.112 - }
144.113 -
144.114 -}
145.1 --- a/bridges/refactoring/test/unit/src/org/netbeans/modules/jackpot30/refactoring/ScriptGeneratorTest.java Fri Jan 27 13:35:56 2012 +0100
145.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
145.3 @@ -1,135 +0,0 @@
145.4 -/*
145.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
145.6 - *
145.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
145.8 - *
145.9 - * The contents of this file are subject to the terms of either the GNU
145.10 - * General Public License Version 2 only ("GPL") or the Common
145.11 - * Development and Distribution License("CDDL") (collectively, the
145.12 - * "License"). You may not use this file except in compliance with the
145.13 - * License. You can obtain a copy of the License at
145.14 - * http://www.netbeans.org/cddl-gplv2.html
145.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
145.16 - * specific language governing permissions and limitations under the
145.17 - * License. When distributing the software, include this License Header
145.18 - * Notice in each file and include the License file at
145.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
145.20 - * particular file as subject to the "Classpath" exception as provided
145.21 - * by Sun in the GPL Version 2 section of the License file that
145.22 - * accompanied this code. If applicable, add the following below the
145.23 - * License Header, with the fields enclosed by brackets [] replaced by
145.24 - * your own identifying information:
145.25 - * "Portions Copyrighted [year] [name of copyright owner]"
145.26 - *
145.27 - * If you wish your version of this file to be governed by only the CDDL
145.28 - * or only the GPL Version 2, indicate your decision by adding
145.29 - * "[Contributor] elects to include this software in this distribution
145.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
145.31 - * single choice of license, a recipient has the option to distribute
145.32 - * your version of this file under either the CDDL, the GPL Version 2 or
145.33 - * to extend the choice of license to its licensees as provided above.
145.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
145.35 - * Version 2 license, then the option applies only if the new code is
145.36 - * made subject to such option by the copyright holder.
145.37 - *
145.38 - * Contributor(s):
145.39 - *
145.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
145.41 - */
145.42 -
145.43 -package org.netbeans.modules.jackpot30.refactoring;
145.44 -
145.45 -import com.sun.source.util.TreePath;
145.46 -import java.util.regex.Pattern;
145.47 -import javax.lang.model.element.Element;
145.48 -import org.netbeans.api.java.source.SourceUtilsTestUtil;
145.49 -import org.netbeans.modules.jackpot30.impl.TestBase;
145.50 -
145.51 -/**
145.52 - *
145.53 - * @author lahvac
145.54 - */
145.55 -public class ScriptGeneratorTest extends TestBase {
145.56 -
145.57 - public ScriptGeneratorTest(String testName) {
145.58 - super(testName);
145.59 - }
145.60 -
145.61 - @Override
145.62 - protected void setUp() throws Exception {
145.63 - SourceUtilsTestUtil.prepareTest(new String[0], new Object[0]);
145.64 - super.setUp();
145.65 - }
145.66 -
145.67 - public void testInstanceMethod() throws Exception {
145.68 - performTest("package test;\n" +
145.69 - "public class Test {\n" +
145.70 - " public void te|st() {}" +
145.71 - "}\n",
145.72 - "foo",
145.73 - " $0.test() :: $0 instanceof test.Test\n" +
145.74 - "=> $0.foo()\n" +
145.75 - ";;");
145.76 - }
145.77 -
145.78 - public void testInstanceMethodParam() throws Exception {
145.79 - performTest("package test;\n" +
145.80 - "public class Test {\n" +
145.81 - " public void te|st(int i) {}" +
145.82 - "}\n",
145.83 - "foo",
145.84 - " $0.test($i) :: $0 instanceof test.Test && $i instanceof int\n" +
145.85 - "=> $0.foo($i)\n" +
145.86 - ";;");
145.87 - }
145.88 -
145.89 - public void testStaticMethod() throws Exception {
145.90 - performTest("package test;\n" +
145.91 - "public class Test {\n" +
145.92 - " public static void te|st() {}" +
145.93 - "}\n",
145.94 - "foo",
145.95 - " test.Test.test()\n" +
145.96 - "=> test.Test.foo()\n" +
145.97 - ";;");
145.98 - }
145.99 -
145.100 - public void testStaticMethodParam() throws Exception {
145.101 - performTest("package test;\n" +
145.102 - "public class Test {\n" +
145.103 - " public static void te|st(int i) {}" +
145.104 - "}\n",
145.105 - "foo",
145.106 - " test.Test.test($i) :: $i instanceof int\n" +
145.107 - "=> test.Test.foo($i)\n" +
145.108 - ";;");
145.109 - }
145.110 -
145.111 - public void testMultipleParameters183659() throws Exception {
145.112 - performTest("package test;\n" +
145.113 - "public class Test {\n" +
145.114 - " public void te|st(int i, int j) {}" +
145.115 - "}\n",
145.116 - "foo",
145.117 - " $0.test($i, $j) :: $0 instanceof test.Test && $i instanceof int && $j instanceof int\n" +
145.118 - "=> $0.foo($i, $j)\n" +
145.119 - ";;");
145.120 - }
145.121 -
145.122 - private void performTest(String code, String newName, String script) throws Exception {
145.123 - assertEquals(2, code.split(Pattern.quote("|")).length);
145.124 -
145.125 - int pos = code.indexOf('|');
145.126 -
145.127 - code = code.substring(0, pos) + code.substring(pos + 1);
145.128 -
145.129 - prepareTest("test/Test.java", code);
145.130 -
145.131 - TreePath path = info.getTreeUtilities().pathFor(pos);
145.132 - Element el = info.getTrees().getElement(path);
145.133 -
145.134 - assertNotNull(el);
145.135 -
145.136 - assertEquals(script, ScriptGenerator.constructRenameRule(null, newName, el));
145.137 - }
145.138 -}
146.1 --- a/bridges/refactoring/test/unit/src/org/netbeans/modules/jackpot30/refactoring/invertboolean/InvertBooleanRefactoringPluginImplTest.java Fri Jan 27 13:35:56 2012 +0100
146.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
146.3 @@ -1,192 +0,0 @@
146.4 -/*
146.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
146.6 - *
146.7 - * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
146.8 - *
146.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
146.10 - * Other names may be trademarks of their respective owners.
146.11 - *
146.12 - * The contents of this file are subject to the terms of either the GNU
146.13 - * General Public License Version 2 only ("GPL") or the Common
146.14 - * Development and Distribution License("CDDL") (collectively, the
146.15 - * "License"). You may not use this file except in compliance with the
146.16 - * License. You can obtain a copy of the License at
146.17 - * http://www.netbeans.org/cddl-gplv2.html
146.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
146.19 - * specific language governing permissions and limitations under the
146.20 - * License. When distributing the software, include this License Header
146.21 - * Notice in each file and include the License file at
146.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
146.23 - * particular file as subject to the "Classpath" exception as provided
146.24 - * by Oracle in the GPL Version 2 section of the License file that
146.25 - * accompanied this code. If applicable, add the following below the
146.26 - * License Header, with the fields enclosed by brackets [] replaced by
146.27 - * your own identifying information:
146.28 - * "Portions Copyrighted [year] [name of copyright owner]"
146.29 - *
146.30 - * If you wish your version of this file to be governed by only the CDDL
146.31 - * or only the GPL Version 2, indicate your decision by adding
146.32 - * "[Contributor] elects to include this software in this distribution
146.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
146.34 - * single choice of license, a recipient has the option to distribute
146.35 - * your version of this file under either the CDDL, the GPL Version 2 or
146.36 - * to extend the choice of license to its licensees as provided above.
146.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
146.38 - * Version 2 license, then the option applies only if the new code is
146.39 - * made subject to such option by the copyright holder.
146.40 - *
146.41 - * Contributor(s):
146.42 - *
146.43 - * Portions Copyrighted 2011 Sun Microsystems, Inc.
146.44 - */
146.45 -
146.46 -package org.netbeans.modules.jackpot30.refactoring.invertboolean;
146.47 -
146.48 -import com.sun.source.tree.ClassTree;
146.49 -import com.sun.source.tree.CompilationUnitTree;
146.50 -import com.sun.source.tree.MethodTree;
146.51 -import com.sun.source.tree.VariableTree;
146.52 -import com.sun.source.util.TreePath;
146.53 -import org.netbeans.api.java.source.CompilationController;
146.54 -import org.netbeans.api.java.source.JavaSource;
146.55 -import org.netbeans.api.java.source.SourceUtils;
146.56 -import org.netbeans.api.java.source.Task;
146.57 -import org.netbeans.api.java.source.TreePathHandle;
146.58 -import org.netbeans.modules.jackpot30.spi.refactoring.JackpotBasedRefactoringTestBase;
146.59 -import org.netbeans.modules.parsing.api.indexing.IndexingManager;
146.60 -import org.netbeans.modules.parsing.impl.indexing.errors.TaskCache;
146.61 -import org.netbeans.modules.refactoring.api.RefactoringSession;
146.62 -import org.openide.filesystems.FileObject;
146.63 -
146.64 -/**
146.65 - *
146.66 - * @author lahvac
146.67 - */
146.68 -public class InvertBooleanRefactoringPluginImplTest extends JackpotBasedRefactoringTestBase {
146.69 -
146.70 - public InvertBooleanRefactoringPluginImplTest(String name) {
146.71 - super(name);
146.72 - }
146.73 -
146.74 - public void testInvertField1() throws Exception {
146.75 - writeFilesAndWaitForScan(src,
146.76 - new File("test/Test.java", "package test;\n public class Test {\n public boolean b = Boolean.getBoolean(\"\"); { b = Boolean.getBoolean(\"\"); if (b) System.err.println(1);\n } }\n"),
146.77 - new File("test/Use.java", "package test; public class Use { { new Test().b = Boolean.getBoolean(\"\"); if (new Test().b) System.err.println(1);\n } }")
146.78 - );
146.79 -
146.80 - performFieldTest();
146.81 -
146.82 - assertContent(src,
146.83 - new File("test/Test.java", "package test;\n public class Test {\n public boolean c = !Boolean.getBoolean(\"\"); { c = !Boolean.getBoolean(\"\"); if (!c) System.err.println(1);\n } }\n"),
146.84 - new File("test/Use.java", "package test; public class Use { { new Test().c = !Boolean.getBoolean(\"\"); if (!new Test().c) System.err.println(1);\n } }")/*,
146.85 - new File("META-INF/upgrade/test.Test.hint", "new test.Test($1, $2) :: $1 instanceof int && $2 instanceof java.util.List<java.lang.String> => test.Test.create($1, $2);;")*/
146.86 - );
146.87 - }
146.88 -
146.89 - public void testInvertField2() throws Exception {
146.90 - writeFilesAndWaitForScan(src,
146.91 - new File("test/Test.java", "package test;\n public class Test {\n public boolean b = Integer.getInteger(\"\") == 0; { b = Integer.getInteger(\"\") != 0; b = !b; boolean n1 = false; b = !n1; b = !(n1); b = (!n1); b = true; b = false; System.err.println(!b);\n } }\n")
146.92 - );
146.93 -
146.94 - performFieldTest();
146.95 -
146.96 - assertContent(src,
146.97 - new File("test/Test.java", "package test;\n public class Test {\n public boolean c = Integer.getInteger(\"\") != 0; { c = Integer.getInteger(\"\") == 0; c = !c; boolean n1 = false; c = n1; c = n1; c = n1; c = false; c = true; System.err.println(c);\n } }\n")/*,
146.98 - new File("META-INF/upgrade/test.Test.hint", "new test.Test($1, $2) :: $1 instanceof int && $2 instanceof java.util.List<java.lang.String> => test.Test.create($1, $2);;")*/
146.99 - );
146.100 - }
146.101 -
146.102 - public void testInvertFieldStatic() throws Exception {
146.103 - writeFilesAndWaitForScan(src,
146.104 - new File("test/Test.java", "package test;\n public class Test {\n public static boolean b = true; static { b = Integer.getInteger(\"\") != 0; \n } }\n")
146.105 - );
146.106 -
146.107 - performFieldTest();
146.108 -
146.109 - assertContent(src,
146.110 - new File("test/Test.java", "package test;\n public class Test {\n public static boolean c = false; static { " + /*XXX:*/ "Test." + "c = Integer.getInteger(\"\") == 0; \n } }\n")/*,
146.111 - new File("META-INF/upgrade/test.Test.hint", "new test.Test($1, $2) :: $1 instanceof int && $2 instanceof java.util.List<java.lang.String> => test.Test.create($1, $2);;")*/
146.112 - );
146.113 - }
146.114 -
146.115 - public void testInvertMethod() throws Exception {
146.116 - writeFilesAndWaitForScan(src,
146.117 - new File("test/Test.java", "package test;\n public class Test {\n public boolean b() { if (true) return Boolean.getBoolean(\"\"); else return false; } { if (b()) System.err.println(1); \n } }\n"),
146.118 - new File("test/Use.java", "package test; public class Use { { if (!new Test().b()) System.err.println(1);\n } }")
146.119 - );
146.120 -
146.121 - performMethodTest();
146.122 -
146.123 - assertContent(src,
146.124 - new File("test/Test.java", "package test;\n public class Test {\n public boolean c() { if (true) return !Boolean.getBoolean(\"\"); else return true; } { if (!c()) System.err.println(1); \n } }\n"),
146.125 - new File("test/Use.java", "package test; public class Use { { if (new Test().c()) System.err.println(1);\n } }")/*,
146.126 - new File("META-INF/upgrade/test.Test.hint", "new test.Test($1, $2) :: $1 instanceof int && $2 instanceof java.util.List<java.lang.String> => test.Test.create($1, $2);;")*/
146.127 - );
146.128 - }
146.129 -
146.130 - public void testInvertMethodStaticTypeParam() throws Exception {
146.131 - writeFilesAndWaitForScan(src,
146.132 - new File("test/Test.java", "package test;\n public class Test {\n public static <T> boolean b(T t) { return true; } { if (Test.<String>b(null)) System.err.println(1); \n } }\n")
146.133 - );
146.134 -
146.135 - performMethodTest();
146.136 -
146.137 - assertContent(src,
146.138 - new File("test/Test.java", "package test;\n public class Test {\n public static <T> boolean c(T t) { return false; } { if (!Test.<String>c(null)) System.err.println(1); \n } }\n")/*,
146.139 - new File("META-INF/upgrade/test.Test.hint", "new test.Test($1, $2) :: $1 instanceof int && $2 instanceof java.util.List<java.lang.String> => test.Test.create($1, $2);;")*/
146.140 - );
146.141 - }
146.142 -
146.143 - private void performFieldTest() throws Exception {
146.144 - final InvertBooleanRefactoring[] r = new InvertBooleanRefactoring[1];
146.145 - FileObject testFile = src.getFileObject("test/Test.java");
146.146 -
146.147 - JavaSource.forFileObject(testFile).runUserActionTask(new Task<CompilationController>() {
146.148 -
146.149 - public void run(CompilationController parameter) throws Exception {
146.150 - parameter.toPhase(JavaSource.Phase.RESOLVED);
146.151 - CompilationUnitTree cut = parameter.getCompilationUnit();
146.152 -
146.153 - VariableTree var = (VariableTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(1);
146.154 -
146.155 - TreePath tp = TreePath.getPath(cut, var);
146.156 - r[0] = new InvertBooleanRefactoring(TreePathHandle.create(tp, parameter), "c");
146.157 - }
146.158 - }, true);
146.159 -
146.160 - RefactoringSession rs = RefactoringSession.create("Session");
146.161 - r[0].prepare(rs);
146.162 - rs.doRefactoring(true);
146.163 -
146.164 - IndexingManager.getDefault().refreshIndex(src.getURL(), null);
146.165 - SourceUtils.waitScanFinished();
146.166 - assertEquals(false, TaskCache.getDefault().isInError(src, true));
146.167 - }
146.168 -
146.169 - private void performMethodTest() throws Exception {
146.170 - final InvertBooleanRefactoring[] r = new InvertBooleanRefactoring[1];
146.171 - FileObject testFile = src.getFileObject("test/Test.java");
146.172 -
146.173 - JavaSource.forFileObject(testFile).runUserActionTask(new Task<CompilationController>() {
146.174 -
146.175 - public void run(CompilationController parameter) throws Exception {
146.176 - parameter.toPhase(JavaSource.Phase.RESOLVED);
146.177 - CompilationUnitTree cut = parameter.getCompilationUnit();
146.178 -
146.179 - MethodTree var = (MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(1);
146.180 -
146.181 - TreePath tp = TreePath.getPath(cut, var);
146.182 - r[0] = new InvertBooleanRefactoring(TreePathHandle.create(tp, parameter), "c");
146.183 - }
146.184 - }, true);
146.185 -
146.186 - RefactoringSession rs = RefactoringSession.create("Session");
146.187 - r[0].prepare(rs);
146.188 - rs.doRefactoring(true);
146.189 -
146.190 - IndexingManager.getDefault().refreshIndex(src.getURL(), null);
146.191 - SourceUtils.waitScanFinished();
146.192 - assertEquals(false, TaskCache.getDefault().isInError(src, true));
146.193 - }
146.194 -
146.195 -}
147.1 --- a/bridges/refactoring/test/unit/src/org/netbeans/modules/jackpot30/refactoring/noconstructor/ReplaceConstructorRefactoringPluginImplTest.java Fri Jan 27 13:35:56 2012 +0100
147.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
147.3 @@ -1,121 +0,0 @@
147.4 -/*
147.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
147.6 - *
147.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
147.8 - *
147.9 - * The contents of this file are subject to the terms of either the GNU
147.10 - * General Public License Version 2 only ("GPL") or the Common
147.11 - * Development and Distribution License("CDDL") (collectively, the
147.12 - * "License"). You may not use this file except in compliance with the
147.13 - * License. You can obtain a copy of the License at
147.14 - * http://www.netbeans.org/cddl-gplv2.html
147.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
147.16 - * specific language governing permissions and limitations under the
147.17 - * License. When distributing the software, include this License Header
147.18 - * Notice in each file and include the License file at
147.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
147.20 - * particular file as subject to the "Classpath" exception as provided
147.21 - * by Sun in the GPL Version 2 section of the License file that
147.22 - * accompanied this code. If applicable, add the following below the
147.23 - * License Header, with the fields enclosed by brackets [] replaced by
147.24 - * your own identifying information:
147.25 - * "Portions Copyrighted [year] [name of copyright owner]"
147.26 - *
147.27 - * If you wish your version of this file to be governed by only the CDDL
147.28 - * or only the GPL Version 2, indicate your decision by adding
147.29 - * "[Contributor] elects to include this software in this distribution
147.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
147.31 - * single choice of license, a recipient has the option to distribute
147.32 - * your version of this file under either the CDDL, the GPL Version 2 or
147.33 - * to extend the choice of license to its licensees as provided above.
147.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
147.35 - * Version 2 license, then the option applies only if the new code is
147.36 - * made subject to such option by the copyright holder.
147.37 - *
147.38 - * Contributor(s):
147.39 - *
147.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
147.41 - */
147.42 -
147.43 -package org.netbeans.modules.jackpot30.refactoring.noconstructor;
147.44 -
147.45 -import com.sun.source.tree.ClassTree;
147.46 -import com.sun.source.tree.CompilationUnitTree;
147.47 -import com.sun.source.tree.MethodTree;
147.48 -import com.sun.source.util.TreePath;
147.49 -import javax.swing.text.Document;
147.50 -import org.junit.After;
147.51 -import org.junit.AfterClass;
147.52 -import org.junit.Before;
147.53 -import org.junit.BeforeClass;
147.54 -import org.junit.Test;
147.55 -import static org.junit.Assert.*;
147.56 -import org.netbeans.api.java.source.CompilationController;
147.57 -import org.netbeans.api.java.source.JavaSource;
147.58 -import org.netbeans.api.java.source.SourceUtils;
147.59 -import org.netbeans.api.java.source.Task;
147.60 -import org.netbeans.api.java.source.TreePathHandle;
147.61 -import org.netbeans.modules.editor.NbEditorDocument;
147.62 -import org.netbeans.modules.jackpot30.spi.refactoring.JackpotBasedRefactoring.Context;
147.63 -import org.netbeans.modules.jackpot30.spi.refactoring.JackpotBasedRefactoringTestBase;
147.64 -import org.netbeans.modules.parsing.api.Source;
147.65 -import org.netbeans.modules.parsing.api.indexing.IndexingManager;
147.66 -import org.netbeans.modules.parsing.impl.indexing.errors.TaskCache;
147.67 -import org.netbeans.modules.refactoring.api.Problem;
147.68 -import org.netbeans.modules.refactoring.api.RefactoringSession;
147.69 -import org.openide.filesystems.FileObject;
147.70 -import org.openide.text.FilterDocument;
147.71 -
147.72 -/**
147.73 - *
147.74 - * @author lahvac
147.75 - */
147.76 -public class ReplaceConstructorRefactoringPluginImplTest extends JackpotBasedRefactoringTestBase {
147.77 -
147.78 - public ReplaceConstructorRefactoringPluginImplTest(String name) {
147.79 - super(name);
147.80 - }
147.81 -
147.82 - public void testReplaceWithFactory() throws Exception {
147.83 - writeFilesAndWaitForScan(src,
147.84 - new File("test/Test.java", "package test;\n public class Test {\n public Test(int i, java.util.List<String> aa) {}\n private void t() {\n Test t = new Test(1, null);\n }\n }\n"),
147.85 - new File("test/Use.java", "package test; public class Use { private void t(java.util.List<String> ll) { Test t = new Test(-1, ll); } }")
147.86 - );
147.87 -
147.88 - performTest("create");
147.89 -
147.90 - assertContent(src,
147.91 - new File("test/Test.java", "package test; public class Test { public static Test create(int i, java.util.List<String> aa) { return new Test(i, aa); } private Test(int i, java.util.List<String> aa) {} private void t() { Test t = Test.create(1, null); } } "),
147.92 - new File("test/Use.java", "package test; public class Use { private void t(java.util.List<String> ll) { Test t = Test.create(-1, ll); } }"),
147.93 - new File("META-INF/upgrade/test.Test.hint", "new test.Test($1, $2) :: $1 instanceof int && $2 instanceof java.util.List<java.lang.String> => test.Test.create($1, $2);;")
147.94 - );
147.95 - }
147.96 -
147.97 -
147.98 - private void performTest(final String factoryName) throws Exception {
147.99 - final ReplaceConstructorRefactoring[] r = new ReplaceConstructorRefactoring[1];
147.100 - FileObject testFile = src.getFileObject("test/Test.java");
147.101 -
147.102 - JavaSource.forFileObject(testFile).runUserActionTask(new Task<CompilationController>() {
147.103 -
147.104 - public void run(CompilationController parameter) throws Exception {
147.105 - parameter.toPhase(JavaSource.Phase.RESOLVED);
147.106 - CompilationUnitTree cut = parameter.getCompilationUnit();
147.107 -
147.108 - MethodTree var = (MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0);
147.109 -
147.110 - TreePath tp = TreePath.getPath(cut, var);
147.111 - r[0] = new ReplaceConstructorRefactoring(TreePathHandle.create(tp, parameter), factoryName);
147.112 - }
147.113 - }, true);
147.114 -
147.115 - RefactoringSession rs = RefactoringSession.create("Session");
147.116 - r[0].prepare(rs);
147.117 - rs.doRefactoring(true);
147.118 -
147.119 - IndexingManager.getDefault().refreshIndex(src.getURL(), null);
147.120 - SourceUtils.waitScanFinished();
147.121 - assertEquals(false, TaskCache.getDefault().isInError(src, true));
147.122 - }
147.123 -
147.124 -}
147.125 \ No newline at end of file
148.1 --- a/build.xml Fri Jan 27 13:35:56 2012 +0100
148.2 +++ b/build.xml Mon Mar 12 21:10:10 2012 +0100
148.3 @@ -3,49 +3,21 @@
148.4 <!-- for some information on what you could do (e.g. targets to override). -->
148.5 <!-- If you delete this file and reopen the project it will be recreated. -->
148.6 <project name="jackpot30" basedir=".">
148.7 - <description>Builds the module suite jackpot30.</description>
148.8 - <import file="nbproject/build-impl.xml"/>
148.9 -
148.10 - <property name="server.modules" value="server/indexer:server/web.api" />
148.11 -
148.12 - <target name="-init" depends="suite.-init,copy-from-platform" />
148.13 -
148.14 - <target name="copy-from-platform" depends="suite.-init">
148.15 - <copy file="${nbplatform.active.dir}/java/modules/org-netbeans-modules-java-source.jar" todir="server/lib" />
148.16 - <copy file="${nbplatform.active.dir}/java/modules/org-netbeans-modules-java-hints.jar" todir="server/lib" />
148.17 - <copy file="${nbplatform.active.dir}/platform/core/org-openide-filesystems.jar" todir="server/lib" />
148.18 - <copy file="${nbplatform.active.dir}/platform/lib/org-openide-util.jar" todir="server/lib" />
148.19 - <copy file="${nbplatform.active.dir}/platform/lib/org-openide-util-lookup.jar" todir="server/lib" />
148.20 - <copy file="${nbplatform.active.dir}/ide/modules/org-netbeans-spi-editor-hints.jar" todir="server/lib" />
148.21 - <copy file="${nbplatform.active.dir}/ide/modules/org-netbeans-api-java-classpath.jar" todir="server/lib" />
148.22 - <copy file="${nbplatform.active.dir}/java/modules/ext/javac-api-nb-7.0-b07.jar" todir="server/lib/javac" />
148.23 - <copy file="${nbplatform.active.dir}/java/modules/ext/javac-impl-nb-7.0-b07.jar" todir="server/lib/javac" />
148.24 - <copy file="${nbplatform.active.dir}/ide/modules/org-netbeans-modules-jumpto.jar" todir="server/lib" />
148.25 - <copy file="${nbplatform.active.dir}/platform/modules/org-netbeans-modules-masterfs.jar" todir="server/lib" />
148.26 - <copy file="${nbplatform.active.dir}/ide/modules/org-netbeans-modules-parsing-lucene.jar" todir="server/lib" />
148.27 - <copy file="${nbplatform.active.dir}/ide/modules/org-netbeans-modules-parsing-api.jar" todir="server/lib" />
148.28 - <copy file="${nbplatform.active.dir}/ide/modules/org-netbeans-modules-projectapi.jar" todir="server/lib" />
148.29 - <copy file="${nbplatform.active.dir}/java/modules/org-netbeans-modules-java-project.jar" todir="server/lib" />
148.30 + <target name="build-auc">
148.31 + <taskdef classpath="${nbplatform.default.harness.dir}/tasks.jar" resource="org/netbeans/nbbuild/taskdefs.properties"/>
148.32 + <fileset id="updater.jar" dir="${nbplatform.default.netbeans.dest.dir}">
148.33 + <filename name="platform/modules/ext/updater.jar"/>
148.34 + </fileset>
148.35 + <property name="catalog.base.url" value="."/>
148.36 + <mkdir dir="build/updates" />
148.37 + <makeupdatedesc desc="build/updates/updates.xml" distbase="${catalog.base.url}" automaticgrouping="true" uselicenseurl="${use.license.url.in.catalog}">
148.38 + <fileset dir="build/updates">
148.39 + <include name="*.nbm"/>
148.40 + <include name="*.jar"/> <!-- #181025: bare OSGi bundles -->
148.41 + </fileset>
148.42 + <updaterjar>
148.43 + <resources refid="updater.jar"/>
148.44 + </updaterjar>
148.45 + </makeupdatedesc>
148.46 </target>
148.47 -
148.48 - <target name="findbugs" depends="-init">
148.49 - <subant target="findbugs" buildpath="${modules}" inheritall="false"/>
148.50 - </target>
148.51 -
148.52 - <target name="clean" depends="suite.clean">
148.53 - <subant target="clean" buildpath="${server.modules}" inheritall="false"/>
148.54 - </target>
148.55 -
148.56 - <target name="build" depends="suite.build">
148.57 - <subant target="jar" buildpath="${server.modules}" inheritall="false"/>
148.58 - </target>
148.59 -
148.60 - <target name="test" depends="suite.test">
148.61 - <subant target="test" buildpath="${server.modules}" inheritall="false"/>
148.62 - </target>
148.63 -
148.64 -<!-- <target name="coverage-report" depends="testcoverage-suite.coverage-report">
148.65 - <subant target="test" buildpath="${server.modules}" inheritall="false"/>
148.66 - </target>-->
148.67 -
148.68 </project>
149.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
149.2 +++ b/cmdline/build.sh Mon Mar 12 21:10:10 2012 +0100
149.3 @@ -0,0 +1,3 @@
149.4 +#!/bin/bash
149.5 +ant "$@" clean && ant "$@" build && ant "$@" test && (cd compiler; ant "$@" create-standalone-compiler && build/test/scripted/run ) && (cd tool; ant "$@" create-standalone-tool && build/test/scripted/run ) || exit 1
149.6 +
150.1 --- a/cmdline/compiler/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
150.2 +++ b/cmdline/compiler/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
150.3 @@ -3,6 +3,6 @@
150.4 build.xml.stylesheet.CRC32=79c3b980@1.33
150.5 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
150.6 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
150.7 -nbproject/build-impl.xml.data.CRC32=536100ea
150.8 +nbproject/build-impl.xml.data.CRC32=dcf519c4
150.9 nbproject/build-impl.xml.script.CRC32=64f6fe95
150.10 -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.47
150.11 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.49
151.1 --- a/cmdline/compiler/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
151.2 +++ b/cmdline/compiler/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
151.3 @@ -60,7 +60,7 @@
151.4 </run-dependency>
151.5 </dependency>
151.6 <dependency>
151.7 - <code-name-base>org.netbeans.modules.jackpot30.api</code-name-base>
151.8 + <code-name-base>org.netbeans.modules.jackpot30.indexing</code-name-base>
151.9 <build-prerequisite/>
151.10 <compile-dependency/>
151.11 <run-dependency>
151.12 @@ -103,6 +103,14 @@
151.13 </run-dependency>
151.14 </dependency>
151.15 <dependency>
151.16 + <code-name-base>org.netbeans.modules.java.preprocessorbridge</code-name-base>
151.17 + <build-prerequisite/>
151.18 + <compile-dependency/>
151.19 + <run-dependency>
151.20 + <implementation-version/>
151.21 + </run-dependency>
151.22 + </dependency>
151.23 + <dependency>
151.24 <code-name-base>org.netbeans.modules.java.source</code-name-base>
151.25 <build-prerequisite/>
151.26 <compile-dependency/>
151.27 @@ -129,6 +137,14 @@
151.28 </run-dependency>
151.29 </dependency>
151.30 <dependency>
151.31 + <code-name-base>org.netbeans.modules.refactoring.api</code-name-base>
151.32 + <build-prerequisite/>
151.33 + <compile-dependency/>
151.34 + <run-dependency>
151.35 + <specification-version>1.22</specification-version>
151.36 + </run-dependency>
151.37 + </dependency>
151.38 + <dependency>
151.39 <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
151.40 <build-prerequisite/>
151.41 <compile-dependency/>
151.42 @@ -138,6 +154,14 @@
151.43 </run-dependency>
151.44 </dependency>
151.45 <dependency>
151.46 + <code-name-base>org.netbeans.spi.java.hints</code-name-base>
151.47 + <build-prerequisite/>
151.48 + <compile-dependency/>
151.49 + <run-dependency>
151.50 + <implementation-version/>
151.51 + </run-dependency>
151.52 + </dependency>
151.53 + <dependency>
151.54 <code-name-base>org.openide.filesystems</code-name-base>
151.55 <build-prerequisite/>
151.56 <compile-dependency/>
151.57 @@ -213,10 +237,6 @@
151.58 <compile-dependency/>
151.59 </test-dependency>
151.60 <test-dependency>
151.61 - <code-name-base>org.netbeans.modules.java.hints.processor</code-name-base>
151.62 - <compile-dependency/>
151.63 - </test-dependency>
151.64 - <test-dependency>
151.65 <code-name-base>org.netbeans.modules.masterfs</code-name-base>
151.66 <compile-dependency/>
151.67 </test-dependency>
152.1 --- a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessing.java Fri Jan 27 13:35:56 2012 +0100
152.2 +++ b/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessing.java Mon Mar 12 21:10:10 2012 +0100
152.3 @@ -42,6 +42,7 @@
152.4 import java.io.IOException;
152.5 import java.io.OutputStreamWriter;
152.6 import java.io.Writer;
152.7 +import java.util.ArrayList;
152.8 import java.util.Arrays;
152.9 import java.util.Collection;
152.10 import java.util.Collections;
152.11 @@ -60,23 +61,25 @@
152.12 import javax.tools.Diagnostic.Kind;
152.13 import javax.tools.FileObject;
152.14 import javax.tools.StandardLocation;
152.15 -import org.netbeans.api.java.classpath.ClassPath;
152.16 import org.netbeans.api.java.source.ClasspathInfo.PathKind;
152.17 import org.netbeans.api.java.source.CompilationInfoHack;
152.18 import org.netbeans.api.java.source.ModificationResult;
152.19 -import org.netbeans.modules.jackpot30.impl.batch.BatchUtilities;
152.20 +import org.netbeans.modules.jackpot30.indexing.batch.BatchUtilities;
152.21 import org.netbeans.modules.java.hints.declarative.DeclarativeHintRegistry;
152.22 -import org.netbeans.modules.java.hints.jackpot.impl.JavaFixImpl;
152.23 -import org.netbeans.modules.java.hints.jackpot.impl.RulesManager;
152.24 -import org.netbeans.modules.java.hints.jackpot.impl.Utilities;
152.25 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
152.26 -import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata;
152.27 import org.netbeans.modules.java.hints.jackpot.spi.HintsRunner;
152.28 -import org.netbeans.modules.java.hints.options.HintsSettings;
152.29 -import org.netbeans.modules.java.hints.spi.AbstractHint.HintSeverity;
152.30 +import org.netbeans.modules.java.hints.providers.spi.HintDescription;
152.31 +import org.netbeans.modules.java.hints.providers.spi.HintMetadata;
152.32 +import org.netbeans.modules.java.hints.spiimpl.JavaFixImpl;
152.33 +import org.netbeans.modules.java.hints.spiimpl.RulesManager;
152.34 +import org.netbeans.modules.java.hints.spiimpl.Utilities;
152.35 +import org.netbeans.modules.java.hints.spiimpl.options.HintsSettings;
152.36 import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
152.37 +import org.netbeans.modules.refactoring.spi.RefactoringElementImplementation;
152.38 import org.netbeans.spi.editor.hints.ErrorDescription;
152.39 import org.netbeans.spi.editor.hints.Fix;
152.40 +import org.netbeans.spi.editor.hints.Severity;
152.41 +import org.netbeans.spi.java.hints.Hint;
152.42 +import org.netbeans.spi.java.hints.HintSeverity;
152.43 import org.openide.filesystems.FileUtil;
152.44 import org.openide.util.Exceptions;
152.45 import org.openide.util.lookup.ServiceProvider;
152.46 @@ -133,7 +136,7 @@
152.47 protected void doProcess(CompilationInfoHack info, ProcessingEnvironment processingEnv, Reporter reporter) {
152.48 Set<HintDescription> hardCodedHints = new LinkedHashSet<HintDescription>();
152.49
152.50 - for (Collection<? extends HintDescription> v : RulesManager.getInstance().allHints.values()) {
152.51 + for (Collection<? extends HintDescription> v : RulesManager.getInstance().readHints(null, null, null).values()) {
152.52 hardCodedHints.addAll(v);
152.53 }
152.54
152.55 @@ -142,7 +145,7 @@
152.56 for (Iterator<HintDescription> it = hardCodedHints.iterator(); it.hasNext(); ) {
152.57 HintMetadata current = it.next().getMetadata();
152.58
152.59 - if ( (current.kind == HintMetadata.Kind.HINT)
152.60 + if ( (current.kind == Hint.Kind.INSPECTION)
152.61 && enabledHints.contains(current.id)) {
152.62 continue;
152.63 }
152.64 @@ -155,7 +158,7 @@
152.65 List<HintDescription> hintDescriptions = new LinkedList<HintDescription>(hardCodedHints);
152.66
152.67 if (isEnabled(processingEnv, CLASSPATH_HINTS_ENABLE)) {
152.68 - hintDescriptions.addAll(new LinkedList<HintDescription>(Utilities.listClassPathHints(new HashSet<ClassPath>(Arrays.asList(info.getClasspathInfo().getClassPath(PathKind.COMPILE), info.getClasspathInfo().getClassPath(PathKind.SOURCE))))));
152.69 + hintDescriptions.addAll(new LinkedList<HintDescription>(Utilities.listClassPathHints(Collections.singleton(info.getClasspathInfo().getClassPath(PathKind.SOURCE)), Collections.singleton(info.getClasspathInfo().getClassPath(PathKind.COMPILE)))));
152.70 }
152.71
152.72 boolean applyCPHints = isEnabled(processingEnv, CLASSPATH_HINTS_FIXES_ENABLE);
152.73 @@ -187,7 +190,7 @@
152.74 JavaFixImpl jfi = (JavaFixImpl) f;
152.75
152.76 try {
152.77 - JavaFixImpl.Accessor.INSTANCE.process(jfi.jf, info, false);
152.78 + JavaFixImpl.Accessor.INSTANCE.process(jfi.jf, info, false, null, new ArrayList<RefactoringElementImplementation>());
152.79 } catch (Exception ex) {
152.80 Exceptions.printStackTrace(ex);
152.81 }
152.82 @@ -301,9 +304,9 @@
152.83 private static final class SettingsBasedChecker implements ContainsChecker<String> {
152.84 private static final Set<String> enabled = new HashSet<String>();
152.85 public SettingsBasedChecker() {
152.86 - for (HintMetadata hm : RulesManager.getInstance().allHints.keySet()) {
152.87 + for (HintMetadata hm : RulesManager.getInstance().readHints(null, null, null).keySet()) {
152.88 if ( HintsSettings.isEnabled(hm)
152.89 - && HintsSettings.getSeverity(hm, RulesManager.getPreferences(hm.id, HintsSettings.getCurrentProfileId())) != HintSeverity.CURRENT_LINE_WARNING) {
152.90 + && HintsSettings.getSeverity(hm, HintsSettings.getPreferences(hm.id, HintsSettings.getCurrentProfileId())) != Severity.HINT) {
152.91 enabled.add(hm.id);
152.92 }
152.93 }
153.1 --- a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/IndexingAnnotationProcessor.java Fri Jan 27 13:35:56 2012 +0100
153.2 +++ b/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/IndexingAnnotationProcessor.java Mon Mar 12 21:10:10 2012 +0100
153.3 @@ -41,6 +41,7 @@
153.4 import com.sun.source.tree.MemberSelectTree;
153.5 import com.sun.source.tree.Tree;
153.6 import com.sun.source.tree.Tree.Kind;
153.7 +import com.sun.source.util.Trees;
153.8 import java.io.File;
153.9 import java.io.IOException;
153.10 import java.net.URL;
153.11 @@ -52,19 +53,18 @@
153.12 import java.util.Set;
153.13 import javax.annotation.processing.ProcessingEnvironment;
153.14 import javax.tools.Diagnostic;
153.15 -import org.netbeans.api.annotations.common.NonNull;
153.16 -import org.netbeans.api.annotations.common.NullAllowed;
153.17 import org.netbeans.api.java.source.ClasspathInfo.PathKind;
153.18 -import org.netbeans.api.java.source.CompilationInfo;
153.19 import org.netbeans.api.java.source.CompilationInfoHack;
153.20 -import org.netbeans.modules.jackpot30.impl.duplicates.indexing.DuplicatesIndex;
153.21 -import org.netbeans.modules.jackpot30.impl.indexing.FileBasedIndex;
153.22 -import org.netbeans.modules.jackpot30.impl.indexing.Index.AttributionWrapper;
153.23 -import org.netbeans.modules.jackpot30.impl.indexing.Index.IndexWriter;
153.24 +import org.netbeans.modules.jackpot30.indexing.index.Indexer;
153.25 +import org.netbeans.modules.java.preprocessorbridge.spi.JavaIndexerPlugin;
153.26 import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
153.27 +import org.netbeans.modules.parsing.impl.indexing.FileObjectIndexable;
153.28 +import org.netbeans.modules.parsing.impl.indexing.SPIAccessor;
153.29 import org.openide.filesystems.FileObject;
153.30 import org.openide.filesystems.FileUtil;
153.31 import org.openide.util.Exceptions;
153.32 +import org.openide.util.Lookup;
153.33 +import org.openide.util.lookup.Lookups;
153.34 import org.openide.util.lookup.ServiceProvider;
153.35
153.36 /**
153.37 @@ -85,7 +85,7 @@
153.38 )));
153.39
153.40 private boolean enabled;
153.41 - private Map<FileObject, Writers> writers;
153.42 + private Map<FileObject, JavaIndexerPlugin> writers;
153.43
153.44 @Override
153.45 protected boolean initialize(ProcessingEnvironment processingEnv) {
153.46 @@ -102,7 +102,7 @@
153.47 FileUtil.refreshFor(cache.getParentFile());
153.48 CacheFolder.setCacheFolder(FileUtil.toFileObject(cache));
153.49
153.50 - writers = new HashMap<FileObject, Writers>();
153.51 + writers = new HashMap<FileObject, JavaIndexerPlugin>();
153.52
153.53 return true;
153.54 }
153.55 @@ -143,13 +143,16 @@
153.56 }
153.57 }
153.58
153.59 - Writers w = writers.get(root);
153.60 + JavaIndexerPlugin w = writers.get(root);
153.61 + URL sourceRoot = root.toURL();
153.62
153.63 if (w == null) {
153.64 - writers.put(root, w = new Writers(root.getURL()));
153.65 + writers.put(root, w = new Indexer.FactoryImpl().create(sourceRoot, Indexer.resolveCacheFolder(sourceRoot)));
153.66 }
153.67 +
153.68 + Lookup services = Lookups.fixed(processingEnv.getElementUtils(), processingEnv.getTypeUtils(), Trees.instance(processingEnv));
153.69
153.70 - w.record(info);
153.71 + w.process(info.getCompilationUnit(), SPIAccessor.getInstance().create(new FileObjectIndexable(root, info.getFileObject())), services);
153.72 } catch (IOException ex) {
153.73 Exceptions.printStackTrace(ex);
153.74 }
153.75 @@ -159,12 +162,8 @@
153.76 protected void finish() {
153.77 if (!enabled) return;
153.78
153.79 - for (Writers w : writers.values()) {
153.80 - try {
153.81 - w.close();
153.82 - } catch (IOException ex) {
153.83 - Exceptions.printStackTrace(ex);
153.84 - }
153.85 + for (JavaIndexerPlugin w : writers.values()) {
153.86 + w.finish();
153.87 }
153.88
153.89 writers = null;
153.90 @@ -175,31 +174,4 @@
153.91 return OPTIONS;
153.92 }
153.93
153.94 - static final class Writers {
153.95 - private final @NonNull IndexWriter w;
153.96 - private final @NullAllowed DuplicatesIndex.IndexWriter dw;
153.97 -
153.98 - public Writers(URL src) throws IOException {
153.99 - w = FileBasedIndex.get(src).openForWriting();
153.100 - //duplicates index does not currently work:
153.101 -// dw = DuplicatesIndex.get(src).openForWriting();
153.102 - dw = null;
153.103 - }
153.104 -
153.105 - public void record(CompilationInfo info) throws IOException {
153.106 - w.record(info.getFileObject().getURL(), info.getCompilationUnit(), new AttributionWrapper(info));
153.107 -
153.108 - if (dw != null) {
153.109 - dw.record(info, info.getFileObject().getURL(), info.getCompilationUnit());
153.110 - }
153.111 - }
153.112 -
153.113 - public void close() throws IOException {
153.114 - w.close();
153.115 -
153.116 - if (dw != null) {
153.117 - dw.close();
153.118 - }
153.119 - }
153.120 - }
153.121 }
154.1 --- a/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/CreateStandaloneCompilerJar.java Fri Jan 27 13:35:56 2012 +0100
154.2 +++ b/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/CreateStandaloneCompilerJar.java Mon Mar 12 21:10:10 2012 +0100
154.3 @@ -41,7 +41,7 @@
154.4 import org.netbeans.modules.jackpot30.cmdline.lib.CreateStandaloneJar;
154.5 import javax.annotation.processing.Processor;
154.6 import org.netbeans.modules.jackpot30.cmdline.lib.StandaloneTools.UtilitiesSPIImpl;
154.7 -import org.netbeans.modules.java.hints.jackpot.impl.Utilities;
154.8 +import org.netbeans.modules.java.hints.spiimpl.Utilities;
154.9
154.10 /**
154.11 *
155.1 --- a/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessingTest.java Fri Jan 27 13:35:56 2012 +0100
155.2 +++ b/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessingTest.java Mon Mar 12 21:10:10 2012 +0100
155.3 @@ -41,13 +41,13 @@
155.4 import java.io.File;
155.5 import java.util.Collections;
155.6 import javax.lang.model.type.TypeMirror;
155.7 -import org.netbeans.modules.java.hints.jackpot.code.spi.Hint;
155.8 -import org.netbeans.modules.java.hints.jackpot.code.spi.TriggerCompileTime;
155.9 -import org.netbeans.modules.java.hints.jackpot.code.spi.TriggerPattern;
155.10 -import org.netbeans.modules.java.hints.jackpot.spi.HintContext;
155.11 -import org.netbeans.modules.java.hints.jackpot.spi.JavaFix;
155.12 -import org.netbeans.modules.java.hints.jackpot.spi.support.ErrorDescriptionFactory;
155.13 import org.netbeans.spi.editor.hints.ErrorDescription;
155.14 +import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
155.15 +import org.netbeans.spi.java.hints.Hint;
155.16 +import org.netbeans.spi.java.hints.HintContext;
155.17 +import org.netbeans.spi.java.hints.JavaFix;
155.18 +import org.netbeans.spi.java.hints.JavaFixUtilities;
155.19 +import org.netbeans.spi.java.hints.TriggerPattern;
155.20
155.21 /**
155.22 *
155.23 @@ -247,11 +247,10 @@
155.24 assertEquals(goldenDiff, diffText);
155.25 }
155.26
155.27 - @Hint(category="general")
155.28 + @Hint(displayName="test", description="test", category="general")
155.29 @TriggerPattern("$1 == null && null == $1")
155.30 - @TriggerCompileTime //XXX: currently not really used
155.31 public static ErrorDescription codeHint(HintContext ctx) {
155.32 - return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), "test", JavaFix.rewriteFix(ctx.getInfo(), "test", ctx.getPath(), "$1 == null", ctx.getVariables(), ctx.getMultiVariables(), ctx.getVariableNames(), Collections.<String, TypeMirror>emptyMap()));
155.33 + return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), "test", JavaFixUtilities.rewriteFix(ctx, "test", ctx.getPath(), "$1 == null"));
155.34 }
155.35
155.36 }
156.1 --- a/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/IndexingAnnotationProcessorTest.java Fri Jan 27 13:35:56 2012 +0100
156.2 +++ b/cmdline/compiler/test/unit/src/org/netbeans/modules/jackpot30/compiler/IndexingAnnotationProcessorTest.java Mon Mar 12 21:10:10 2012 +0100
156.3 @@ -46,10 +46,11 @@
156.4 import org.netbeans.api.java.source.CompilationController;
156.5 import org.netbeans.api.java.source.JavaSource;
156.6 import org.netbeans.api.java.source.Task;
156.7 -import org.netbeans.modules.jackpot30.impl.indexing.Cache;
156.8 -import org.netbeans.modules.jackpot30.impl.indexing.FileBasedIndex;
156.9 +import org.netbeans.modules.jackpot30.indexing.index.IndexQuery;
156.10 import org.netbeans.modules.java.hints.declarative.Hacks;
156.11 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch;
156.12 +import org.netbeans.modules.java.hints.spiimpl.pm.BulkSearch;
156.13 +import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
156.14 +import org.openide.filesystems.FileUtil;
156.15
156.16 /**
156.17 *
156.18 @@ -64,7 +65,7 @@
156.19 protected void setUp() throws Exception {
156.20 super.setUp();
156.21 cache = new File(workDir, "cache");
156.22 - Cache.setStandaloneCacheRoot(cache);
156.23 + CacheFolder.setCacheFolder(FileUtil.createFolder(cache));
156.24 }
156.25
156.26 private File cache;
156.27 @@ -109,7 +110,7 @@
156.28
156.29 JavaSource.create(cpInfo).runUserActionTask(new Task<CompilationController>() {
156.30 public void run(CompilationController parameter) throws Exception {
156.31 - real.addAll(FileBasedIndex.get(src.toURI().toURL()).findCandidates(BulkSearch.getDefault().create(parameter, patterns)));
156.32 + real.addAll(IndexQuery.open(src.toURI().toURL()).findCandidates(BulkSearch.getDefault().create(parameter, patterns)));
156.33 }
156.34 }, true);
156.35
157.1 --- a/cmdline/lib/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
157.2 +++ b/cmdline/lib/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
157.3 @@ -60,14 +60,6 @@
157.4 </run-dependency>
157.5 </dependency>
157.6 <dependency>
157.7 - <code-name-base>org.netbeans.modules.jackpot30.api</code-name-base>
157.8 - <build-prerequisite/>
157.9 - <compile-dependency/>
157.10 - <run-dependency>
157.11 - <implementation-version/>
157.12 - </run-dependency>
157.13 - </dependency>
157.14 - <dependency>
157.15 <code-name-base>org.netbeans.modules.jackpot30.remoting.api</code-name-base>
157.16 <build-prerequisite/>
157.17 <compile-dependency/>
157.18 @@ -77,11 +69,9 @@
157.19 </dependency>
157.20 <dependency>
157.21 <code-name-base>org.netbeans.modules.java.hints</code-name-base>
157.22 - <build-prerequisite/>
157.23 - <compile-dependency/>
157.24 <run-dependency>
157.25 <release-version>1</release-version>
157.26 - <implementation-version/>
157.27 + <specification-version>1.64.0.13.9.1.20.6.1.1</specification-version>
157.28 </run-dependency>
157.29 </dependency>
157.30 <dependency>
157.31 @@ -129,6 +119,14 @@
157.32 </run-dependency>
157.33 </dependency>
157.34 <dependency>
157.35 + <code-name-base>org.netbeans.spi.java.hints</code-name-base>
157.36 + <build-prerequisite/>
157.37 + <compile-dependency/>
157.38 + <run-dependency>
157.39 + <implementation-version/>
157.40 + </run-dependency>
157.41 + </dependency>
157.42 + <dependency>
157.43 <code-name-base>org.openide.filesystems</code-name-base>
157.44 <build-prerequisite/>
157.45 <compile-dependency/>
157.46 @@ -189,6 +187,10 @@
157.47 <compile-dependency/>
157.48 </test-dependency>
157.49 <test-dependency>
157.50 + <code-name-base>org.netbeans.modules.jackpot30.common</code-name-base>
157.51 + <compile-dependency/>
157.52 + </test-dependency>
157.53 + <test-dependency>
157.54 <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
157.55 <recursive/>
157.56 <compile-dependency/>
157.57 @@ -202,10 +204,6 @@
157.58 <compile-dependency/>
157.59 </test-dependency>
157.60 <test-dependency>
157.61 - <code-name-base>org.netbeans.modules.java.hints.processor</code-name-base>
157.62 - <compile-dependency/>
157.63 - </test-dependency>
157.64 - <test-dependency>
157.65 <code-name-base>org.netbeans.modules.masterfs</code-name-base>
157.66 <compile-dependency/>
157.67 </test-dependency>
158.1 --- a/cmdline/lib/src/org/netbeans/modules/jackpot30/cmdline/lib/DumpHints.java Fri Jan 27 13:35:56 2012 +0100
158.2 +++ b/cmdline/lib/src/org/netbeans/modules/jackpot30/cmdline/lib/DumpHints.java Mon Mar 12 21:10:10 2012 +0100
158.3 @@ -43,8 +43,8 @@
158.4 import java.util.List;
158.5 import java.util.Map;
158.6 import org.codeviation.pojson.Pojson;
158.7 -import org.netbeans.modules.java.hints.jackpot.impl.RulesManager;
158.8 -import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata;
158.9 +import org.netbeans.modules.java.hints.providers.spi.HintMetadata;
158.10 +import org.netbeans.modules.java.hints.spiimpl.RulesManager;
158.11
158.12 /**
158.13 *
158.14 @@ -55,7 +55,7 @@
158.15 public static String dumpHints() {
158.16 List<Map<String, String>> data = new LinkedList<Map<String, String>>();
158.17
158.18 - for (HintMetadata hm : RulesManager.getInstance().allHints.keySet()) {
158.19 + for (HintMetadata hm : RulesManager.getInstance().readHints(null, null, null).keySet()) {
158.20 Map<String, String> hintData = new HashMap<String, String>();
158.21
158.22 hintData.put("id", hm.id);
159.1 --- a/cmdline/lib/src/org/netbeans/modules/jackpot30/cmdline/lib/NonNBComputer.java Fri Jan 27 13:35:56 2012 +0100
159.2 +++ b/cmdline/lib/src/org/netbeans/modules/jackpot30/cmdline/lib/NonNBComputer.java Mon Mar 12 21:10:10 2012 +0100
159.3 @@ -56,7 +56,7 @@
159.4 import org.netbeans.api.java.source.CompilationController;
159.5 import org.netbeans.api.java.source.JavaSource;
159.6 import org.netbeans.api.java.source.Task;
159.7 -import org.netbeans.modules.java.hints.jackpot.impl.hints.HintsInvoker;
159.8 +import org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker;
159.9 import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
159.10 import org.netbeans.spi.editor.hints.ErrorDescription;
159.11 import org.netbeans.spi.java.classpath.support.ClassPathSupport;
160.1 --- a/cmdline/lib/src/org/netbeans/modules/jackpot30/cmdline/lib/StandaloneTools.java Fri Jan 27 13:35:56 2012 +0100
160.2 +++ b/cmdline/lib/src/org/netbeans/modules/jackpot30/cmdline/lib/StandaloneTools.java Mon Mar 12 21:10:10 2012 +0100
160.3 @@ -58,7 +58,7 @@
160.4 import org.netbeans.api.java.classpath.ClassPath;
160.5 import org.netbeans.api.java.queries.SourceForBinaryQuery;
160.6 import org.netbeans.api.java.source.ClasspathInfo;
160.7 -import org.netbeans.modules.java.hints.jackpot.impl.Utilities.SPI;
160.8 +import org.netbeans.modules.java.hints.spiimpl.Utilities.SPI;
160.9 import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
160.10 import org.netbeans.modules.java.source.parsing.JavacParser;
160.11 import org.netbeans.modules.java.source.parsing.JavacParserFactory;
161.1 --- a/cmdline/lib/test/unit/src/org/netbeans/modules/jackpot30/cmdline/lib/CreateStandaloneJar.java Fri Jan 27 13:35:56 2012 +0100
161.2 +++ b/cmdline/lib/test/unit/src/org/netbeans/modules/jackpot30/cmdline/lib/CreateStandaloneJar.java Mon Mar 12 21:10:10 2012 +0100
161.3 @@ -75,14 +75,18 @@
161.4 import org.netbeans.modules.classfile.ClassName;
161.5 import org.netbeans.modules.jackpot30.cmdline.lib.StandaloneTools.JavaMimeResolver;
161.6 import org.netbeans.modules.jackpot30.cmdline.lib.StandaloneTools.RepositoryImpl;
161.7 -import org.netbeans.modules.jackpot30.spi.Hacks.HintPreferencesProvider;
161.8 +import org.netbeans.modules.jackpot30.common.api.IndexAccess;
161.9 import org.netbeans.modules.java.hints.declarative.DeclarativeHintRegistry;
161.10 -import org.netbeans.modules.java.hints.jackpot.code.CodeHintProviderImpl;
161.11 -import org.netbeans.modules.java.hints.jackpot.code.FSWrapper;
161.12 -import org.netbeans.modules.java.hints.jackpot.impl.Utilities.SPI;
161.13 -import org.netbeans.modules.java.hints.jackpot.spi.ClassPathBasedHintProvider;
161.14 -import org.netbeans.modules.java.hints.jackpot.spi.HintProvider;
161.15 +import org.netbeans.modules.java.hints.jackpot.refactoring.Hacks.HintPreferencesProvider;
161.16 +import org.netbeans.modules.java.hints.providers.code.CodeHintProviderImpl;
161.17 +import org.netbeans.modules.java.hints.providers.code.FSWrapper;
161.18 +import org.netbeans.modules.java.hints.providers.spi.ClassPathBasedHintProvider;
161.19 +import org.netbeans.modules.java.hints.providers.spi.HintProvider;
161.20 +import org.netbeans.modules.java.hints.spiimpl.RulesManager;
161.21 +import org.netbeans.modules.java.hints.spiimpl.RulesManagerImpl;
161.22 +import org.netbeans.modules.java.hints.spiimpl.Utilities.SPI;
161.23 import org.netbeans.spi.editor.mimelookup.MimeDataProvider;
161.24 +import org.openide.filesystems.MIMEResolver;
161.25 import org.openide.util.NbPreferences.Provider;
161.26 import org.openide.xml.EntityCatalog;
161.27 import org.openide.xml.XMLUtil;
161.28 @@ -230,6 +234,7 @@
161.29 registrations.add(new MetaInfRegistration(Provider.class.getName(), StandaloneTools.PreferencesProvider.class.getName(), 0));
161.30 registrations.add(new MetaInfRegistration(MimeDataProvider.class.getName(), StandaloneTools.StandaloneMimeDataProviderImpl.class.getName()));
161.31 registrations.add(new MetaInfRegistration(SPI.class.getName(), StandaloneTools.UtilitiesSPIImpl.class.getName()));
161.32 + registrations.add(new MetaInfRegistration(MIMEResolver.class.getName(), JavaMimeResolver.class.getName()));
161.33 registrations.addAll(info.metaInf);
161.34
161.35 Map<String, Collection<MetaInfRegistration>> api2Registrations = new HashMap<String, Collection<MetaInfRegistration>>();
161.36 @@ -414,6 +419,8 @@
161.37 "org.netbeans.core.NbLoaderPool",
161.38 "org.netbeans.core.startup.preferences.PreferencesProviderImpl",
161.39 "org.netbeans.modules.java.platform.DefaultJavaPlatformProvider",
161.40 + IndexAccess.class.getName(),
161.41 + RulesManagerImpl.class.getName(),
161.42
161.43 "com.sun.tools.javac.resources.compiler",
161.44 "com.sun.tools.javac.resources.javac",
161.45 @@ -422,7 +429,7 @@
161.46 PositionIncrementAttributeImpl.class.getName()
161.47
161.48
161.49 - , "org.netbeans.modules.java.hints.infrastructure.RulesManager$HintProviderImpl"
161.50 + , "org.netbeans.modules.java.hints.legacy.spi.RulesManager$HintProviderImpl"
161.51 , Tree.class.getName()
161.52 ,JavacTool.class.getName()
161.53 ,JavaMimeResolver.class.getName()
161.54 @@ -435,7 +442,8 @@
161.55 "org.netbeans.modules.openide.util.PreferencesProvider",
161.56 HintPreferencesProvider.class.getName(),
161.57 ClassPathBasedHintProvider.class.getName(),
161.58 - "org.openide.filesystems.MIMEResolver"
161.59 + IndexAccess.class.getName(),
161.60 + RulesManager.class.getName()
161.61 ));
161.62
161.63 private static final Set<String> RESOURCES = new HashSet<String>(Arrays.asList(
162.1 --- a/cmdline/nbproject/platform.properties Fri Jan 27 13:35:56 2012 +0100
162.2 +++ b/cmdline/nbproject/platform.properties Mon Mar 12 21:10:10 2012 +0100
162.3 @@ -10,9 +10,14 @@
162.4 ${nbplatform.active.dir}/platform:\
162.5 ${nbplatform.active.dir}/profiler:\
162.6 ${nbplatform.active.dir}/websvccommon:\
162.7 - ../build/cluster:\
162.8 ../borrowedtests/build/cluster:\
162.9 - ../remoting/ide/build/cluster
162.10 + ../remoting/ide/build/cluster:\
162.11 + ../language/ide/build/cluster:\
162.12 + ../remoting/common/build/cluster
162.13 +extcluster.../language/ide/build/cluster.javadoc=
162.14 +extcluster.../language/ide/build/cluster.sources=
162.15 +extcluster.../remoting/common/build/cluster.javadoc=
162.16 +extcluster.../remoting/common/build/cluster.sources=
162.17 extcluster.../remoting/ide/build/cluster.javadoc=
162.18 extcluster.../remoting/ide/build/cluster.sources=
162.19 nbplatform.active=default
163.1 --- a/cmdline/tool/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
163.2 +++ b/cmdline/tool/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
163.3 @@ -3,6 +3,6 @@
163.4 build.xml.stylesheet.CRC32=a56c6a5b@1.44
163.5 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
163.6 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
163.7 -nbproject/build-impl.xml.data.CRC32=af581875
163.8 +nbproject/build-impl.xml.data.CRC32=d1f6cef0
163.9 nbproject/build-impl.xml.script.CRC32=08f1fb11
163.10 nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.49
164.1 --- a/cmdline/tool/nbproject/project.properties Fri Jan 27 13:35:56 2012 +0100
164.2 +++ b/cmdline/tool/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
164.3 @@ -1,6 +1,6 @@
164.4 javac.source=1.6
164.5 javac.compilerargs=-Xlint -Xlint:-serial
164.6 -cp.extra=../../server/lib/jopt-simple/jopt-simple-3.2.jar
164.7 +cp.extra=../../lib/jopt-simple/jopt-simple-3.2.jar
164.8 spec.version.base=1.16.0
164.9 test.timeout=6000000
164.10 bootclasspath.prepend=${basedir}/../../server/lib/javac/javac-api-nb-7.0-b07.jar
165.1 --- a/cmdline/tool/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
165.2 +++ b/cmdline/tool/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
165.3 @@ -61,7 +61,7 @@
165.4 </run-dependency>
165.5 </dependency>
165.6 <dependency>
165.7 - <code-name-base>org.netbeans.modules.jackpot30.api</code-name-base>
165.8 + <code-name-base>org.netbeans.modules.jackpot30.indexing</code-name-base>
165.9 <build-prerequisite/>
165.10 <compile-dependency/>
165.11 <run-dependency>
165.12 @@ -70,11 +70,9 @@
165.13 </dependency>
165.14 <dependency>
165.15 <code-name-base>org.netbeans.modules.java.hints</code-name-base>
165.16 - <build-prerequisite/>
165.17 - <compile-dependency/>
165.18 <run-dependency>
165.19 <release-version>1</release-version>
165.20 - <implementation-version/>
165.21 + <specification-version>1.64.0.13.9.1.20.6.1.1</specification-version>
165.22 </run-dependency>
165.23 </dependency>
165.24 <dependency>
165.25 @@ -148,6 +146,14 @@
165.26 </run-dependency>
165.27 </dependency>
165.28 <dependency>
165.29 + <code-name-base>org.netbeans.modules.refactoring.api</code-name-base>
165.30 + <build-prerequisite/>
165.31 + <compile-dependency/>
165.32 + <run-dependency>
165.33 + <specification-version>1.22</specification-version>
165.34 + </run-dependency>
165.35 + </dependency>
165.36 + <dependency>
165.37 <code-name-base>org.netbeans.modules.sendopts</code-name-base>
165.38 <build-prerequisite/>
165.39 <compile-dependency/>
165.40 @@ -166,6 +172,14 @@
165.41 </run-dependency>
165.42 </dependency>
165.43 <dependency>
165.44 + <code-name-base>org.netbeans.spi.java.hints</code-name-base>
165.45 + <build-prerequisite/>
165.46 + <compile-dependency/>
165.47 + <run-dependency>
165.48 + <implementation-version/>
165.49 + </run-dependency>
165.50 + </dependency>
165.51 + <dependency>
165.52 <code-name-base>org.openide.filesystems</code-name-base>
165.53 <build-prerequisite/>
165.54 <compile-dependency/>
165.55 @@ -250,11 +264,6 @@
165.56 <test/>
165.57 </test-dependency>
165.58 <test-dependency>
165.59 - <code-name-base>org.netbeans.modules.jackpot30.hintsimpl</code-name-base>
165.60 - <recursive/>
165.61 - <compile-dependency/>
165.62 - </test-dependency>
165.63 - <test-dependency>
165.64 <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
165.65 <compile-dependency/>
165.66 </test-dependency>
166.1 --- a/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java Fri Jan 27 13:35:56 2012 +0100
166.2 +++ b/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java Mon Mar 12 21:10:10 2012 +0100
166.3 @@ -48,8 +48,8 @@
166.4 import java.io.Writer;
166.5 import java.net.URL;
166.6 import java.util.ArrayList;
166.7 +import java.util.Arrays;
166.8 import java.util.Collection;
166.9 -import java.util.Collections;
166.10 import java.util.HashMap;
166.11 import java.util.Iterator;
166.12 import java.util.LinkedList;
166.13 @@ -72,28 +72,27 @@
166.14 import org.netbeans.api.java.source.CompilationController;
166.15 import org.netbeans.api.java.source.ModificationResult;
166.16 import org.netbeans.core.startup.MainLookup;
166.17 -import org.netbeans.modules.java.hints.jackpot.impl.MessageImpl;
166.18 -import org.netbeans.modules.java.hints.jackpot.impl.RulesManager;
166.19 -import org.netbeans.modules.java.hints.jackpot.impl.Utilities;
166.20 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch;
166.21 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.BatchResult;
166.22 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.Folder;
166.23 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.Resource;
166.24 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.VerifiedSpansCallBack;
166.25 -import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchUtilities;
166.26 -import org.netbeans.modules.java.hints.jackpot.impl.batch.ProgressHandleWrapper;
166.27 -import org.netbeans.modules.java.hints.jackpot.impl.batch.ProgressHandleWrapper.ProgressHandleAbstraction;
166.28 -import org.netbeans.modules.java.hints.jackpot.impl.batch.Scopes;
166.29 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
166.30 -import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata;
166.31 -import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata.Kind;
166.32 -import org.netbeans.modules.java.hints.options.HintsSettings;
166.33 +import org.netbeans.modules.java.hints.providers.spi.HintDescription;
166.34 +import org.netbeans.modules.java.hints.providers.spi.HintMetadata;
166.35 +import org.netbeans.modules.java.hints.spiimpl.MessageImpl;
166.36 +import org.netbeans.modules.java.hints.spiimpl.RulesManager;
166.37 +import org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch;
166.38 +import org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch.BatchResult;
166.39 +import org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch.Folder;
166.40 +import org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch.Resource;
166.41 +import org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch.VerifiedSpansCallBack;
166.42 +import org.netbeans.modules.java.hints.spiimpl.batch.BatchUtilities;
166.43 +import org.netbeans.modules.java.hints.spiimpl.batch.ProgressHandleWrapper;
166.44 +import org.netbeans.modules.java.hints.spiimpl.batch.ProgressHandleWrapper.ProgressHandleAbstraction;
166.45 +import org.netbeans.modules.java.hints.spiimpl.batch.Scopes;
166.46 +import org.netbeans.modules.java.hints.spiimpl.options.HintsSettings;
166.47 import org.netbeans.modules.java.source.parsing.JavaPathRecognizer;
166.48 import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
166.49 import org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater;
166.50 import org.netbeans.spi.editor.hints.ErrorDescription;
166.51 import org.netbeans.spi.java.classpath.ClassPathProvider;
166.52 import org.netbeans.spi.java.classpath.support.ClassPathSupport;
166.53 +import org.netbeans.spi.java.hints.Hint.Kind;
166.54 import org.netbeans.spi.java.queries.SourceLevelQueryImplementation2;
166.55 import org.openide.filesystems.FileObject;
166.56 import org.openide.filesystems.FileStateInvalidException;
166.57 @@ -209,17 +208,17 @@
166.58 ClassPath bootCP = createClassPath(parsed.has(bootclasspath) ? parsed.valuesOf(bootclasspath) : null, createDefaultBootClassPath());
166.59 ClassPath compileCP = createClassPath(parsed.has(classpath) ? parsed.valuesOf(classpath) : null, ClassPath.EMPTY);
166.60 ClassPath sourceCP = createClassPath(parsed.has(sourcepath) ? parsed.valuesOf(sourcepath) : null, ClassPathSupport.createClassPath(roots.toArray(new FileObject[0])));
166.61 - ClassPath hintsCP = ClassPathSupport.createProxyClassPath(bootCP, compileCP, sourceCP);
166.62 + ClassPath binaryCP = ClassPathSupport.createProxyClassPath(bootCP, compileCP);
166.63
166.64 if (parsed.has("list")) {
166.65 - printHints(hintsCP);
166.66 + printHints(sourceCP, binaryCP);
166.67 return 0;
166.68 }
166.69
166.70 if (parsed.has(hint)) {
166.71 - hints = findHints(hintsCP, parsed.valueOf(hint));
166.72 + hints = findHints(sourceCP, binaryCP, parsed.valueOf(hint));
166.73 } else {
166.74 - hints = allHints(hintsCP);
166.75 + hints = allHints(sourceCP, binaryCP);
166.76 }
166.77
166.78 if (!hints.iterator().hasNext()) {
166.79 @@ -242,7 +241,7 @@
166.80 return 1;
166.81 }
166.82
166.83 - Preferences prefs = RulesManager.getPreferences(hd.getMetadata().id, HintsSettings.getCurrentProfileId());
166.84 + Preferences prefs = HintsSettings.getPreferences(hd.getMetadata().id, HintsSettings.getCurrentProfileId());
166.85
166.86 if (prefs == null) {
166.87 System.err.println("hint '" + parsed.valueOf(hint) + "' cannot be configured");
166.88 @@ -297,24 +296,20 @@
166.89 return 0;
166.90 }
166.91
166.92 - private static Map<HintMetadata, Collection<? extends HintDescription>> listHints(ClassPath from) {
166.93 + private static Map<HintMetadata, Collection<? extends HintDescription>> listHints(ClassPath sourceFrom, ClassPath binaryFrom) {
166.94 Map<HintMetadata, Collection<? extends HintDescription>> result = new HashMap<HintMetadata, Collection<? extends HintDescription>>();
166.95
166.96 - for (Map.Entry<HintMetadata, Collection<? extends HintDescription>> entry: RulesManager.getInstance().allHints.entrySet()) {
166.97 - result.put(entry.getKey(), entry.getValue());
166.98 - }
166.99 -
166.100 - for (Map.Entry<? extends HintMetadata, ? extends Collection<? extends HintDescription>> entry: org.netbeans.modules.java.hints.jackpot.impl.refactoring.Utilities.sortByMetadata(Utilities.listClassPathHints(Collections.singleton(from))).entrySet()) {
166.101 + for (Entry<HintMetadata, ? extends Collection<? extends HintDescription>> entry: RulesManager.getInstance().readHints(null, Arrays.asList(sourceFrom, binaryFrom), null).entrySet()) {
166.102 result.put(entry.getKey(), entry.getValue());
166.103 }
166.104
166.105 return result;
166.106 }
166.107
166.108 - private static Iterable<? extends HintDescription> findHints(ClassPath from, String name) {
166.109 + private static Iterable<? extends HintDescription> findHints(ClassPath sourceFrom, ClassPath binaryFrom, String name) {
166.110 List<HintDescription> descs = new LinkedList<HintDescription>();
166.111
166.112 - for (Entry<HintMetadata, Collection<? extends HintDescription>> e : listHints(from).entrySet()) {
166.113 + for (Entry<HintMetadata, Collection<? extends HintDescription>> e : listHints(sourceFrom, binaryFrom).entrySet()) {
166.114 if (e.getKey().displayName.equals(name)) {
166.115 descs.addAll(e.getValue());
166.116 }
166.117 @@ -323,11 +318,11 @@
166.118 return descs;
166.119 }
166.120
166.121 - private static Iterable<? extends HintDescription> allHints(ClassPath from) {
166.122 + private static Iterable<? extends HintDescription> allHints(ClassPath sourceFrom, ClassPath binaryFrom) {
166.123 List<HintDescription> descs = new LinkedList<HintDescription>();
166.124
166.125 - for (Entry<HintMetadata, Collection<? extends HintDescription>> e : listHints(from).entrySet()) {
166.126 - if (e.getKey().kind != Kind.HINT) continue;
166.127 + for (Entry<HintMetadata, Collection<? extends HintDescription>> e : listHints(sourceFrom, binaryFrom).entrySet()) {
166.128 + if (e.getKey().kind != Kind.INSPECTION) continue;
166.129 if (!e.getKey().enabled) continue;
166.130 descs.addAll(e.getValue());
166.131 }
166.132 @@ -396,7 +391,7 @@
166.133 outS = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(out)));
166.134
166.135 for (ModificationResult mr : diffs) {
166.136 - org.netbeans.modules.jackpot30.impl.batch.BatchUtilities.exportDiff(mr, null, outS);
166.137 + org.netbeans.modules.jackpot30.indexing.batch.BatchUtilities.exportDiff(mr, null, outS);
166.138 }
166.139 } finally {
166.140 try {
166.141 @@ -412,10 +407,10 @@
166.142 }
166.143 }
166.144
166.145 - private static void printHints(ClassPath from) throws IOException {
166.146 + private static void printHints(ClassPath sourceFrom, ClassPath binaryFrom) throws IOException {
166.147 Set<String> hints = new TreeSet<String>();
166.148
166.149 - for (Entry<HintMetadata, Collection<? extends HintDescription>> e : listHints(from).entrySet()) {
166.150 + for (Entry<HintMetadata, Collection<? extends HintDescription>> e : listHints(sourceFrom, binaryFrom).entrySet()) {
166.151 hints.add(e.getKey().displayName);
166.152 }
166.153
167.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
167.2 +++ b/duplicates/build.sh Mon Mar 12 21:10:10 2012 +0100
167.3 @@ -0,0 +1,3 @@
167.4 +#!/bin/bash
167.5 +(cd ide; ant "$@" clean && ant "$@" nbms && ant "$@" test) || exit 1
167.6 +
168.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
168.2 +++ b/duplicates/ide/build.xml Mon Mar 12 21:10:10 2012 +0100
168.3 @@ -0,0 +1,8 @@
168.4 +<?xml version="1.0" encoding="UTF-8"?>
168.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
168.6 +<!-- for some information on what you could do (e.g. targets to override). -->
168.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
168.8 +<project name="duplicates-ide" basedir=".">
168.9 + <description>Builds the module suite ide.</description>
168.10 + <import file="nbproject/build-impl.xml"/>
168.11 +</project>
169.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
169.2 +++ b/duplicates/ide/impl/build.xml Mon Mar 12 21:10:10 2012 +0100
169.3 @@ -0,0 +1,9 @@
169.4 +<?xml version="1.0" encoding="UTF-8"?>
169.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
169.6 +<!-- for some information on what you could do (e.g. targets to override). -->
169.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
169.8 +<project name="org.netbeans.modules.jackpot30.duplicates.impl" default="netbeans" basedir=".">
169.9 + <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.duplicates.impl.</description>
169.10 + <import file="nbproject/build-impl.xml"/>
169.11 + <import file="../../../findbugs-import.xml" />
169.12 +</project>
170.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
170.2 +++ b/duplicates/ide/impl/manifest.mf Mon Mar 12 21:10:10 2012 +0100
170.3 @@ -0,0 +1,5 @@
170.4 +Manifest-Version: 1.0
170.5 +OpenIDE-Module: org.netbeans.modules.jackpot30.duplicates.impl
170.6 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/duplicates/impl/Bundle.properties
170.7 +OpenIDE-Module-Specification-Version: 1.0
170.8 +
171.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
171.2 +++ b/duplicates/ide/impl/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
171.3 @@ -0,0 +1,45 @@
171.4 +<?xml version="1.0" encoding="UTF-8"?>
171.5 +<!--
171.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
171.7 +*** EDIT ../build.xml INSTEAD ***
171.8 +-->
171.9 +<project name="org.netbeans.modules.jackpot30.duplicates.impl-impl" basedir="..">
171.10 + <fail message="Please build using Ant 1.7.1 or higher.">
171.11 + <condition>
171.12 + <not>
171.13 + <antversion atleast="1.7.1"/>
171.14 + </not>
171.15 + </condition>
171.16 + </fail>
171.17 + <property file="nbproject/private/suite-private.properties"/>
171.18 + <property file="nbproject/suite.properties"/>
171.19 + <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
171.20 + <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
171.21 + <property file="${suite.dir}/nbproject/platform.properties"/>
171.22 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
171.23 + <attribute name="name"/>
171.24 + <attribute name="value"/>
171.25 + <sequential>
171.26 + <property name="@{name}" value="${@{value}}"/>
171.27 + </sequential>
171.28 + </macrodef>
171.29 + <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
171.30 + <attribute name="property"/>
171.31 + <attribute name="value"/>
171.32 + <sequential>
171.33 + <property name="@{property}" value="@{value}"/>
171.34 + </sequential>
171.35 + </macrodef>
171.36 + <property file="${user.properties.file}"/>
171.37 + <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
171.38 + <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
171.39 + <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
171.40 + <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
171.41 + <condition>
171.42 + <not>
171.43 + <contains string="${cluster.path.evaluated}" substring="platform"/>
171.44 + </not>
171.45 + </condition>
171.46 + </fail>
171.47 + <import file="${harness.dir}/build.xml"/>
171.48 +</project>
172.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
172.2 +++ b/duplicates/ide/impl/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
172.3 @@ -0,0 +1,8 @@
172.4 +build.xml.data.CRC32=f3f3f30d
172.5 +build.xml.script.CRC32=b45f306d
172.6 +build.xml.stylesheet.CRC32=a56c6a5b@2.49
172.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
172.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
172.9 +nbproject/build-impl.xml.data.CRC32=113fe8ad
172.10 +nbproject/build-impl.xml.script.CRC32=5fd8da83
172.11 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.49
173.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
173.2 +++ b/duplicates/ide/impl/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
173.3 @@ -0,0 +1,2 @@
173.4 +javac.source=1.6
173.5 +javac.compilerargs=-Xlint -Xlint:-serial
174.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
174.2 +++ b/duplicates/ide/impl/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
174.3 @@ -0,0 +1,389 @@
174.4 +<?xml version="1.0" encoding="UTF-8"?>
174.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
174.6 + <type>org.netbeans.modules.apisupport.project</type>
174.7 + <configuration>
174.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
174.9 + <code-name-base>org.netbeans.modules.jackpot30.duplicates.impl</code-name-base>
174.10 + <suite-component/>
174.11 + <module-dependencies>
174.12 + <dependency>
174.13 + <code-name-base>org.jdesktop.layout</code-name-base>
174.14 + <build-prerequisite/>
174.15 + <compile-dependency/>
174.16 + <run-dependency>
174.17 + <release-version>1</release-version>
174.18 + <specification-version>1.7.0.103</specification-version>
174.19 + </run-dependency>
174.20 + </dependency>
174.21 + <dependency>
174.22 + <code-name-base>org.netbeans.api.annotations.common</code-name-base>
174.23 + <build-prerequisite/>
174.24 + <compile-dependency/>
174.25 + <run-dependency>
174.26 + <release-version>1</release-version>
174.27 + <specification-version>1.0</specification-version>
174.28 + </run-dependency>
174.29 + </dependency>
174.30 + <dependency>
174.31 + <code-name-base>org.netbeans.api.java.classpath</code-name-base>
174.32 + <build-prerequisite/>
174.33 + <compile-dependency/>
174.34 + <run-dependency>
174.35 + <release-version>1</release-version>
174.36 + <specification-version>1.19</specification-version>
174.37 + </run-dependency>
174.38 + </dependency>
174.39 + <dependency>
174.40 + <code-name-base>org.netbeans.api.progress</code-name-base>
174.41 + <build-prerequisite/>
174.42 + <compile-dependency/>
174.43 + <run-dependency>
174.44 + <release-version>1</release-version>
174.45 + <specification-version>1.13.0.1</specification-version>
174.46 + </run-dependency>
174.47 + </dependency>
174.48 + <dependency>
174.49 + <code-name-base>org.netbeans.libs.javacapi</code-name-base>
174.50 + <build-prerequisite/>
174.51 + <compile-dependency/>
174.52 + <run-dependency>
174.53 + <specification-version>7.5.0.3</specification-version>
174.54 + </run-dependency>
174.55 + </dependency>
174.56 + <dependency>
174.57 + <code-name-base>org.netbeans.libs.javacimpl</code-name-base>
174.58 + <build-prerequisite/>
174.59 + <compile-dependency/>
174.60 + <run-dependency>
174.61 + <release-version>1</release-version>
174.62 + <implementation-version/>
174.63 + </run-dependency>
174.64 + </dependency>
174.65 + <dependency>
174.66 + <code-name-base>org.netbeans.libs.lucene</code-name-base>
174.67 + <build-prerequisite/>
174.68 + <compile-dependency/>
174.69 + <run-dependency>
174.70 + <release-version>1-3</release-version>
174.71 + <specification-version>2.13</specification-version>
174.72 + </run-dependency>
174.73 + </dependency>
174.74 + <dependency>
174.75 + <code-name-base>org.netbeans.modules.diff</code-name-base>
174.76 + <build-prerequisite/>
174.77 + <compile-dependency/>
174.78 + <run-dependency>
174.79 + <release-version>1</release-version>
174.80 + <implementation-version/>
174.81 + </run-dependency>
174.82 + </dependency>
174.83 + <dependency>
174.84 + <code-name-base>org.netbeans.modules.editor</code-name-base>
174.85 + <build-prerequisite/>
174.86 + <compile-dependency/>
174.87 + <run-dependency>
174.88 + <release-version>3</release-version>
174.89 + <specification-version>1.56.0.5.13.6</specification-version>
174.90 + </run-dependency>
174.91 + </dependency>
174.92 + <dependency>
174.93 + <code-name-base>org.netbeans.modules.editor.lib</code-name-base>
174.94 + <build-prerequisite/>
174.95 + <compile-dependency/>
174.96 + <run-dependency>
174.97 + <release-version>1-3</release-version>
174.98 + <specification-version>1.38.0.9.2</specification-version>
174.99 + </run-dependency>
174.100 + </dependency>
174.101 + <dependency>
174.102 + <code-name-base>org.netbeans.modules.editor.lib2</code-name-base>
174.103 + <build-prerequisite/>
174.104 + <compile-dependency/>
174.105 + <run-dependency>
174.106 + <release-version>1</release-version>
174.107 + <specification-version>1.13.0.2</specification-version>
174.108 + </run-dependency>
174.109 + </dependency>
174.110 + <dependency>
174.111 + <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
174.112 + <build-prerequisite/>
174.113 + <compile-dependency/>
174.114 + <run-dependency>
174.115 + <release-version>1</release-version>
174.116 + <specification-version>1.12</specification-version>
174.117 + </run-dependency>
174.118 + </dependency>
174.119 + <dependency>
174.120 + <code-name-base>org.netbeans.modules.editor.settings</code-name-base>
174.121 + <build-prerequisite/>
174.122 + <compile-dependency/>
174.123 + <run-dependency>
174.124 + <release-version>1</release-version>
174.125 + <specification-version>1.25</specification-version>
174.126 + </run-dependency>
174.127 + </dependency>
174.128 + <dependency>
174.129 + <code-name-base>org.netbeans.modules.jackpot30.common</code-name-base>
174.130 + <build-prerequisite/>
174.131 + <compile-dependency/>
174.132 + <run-dependency>
174.133 + <specification-version>1.0</specification-version>
174.134 + </run-dependency>
174.135 + </dependency>
174.136 + <dependency>
174.137 + <code-name-base>org.netbeans.modules.jackpot30.remoting.api</code-name-base>
174.138 + <build-prerequisite/>
174.139 + <compile-dependency/>
174.140 + <run-dependency>
174.141 + <specification-version>1.8</specification-version>
174.142 + </run-dependency>
174.143 + </dependency>
174.144 + <dependency>
174.145 + <code-name-base>org.netbeans.modules.java.editor</code-name-base>
174.146 + <build-prerequisite/>
174.147 + <compile-dependency/>
174.148 + <run-dependency>
174.149 + <release-version>1</release-version>
174.150 + <implementation-version/>
174.151 + </run-dependency>
174.152 + </dependency>
174.153 + <dependency>
174.154 + <code-name-base>org.netbeans.modules.java.lexer</code-name-base>
174.155 + <build-prerequisite/>
174.156 + <compile-dependency/>
174.157 + <run-dependency>
174.158 + <release-version>1</release-version>
174.159 + <specification-version>1.9</specification-version>
174.160 + </run-dependency>
174.161 + </dependency>
174.162 + <dependency>
174.163 + <code-name-base>org.netbeans.modules.java.platform</code-name-base>
174.164 + <build-prerequisite/>
174.165 + <compile-dependency/>
174.166 + <run-dependency>
174.167 + <release-version>1</release-version>
174.168 + <specification-version>1.12</specification-version>
174.169 + </run-dependency>
174.170 + </dependency>
174.171 + <dependency>
174.172 + <code-name-base>org.netbeans.modules.java.preprocessorbridge</code-name-base>
174.173 + <build-prerequisite/>
174.174 + <compile-dependency/>
174.175 + <run-dependency>
174.176 + <implementation-version/>
174.177 + </run-dependency>
174.178 + </dependency>
174.179 + <dependency>
174.180 + <code-name-base>org.netbeans.modules.java.source</code-name-base>
174.181 + <build-prerequisite/>
174.182 + <compile-dependency/>
174.183 + <run-dependency>
174.184 + <implementation-version/>
174.185 + </run-dependency>
174.186 + </dependency>
174.187 + <dependency>
174.188 + <code-name-base>org.netbeans.modules.lexer</code-name-base>
174.189 + <build-prerequisite/>
174.190 + <compile-dependency/>
174.191 + <run-dependency>
174.192 + <release-version>2</release-version>
174.193 + <specification-version>1.34</specification-version>
174.194 + </run-dependency>
174.195 + </dependency>
174.196 + <dependency>
174.197 + <code-name-base>org.netbeans.modules.options.api</code-name-base>
174.198 + <build-prerequisite/>
174.199 + <compile-dependency/>
174.200 + <run-dependency>
174.201 + <release-version>1</release-version>
174.202 + <specification-version>1.20</specification-version>
174.203 + </run-dependency>
174.204 + </dependency>
174.205 + <dependency>
174.206 + <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
174.207 + <build-prerequisite/>
174.208 + <compile-dependency/>
174.209 + <run-dependency>
174.210 + <release-version>1</release-version>
174.211 + <implementation-version/>
174.212 + </run-dependency>
174.213 + </dependency>
174.214 + <dependency>
174.215 + <code-name-base>org.netbeans.modules.projectapi</code-name-base>
174.216 + <build-prerequisite/>
174.217 + <compile-dependency/>
174.218 + <run-dependency>
174.219 + <release-version>1</release-version>
174.220 + <specification-version>1.24</specification-version>
174.221 + </run-dependency>
174.222 + </dependency>
174.223 + <dependency>
174.224 + <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
174.225 + <build-prerequisite/>
174.226 + <compile-dependency/>
174.227 + <run-dependency>
174.228 + <release-version>1</release-version>
174.229 + <specification-version>1.35.0.6</specification-version>
174.230 + </run-dependency>
174.231 + </dependency>
174.232 + <dependency>
174.233 + <code-name-base>org.netbeans.modules.queries</code-name-base>
174.234 + <build-prerequisite/>
174.235 + <compile-dependency/>
174.236 + <run-dependency>
174.237 + <release-version>1</release-version>
174.238 + <specification-version>1.15</specification-version>
174.239 + </run-dependency>
174.240 + </dependency>
174.241 + <dependency>
174.242 + <code-name-base>org.netbeans.modules.refactoring.api</code-name-base>
174.243 + <build-prerequisite/>
174.244 + <compile-dependency/>
174.245 + <run-dependency>
174.246 + <specification-version>1.6</specification-version>
174.247 + </run-dependency>
174.248 + </dependency>
174.249 + <dependency>
174.250 + <code-name-base>org.netbeans.modules.refactoring.java</code-name-base>
174.251 + <build-prerequisite/>
174.252 + <compile-dependency/>
174.253 + <run-dependency>
174.254 + <release-version>1</release-version>
174.255 + <specification-version>1.6</specification-version>
174.256 + </run-dependency>
174.257 + </dependency>
174.258 + <dependency>
174.259 + <code-name-base>org.netbeans.modules.sendopts</code-name-base>
174.260 + <build-prerequisite/>
174.261 + <compile-dependency/>
174.262 + <run-dependency>
174.263 + <release-version>2</release-version>
174.264 + <specification-version>2.4</specification-version>
174.265 + </run-dependency>
174.266 + </dependency>
174.267 + <dependency>
174.268 + <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
174.269 + <build-prerequisite/>
174.270 + <compile-dependency/>
174.271 + <run-dependency>
174.272 + <release-version>0-1</release-version>
174.273 + <specification-version>1.7.0.7.2</specification-version>
174.274 + </run-dependency>
174.275 + </dependency>
174.276 + <dependency>
174.277 + <code-name-base>org.netbeans.spi.java.hints</code-name-base>
174.278 + <build-prerequisite/>
174.279 + <compile-dependency/>
174.280 + <run-dependency>
174.281 + <implementation-version/>
174.282 + </run-dependency>
174.283 + </dependency>
174.284 + <dependency>
174.285 + <code-name-base>org.openide.awt</code-name-base>
174.286 + <build-prerequisite/>
174.287 + <compile-dependency/>
174.288 + <run-dependency>
174.289 + <specification-version>7.7.0.1</specification-version>
174.290 + </run-dependency>
174.291 + </dependency>
174.292 + <dependency>
174.293 + <code-name-base>org.openide.dialogs</code-name-base>
174.294 + <build-prerequisite/>
174.295 + <compile-dependency/>
174.296 + <run-dependency>
174.297 + <specification-version>7.10</specification-version>
174.298 + </run-dependency>
174.299 + </dependency>
174.300 + <dependency>
174.301 + <code-name-base>org.openide.filesystems</code-name-base>
174.302 + <build-prerequisite/>
174.303 + <compile-dependency/>
174.304 + <run-dependency>
174.305 + <specification-version>7.21.0.1.1</specification-version>
174.306 + </run-dependency>
174.307 + </dependency>
174.308 + <dependency>
174.309 + <code-name-base>org.openide.loaders</code-name-base>
174.310 + <build-prerequisite/>
174.311 + <compile-dependency/>
174.312 + <run-dependency>
174.313 + <specification-version>7.5</specification-version>
174.314 + </run-dependency>
174.315 + </dependency>
174.316 + <dependency>
174.317 + <code-name-base>org.openide.modules</code-name-base>
174.318 + <build-prerequisite/>
174.319 + <compile-dependency/>
174.320 + <run-dependency>
174.321 + <specification-version>7.10</specification-version>
174.322 + </run-dependency>
174.323 + </dependency>
174.324 + <dependency>
174.325 + <code-name-base>org.openide.nodes</code-name-base>
174.326 + <build-prerequisite/>
174.327 + <compile-dependency/>
174.328 + <run-dependency>
174.329 + <specification-version>7.9.0.1</specification-version>
174.330 + </run-dependency>
174.331 + </dependency>
174.332 + <dependency>
174.333 + <code-name-base>org.openide.text</code-name-base>
174.334 + <build-prerequisite/>
174.335 + <compile-dependency/>
174.336 + <run-dependency>
174.337 + <specification-version>6.22</specification-version>
174.338 + </run-dependency>
174.339 + </dependency>
174.340 + <dependency>
174.341 + <code-name-base>org.openide.util</code-name-base>
174.342 + <build-prerequisite/>
174.343 + <compile-dependency/>
174.344 + <run-dependency>
174.345 + <specification-version>8.0</specification-version>
174.346 + </run-dependency>
174.347 + </dependency>
174.348 + <dependency>
174.349 + <code-name-base>org.openide.util.lookup</code-name-base>
174.350 + <build-prerequisite/>
174.351 + <compile-dependency/>
174.352 + <run-dependency>
174.353 + <specification-version>8.0.0.1</specification-version>
174.354 + </run-dependency>
174.355 + </dependency>
174.356 + <dependency>
174.357 + <code-name-base>org.openide.windows</code-name-base>
174.358 + <build-prerequisite/>
174.359 + <compile-dependency/>
174.360 + <run-dependency>
174.361 + <specification-version>6.27</specification-version>
174.362 + </run-dependency>
174.363 + </dependency>
174.364 + </module-dependencies>
174.365 + <test-dependencies>
174.366 + <test-type>
174.367 + <name>unit</name>
174.368 + <test-dependency>
174.369 + <code-name-base>org.netbeans.libs.junit4</code-name-base>
174.370 + <compile-dependency/>
174.371 + </test-dependency>
174.372 + <test-dependency>
174.373 + <code-name-base>org.netbeans.modules.jackpot30.common.test</code-name-base>
174.374 + <recursive/>
174.375 + <compile-dependency/>
174.376 + </test-dependency>
174.377 + <test-dependency>
174.378 + <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
174.379 + <recursive/>
174.380 + <compile-dependency/>
174.381 + </test-dependency>
174.382 + <test-dependency>
174.383 + <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
174.384 + <recursive/>
174.385 + <compile-dependency/>
174.386 + </test-dependency>
174.387 + </test-type>
174.388 + </test-dependencies>
174.389 + <public-packages/>
174.390 + </data>
174.391 + </configuration>
174.392 +</project>
175.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
175.2 +++ b/duplicates/ide/impl/nbproject/suite.properties Mon Mar 12 21:10:10 2012 +0100
175.3 @@ -0,0 +1,1 @@
175.4 +suite.dir=${basedir}/..
176.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
176.2 +++ b/duplicates/ide/impl/src/org/netbeans/modules/jackpot30/duplicates/impl/Bundle.properties Mon Mar 12 21:10:10 2012 +0100
176.3 @@ -0,0 +1,1 @@
176.4 +OpenIDE-Module-Name=Jackpot 3.0 Duplicates Impl
177.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
177.2 +++ b/duplicates/ide/impl/src/org/netbeans/modules/jackpot30/impl/duplicates/Bundle.properties Mon Mar 12 21:10:10 2012 +0100
177.3 @@ -0,0 +1,3 @@
177.4 +CTL_GlobalFindDuplicates=Global Find Duplicates
177.5 +DuplicatesListPanel.findMore.text=<html><body><a href="">Look for More</a>
177.6 +DuplicatesListPanel.progressLabel.text=
178.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
178.2 +++ b/duplicates/ide/impl/src/org/netbeans/modules/jackpot30/impl/duplicates/ComputeDuplicates.java Mon Mar 12 21:10:10 2012 +0100
178.3 @@ -0,0 +1,458 @@
178.4 +/*
178.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
178.6 + *
178.7 + * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
178.8 + *
178.9 + * The contents of this file are subject to the terms of either the GNU
178.10 + * General Public License Version 2 only ("GPL") or the Common
178.11 + * Development and Distribution License("CDDL") (collectively, the
178.12 + * "License"). You may not use this file except in compliance with the
178.13 + * License. You can obtain a copy of the License at
178.14 + * http://www.netbeans.org/cddl-gplv2.html
178.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
178.16 + * specific language governing permissions and limitations under the
178.17 + * License. When distributing the software, include this License Header
178.18 + * Notice in each file and include the License file at
178.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
178.20 + * particular file as subject to the "Classpath" exception as provided
178.21 + * by Sun in the GPL Version 2 section of the License file that
178.22 + * accompanied this code. If applicable, add the following below the
178.23 + * License Header, with the fields enclosed by brackets [] replaced by
178.24 + * your own identifying information:
178.25 + * "Portions Copyrighted [year] [name of copyright owner]"
178.26 + *
178.27 + * If you wish your version of this file to be governed by only the CDDL
178.28 + * or only the GPL Version 2, indicate your decision by adding
178.29 + * "[Contributor] elects to include this software in this distribution
178.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
178.31 + * single choice of license, a recipient has the option to distribute
178.32 + * your version of this file under either the CDDL, the GPL Version 2 or
178.33 + * to extend the choice of license to its licensees as provided above.
178.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
178.35 + * Version 2 license, then the option applies only if the new code is
178.36 + * made subject to such option by the copyright holder.
178.37 + *
178.38 + * Contributor(s):
178.39 + *
178.40 + * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
178.41 + */
178.42 +package org.netbeans.modules.jackpot30.impl.duplicates;
178.43 +
178.44 +import com.sun.source.tree.CompilationUnitTree;
178.45 +import com.sun.source.tree.Tree;
178.46 +import com.sun.source.util.SourcePositions;
178.47 +import com.sun.source.util.TreePath;
178.48 +import com.sun.source.util.TreePathScanner;
178.49 +import com.sun.source.util.Trees;
178.50 +import java.io.ByteArrayOutputStream;
178.51 +import java.io.File;
178.52 +import java.io.IOException;
178.53 +import java.net.URL;
178.54 +import java.security.DigestOutputStream;
178.55 +import java.security.MessageDigest;
178.56 +import java.security.NoSuchAlgorithmException;
178.57 +import java.util.ArrayList;
178.58 +import java.util.Arrays;
178.59 +import java.util.BitSet;
178.60 +import java.util.Collection;
178.61 +import java.util.Collections;
178.62 +import java.util.Comparator;
178.63 +import java.util.HashMap;
178.64 +import java.util.HashSet;
178.65 +import java.util.Iterator;
178.66 +import java.util.LinkedHashMap;
178.67 +import java.util.LinkedList;
178.68 +import java.util.List;
178.69 +import java.util.Map;
178.70 +import java.util.Map.Entry;
178.71 +import java.util.NoSuchElementException;
178.72 +import java.util.Set;
178.73 +import java.util.TreeMap;
178.74 +import java.util.concurrent.atomic.AtomicBoolean;
178.75 +import javax.tools.JavaCompiler.CompilationTask;
178.76 +import org.apache.lucene.document.Document;
178.77 +import org.apache.lucene.index.IndexReader;
178.78 +import org.apache.lucene.index.MultiReader;
178.79 +import org.apache.lucene.index.Term;
178.80 +import org.apache.lucene.index.TermEnum;
178.81 +import org.apache.lucene.search.Collector;
178.82 +import org.apache.lucene.search.IndexSearcher;
178.83 +import org.apache.lucene.search.Query;
178.84 +import org.apache.lucene.search.Searcher;
178.85 +import org.apache.lucene.search.TermQuery;
178.86 +import org.apache.lucene.store.FSDirectory;
178.87 +import org.netbeans.api.annotations.common.CheckForNull;
178.88 +import org.netbeans.api.java.classpath.ClassPath;
178.89 +import org.netbeans.api.java.classpath.GlobalPathRegistry;
178.90 +import org.netbeans.api.java.source.CompilationInfo;
178.91 +import org.netbeans.api.progress.ProgressHandle;
178.92 +import org.netbeans.modules.jackpot30.common.api.LuceneHelpers.BitSetCollector;
178.93 +import org.netbeans.modules.jackpot30.impl.duplicates.indexing.DuplicatesCustomIndexerImpl;
178.94 +import org.netbeans.modules.jackpot30.impl.duplicates.indexing.DuplicatesIndex;
178.95 +import org.netbeans.modules.java.hints.spiimpl.Utilities;
178.96 +import org.netbeans.modules.java.hints.spiimpl.pm.BulkSearch;
178.97 +import org.netbeans.modules.java.hints.spiimpl.pm.BulkSearch.EncodingContext;
178.98 +import org.netbeans.modules.java.source.JavaSourceAccessor;
178.99 +import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
178.100 +import org.openide.filesystems.FileObject;
178.101 +import org.openide.filesystems.FileUtil;
178.102 +import org.openide.filesystems.URLMapper;
178.103 +import org.openide.util.Exceptions;
178.104 +
178.105 +
178.106 +/**
178.107 + *
178.108 + * @author lahvac
178.109 + */
178.110 +public class ComputeDuplicates {
178.111 +
178.112 + public Iterator<? extends DuplicateDescription> computeDuplicatesForAllOpenedProjects(ProgressHandle progress, AtomicBoolean cancel) throws IOException {
178.113 + Set<URL> urls = new HashSet<URL>();
178.114 +
178.115 + for (ClassPath cp : GlobalPathRegistry.getDefault().getPaths(ClassPath.SOURCE)) {
178.116 + for (ClassPath.Entry e : cp.entries()) {
178.117 + urls.add(e.getURL());
178.118 + }
178.119 + }
178.120 +
178.121 + long start = System.currentTimeMillis();
178.122 + try {
178.123 + return computeDuplicates(urls, progress, cancel);
178.124 + } finally {
178.125 + System.err.println("duplicates for all open projects: " + (System.currentTimeMillis() - start));
178.126 + }
178.127 + }
178.128 +
178.129 + public Iterator<? extends DuplicateDescription> computeDuplicates(Set<URL> forURLs, ProgressHandle progress, AtomicBoolean cancel) throws IOException {
178.130 + Map<IndexReader, FileObject> readers2Roots = new LinkedHashMap<IndexReader, FileObject>();
178.131 +
178.132 + progress.progress("Updating indices");
178.133 +
178.134 + for (URL u : forURLs) {
178.135 + try {
178.136 + //TODO: needs to be removed for server mode
178.137 + new DuplicatesCustomIndexerImpl.FactoryImpl().updateIndex(u, cancel); //TODO: show updating progress to the user
178.138 +
178.139 + File cacheRoot = cacheRoot(u);
178.140 +
178.141 + File dir = new File(cacheRoot, DuplicatesIndex.NAME);
178.142 +
178.143 + if (dir.listFiles() != null && dir.listFiles().length > 0) {
178.144 + IndexReader reader = IndexReader.open(FSDirectory.open(dir), true);
178.145 +
178.146 + readers2Roots.put(reader, URLMapper.findFileObject(u));
178.147 + }
178.148 + } catch (IOException ex) {
178.149 + Exceptions.printStackTrace(ex);
178.150 + }
178.151 + }
178.152 +
178.153 + progress.progress("Searching for duplicates");
178.154 +
178.155 + MultiReader r = new MultiReader(readers2Roots.keySet().toArray(new IndexReader[0]));
178.156 +
178.157 + List<String> dd = new ArrayList<String>(getDuplicatedValues(r, "generalized", cancel));
178.158 +
178.159 + sortHashes(dd);
178.160 +
178.161 + //TODO: only show valuable duplicates?:
178.162 +// dd = dd.subList(0, dd.size() / 10 + 1);
178.163 +
178.164 + return new DuplicatesIterator(readers2Roots, dd, 2);
178.165 + }
178.166 +
178.167 + public static Iterator<? extends DuplicateDescription> XXXduplicatesOf(Map<IndexReader, FileObject> readers2Roots, Collection<String> hashes) {
178.168 + List<String> hashesList = new ArrayList<String>(hashes);
178.169 + sortHashes(hashesList);
178.170 + return new DuplicatesIterator(readers2Roots, hashesList, 1);
178.171 + }
178.172 +
178.173 + private static File cacheRoot(URL sourceRoot) throws IOException {
178.174 + FileObject dataFolder = CacheFolder.getDataFolder(sourceRoot);
178.175 + FileObject cacheFO = dataFolder.getFileObject(DuplicatesIndex.NAME + "/" +DuplicatesIndex.VERSION);
178.176 + File cache = cacheFO != null ? FileUtil.toFile(cacheFO) : null;
178.177 +
178.178 + return cache;
178.179 + }
178.180 +
178.181 + private static final class DuplicatesIterator implements Iterator<DuplicateDescription> {
178.182 + private final Map<IndexReader, FileObject> readers2Roots;
178.183 + private final Iterator<String> duplicateCandidates;
178.184 + private final int minDuplicates;
178.185 + private final List<DuplicateDescription> result = new LinkedList<DuplicateDescription>();
178.186 +
178.187 + public DuplicatesIterator(Map<IndexReader, FileObject> readers2Roots, Iterable<String> duplicateCandidates, int minDuplicates) {
178.188 + this.readers2Roots = readers2Roots;
178.189 + this.duplicateCandidates = duplicateCandidates.iterator();
178.190 + this.minDuplicates = minDuplicates;
178.191 + }
178.192 +
178.193 + private DuplicateDescription nextDescription() throws IOException {
178.194 + while (duplicateCandidates.hasNext()) {
178.195 + String longest = duplicateCandidates.next();
178.196 + List<Span> foundDuplicates = new LinkedList<Span>();
178.197 +
178.198 + Query query = new TermQuery(new Term("generalized", longest));
178.199 +
178.200 + for (Entry<IndexReader, FileObject> e : readers2Roots.entrySet()) {
178.201 + Searcher s = new IndexSearcher(e.getKey());
178.202 + BitSet matchingDocuments = new BitSet(e.getKey().maxDoc());
178.203 + Collector c = new BitSetCollector(matchingDocuments);
178.204 +
178.205 + s.search(query, c);
178.206 +
178.207 + for (int docNum = matchingDocuments.nextSetBit(0); docNum >= 0; docNum = matchingDocuments.nextSetBit(docNum + 1)) {
178.208 + final Document doc = e.getKey().document(docNum);
178.209 + int pos = Arrays.binarySearch(doc.getValues("generalized"), longest);
178.210 +
178.211 + if (pos < 0) {
178.212 + System.err.println("FOOBAR=" + pos);
178.213 + continue;
178.214 + }
178.215 +
178.216 + String spanSpec = doc.getValues("positions")[pos];
178.217 + String relPath = doc.getField("path").stringValue();
178.218 +
178.219 + for (String spanPart : spanSpec.split(";")) {
178.220 + Span span = Span.of(e.getValue().getFileObject(relPath), spanPart);
178.221 +
178.222 + if (span != null) {
178.223 + foundDuplicates.add(span);
178.224 + }
178.225 + }
178.226 + }
178.227 + }
178.228 +
178.229 + if (foundDuplicates.size() >= minDuplicates) {
178.230 + DuplicateDescription current = DuplicateDescription.of(foundDuplicates, getValue(longest), longest);
178.231 + boolean add = true;
178.232 +
178.233 + for (Iterator<DuplicateDescription> it = result.iterator(); it.hasNext();) {
178.234 + DuplicateDescription existing = it.next();
178.235 +
178.236 + if (subsumes(existing, current)) {
178.237 + add = false;
178.238 + break;
178.239 + }
178.240 +
178.241 + if (subsumes(current, existing)) {
178.242 + //can happen? (note that the duplicates are sorted by value)
178.243 + it.remove();
178.244 + }
178.245 + }
178.246 +
178.247 + if (add) {
178.248 + result.add(current);
178.249 + return current;
178.250 + }
178.251 + }
178.252 +
178.253 + }
178.254 + return null;
178.255 + }
178.256 +
178.257 + private DuplicateDescription next;
178.258 +
178.259 + public boolean hasNext() {
178.260 + if (next == null) {
178.261 + try {
178.262 + next = nextDescription();
178.263 + } catch (IOException ex) {
178.264 + Exceptions.printStackTrace(ex);
178.265 + }
178.266 + }
178.267 +
178.268 + return next != null;
178.269 + }
178.270 +
178.271 + public DuplicateDescription next() {
178.272 + if (!hasNext()) {
178.273 + throw new NoSuchElementException();
178.274 + }
178.275 +
178.276 + DuplicateDescription r = next;
178.277 +
178.278 + next = null;
178.279 + return r;
178.280 + }
178.281 +
178.282 + public void remove() {
178.283 + throw new UnsupportedOperationException("Not supported.");
178.284 + }
178.285 +
178.286 + }
178.287 +
178.288 + private static List<String> getDuplicatedValues(IndexReader ir, String field, AtomicBoolean cancel) throws IOException {
178.289 + List<String> values = new ArrayList<String>();
178.290 + TermEnum terms = ir.terms( new Term(field));
178.291 + //while (terms.next()) {
178.292 + do {
178.293 + if (cancel.get()) return Collections.emptyList();
178.294 +
178.295 + final Term term = terms.term();
178.296 +
178.297 + if ( !field.equals( term.field() ) ) {
178.298 + break;
178.299 + }
178.300 +
178.301 + if (terms.docFreq() < 2) continue;
178.302 +
178.303 + values.add(term.text());
178.304 + }
178.305 + while (terms.next());
178.306 + return values;
178.307 + }
178.308 +
178.309 + private static long getValue(String encoded) {
178.310 + return Long.parseLong(encoded.substring(encoded.lastIndexOf(":") + 1));
178.311 + }
178.312 +
178.313 + private static void sortHashes(List<String> hashes) {
178.314 + Collections.sort(hashes, new Comparator<String>() {
178.315 + public int compare(String arg0, String arg1) {
178.316 + return (int) Math.signum(getValue(arg1) - getValue(arg0));
178.317 + }
178.318 + });
178.319 + }
178.320 +
178.321 + private static boolean subsumes(DuplicateDescription bigger, DuplicateDescription smaller) {
178.322 + Set<FileObject> bFiles = new HashSet<FileObject>();
178.323 +
178.324 + for (Span s : bigger.dupes) {
178.325 + bFiles.add(s.file);
178.326 + }
178.327 +
178.328 + Set<FileObject> sFiles = new HashSet<FileObject>();
178.329 +
178.330 + for (Span s : smaller.dupes) {
178.331 + sFiles.add(s.file);
178.332 + }
178.333 +
178.334 + if (!bFiles.equals(sFiles)) return false;
178.335 +
178.336 + Span testAgainst = bigger.dupes.get(0);
178.337 +
178.338 + for (Span s : smaller.dupes) {
178.339 + if (s.file == testAgainst.file) {
178.340 + if ( (testAgainst.startOff <= s.startOff && testAgainst.endOff > s.endOff)
178.341 + || (testAgainst.startOff < s.startOff && testAgainst.endOff >= s.endOff)) {
178.342 + return true;
178.343 + }
178.344 + }
178.345 + }
178.346 +
178.347 + return false;
178.348 + }
178.349 +
178.350 + public static Map<String, long[]> encodeGeneralized(CompilationInfo info) {
178.351 + return encodeGeneralized(JavaSourceAccessor.getINSTANCE().getJavacTask(info), info.getCompilationUnit());
178.352 + }
178.353 +
178.354 + public static Map<String, long[]> encodeGeneralized(final CompilationTask task, final CompilationUnitTree cut) {
178.355 + final SourcePositions sp = Trees.instance(task).getSourcePositions();
178.356 + final Map<String, Collection<Long>> positions = new HashMap<String, Collection<Long>>();
178.357 +
178.358 + new TreePathScanner<Void, Void>() {
178.359 + @Override
178.360 + public Void scan(Tree tree, Void p) {
178.361 + if (tree == null) return null;
178.362 + if (getCurrentPath() != null) {
178.363 + Tree generalizedPattern = Utilities.generalizePattern(task, new TreePath(getCurrentPath(), tree));
178.364 + long value = Utilities.patternValue(generalizedPattern);
178.365 + if (value >= MINIMAL_VALUE) {
178.366 + {
178.367 + DigestOutputStream baos = null;
178.368 + try {
178.369 + baos = new DigestOutputStream(new ByteArrayOutputStream(), MessageDigest.getInstance("MD5"));
178.370 + final EncodingContext ec = new BulkSearch.EncodingContext(baos, true);
178.371 + BulkSearch.getDefault().encode( generalizedPattern, ec);
178.372 + StringBuilder text = new StringBuilder();
178.373 + byte[] bytes = baos.getMessageDigest().digest();
178.374 + for (int cntr = 0; cntr < 4; cntr++) {
178.375 + text.append(String.format("%02X", bytes[cntr]));
178.376 + }
178.377 + text.append(':').append(value);
178.378 + String enc = text.toString();
178.379 + Collection<Long> spanSpecs = positions.get(enc);
178.380 + if (spanSpecs == null) {
178.381 + positions.put(enc, spanSpecs = new LinkedList<Long>());
178.382 +// } else {
178.383 +// spanSpecs.append(";");
178.384 + }
178.385 + long start = sp.getStartPosition(cut, tree);
178.386 +// spanSpecs.append(start).append(":").append(sp.getEndPosition(cut, tree) - start);
178.387 + spanSpecs.add(start);
178.388 + spanSpecs.add(sp.getEndPosition(cut, tree));
178.389 + } catch (NoSuchAlgorithmException ex) {
178.390 + Exceptions.printStackTrace(ex);
178.391 + } finally {
178.392 + try {
178.393 + baos.close();
178.394 + } catch (IOException ex) {
178.395 + Exceptions.printStackTrace(ex);
178.396 + }
178.397 + }
178.398 + }
178.399 + }
178.400 + }
178.401 + return super.scan(tree, p);
178.402 + }
178.403 + }.scan(cut, null);
178.404 +
178.405 + Map<String, long[]> result = new TreeMap<String, long[]>();
178.406 +
178.407 + for (Entry<String, Collection<Long>> e : positions.entrySet()) {
178.408 + long[] spans = new long[e.getValue().size()];
178.409 + int idx = 0;
178.410 +
178.411 + for (Long l : e.getValue()) {
178.412 + spans[idx++] = l;
178.413 + }
178.414 +
178.415 + result.put(e.getKey(), spans);
178.416 + }
178.417 +
178.418 + return result;
178.419 + }
178.420 +
178.421 + private static final int MINIMAL_VALUE = 10;
178.422 +
178.423 + public static final class DuplicateDescription {
178.424 +
178.425 + public final List<Span> dupes;
178.426 + public final long value;
178.427 + public final String hash;
178.428 +
178.429 + private DuplicateDescription(List<Span> dupes, long value, String hash) {
178.430 + this.dupes = dupes;
178.431 + this.value = value;
178.432 + this.hash = hash;
178.433 + }
178.434 +
178.435 + public static DuplicateDescription of(List<Span> dupes, long value, String hash) {
178.436 + return new DuplicateDescription(dupes, value, hash);
178.437 + }
178.438 + }
178.439 +
178.440 + public static final class Span {
178.441 + public final FileObject file;
178.442 + public final int startOff;
178.443 + public final int endOff;
178.444 +
178.445 + public Span(FileObject file, int startOff, int endOff) {
178.446 + this.file = file;
178.447 + this.startOff = startOff;
178.448 + this.endOff = endOff;
178.449 + }
178.450 +
178.451 + public static @CheckForNull Span of(FileObject file, String spanSpec) {
178.452 + String[] split = spanSpec.split(":");
178.453 + int start = Integer.valueOf(split[0]);
178.454 + int end = start + Integer.valueOf(split[1]);
178.455 + if (start < 0 || end < 0) return null; //XXX
178.456 +
178.457 + return new Span(file, start, end);
178.458 + }
178.459 +
178.460 + }
178.461 +}
179.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
179.2 +++ b/duplicates/ide/impl/src/org/netbeans/modules/jackpot30/impl/duplicates/DuplicatesListPanel.form Mon Mar 12 21:10:10 2012 +0100
179.3 @@ -0,0 +1,189 @@
179.4 +<?xml version="1.1" encoding="UTF-8" ?>
179.5 +
179.6 +<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
179.7 + <AuxValues>
179.8 + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
179.9 + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
179.10 + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
179.11 + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
179.12 + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
179.13 + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
179.14 + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
179.15 + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
179.16 + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
179.17 + </AuxValues>
179.18 +
179.19 + <Layout>
179.20 + <DimensionLayout dim="0">
179.21 + <Group type="103" groupAlignment="0" attributes="0">
179.22 + <Group type="102" alignment="1" attributes="0">
179.23 + <EmptySpace max="-2" attributes="0"/>
179.24 + <Group type="103" groupAlignment="1" attributes="0">
179.25 + <Component id="mainSplit2" alignment="0" pref="906" max="32767" attributes="0"/>
179.26 + <Component id="jScrollPane1" alignment="0" pref="906" max="32767" attributes="0"/>
179.27 + <Component id="jPanel1" alignment="1" min="-2" max="-2" attributes="0"/>
179.28 + </Group>
179.29 + <EmptySpace max="-2" attributes="0"/>
179.30 + </Group>
179.31 + </Group>
179.32 + </DimensionLayout>
179.33 + <DimensionLayout dim="1">
179.34 + <Group type="103" groupAlignment="0" attributes="0">
179.35 + <Group type="102" attributes="0">
179.36 + <EmptySpace min="-2" max="-2" attributes="0"/>
179.37 + <Component id="jScrollPane1" min="-2" pref="67" max="-2" attributes="0"/>
179.38 + <EmptySpace min="-2" max="-2" attributes="0"/>
179.39 + <Component id="mainSplit2" pref="467" max="32767" attributes="0"/>
179.40 + <EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
179.41 + <Component id="jPanel1" min="-2" max="-2" attributes="0"/>
179.42 + <EmptySpace min="-2" max="-2" attributes="0"/>
179.43 + </Group>
179.44 + </Group>
179.45 + </DimensionLayout>
179.46 + </Layout>
179.47 + <SubComponents>
179.48 + <Container class="javax.swing.JScrollPane" name="jScrollPane1">
179.49 +
179.50 + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
179.51 + <SubComponents>
179.52 + <Component class="javax.swing.JList" name="duplicatesList">
179.53 + <Properties>
179.54 + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
179.55 + <StringArray count="0"/>
179.56 + </Property>
179.57 + <Property name="prototypeCellValue" type="java.lang.Object" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
179.58 + <Connection code=""9999999999999999999999999999999999999999999999999999999999999999999999"" type="code"/>
179.59 + </Property>
179.60 + <Property name="visibleRowCount" type="int" value="4"/>
179.61 + </Properties>
179.62 + </Component>
179.63 + </SubComponents>
179.64 + </Container>
179.65 + <Container class="javax.swing.JSplitPane" name="mainSplit2">
179.66 + <Properties>
179.67 + <Property name="dividerLocation" type="int" value="400"/>
179.68 + </Properties>
179.69 + <AuxValues>
179.70 + <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new BalancedSplitPane()"/>
179.71 + </AuxValues>
179.72 +
179.73 + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
179.74 + <SubComponents>
179.75 + <Container class="javax.swing.JPanel" name="rightPanel">
179.76 + <Constraints>
179.77 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
179.78 + <JSplitPaneConstraints position="right"/>
179.79 + </Constraint>
179.80 + </Constraints>
179.81 +
179.82 + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
179.83 + <SubComponents>
179.84 + <Component class="javax.swing.JComboBox" name="rightFileList">
179.85 + <Properties>
179.86 + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
179.87 + <StringArray count="0"/>
179.88 + </Property>
179.89 + </Properties>
179.90 + <Constraints>
179.91 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
179.92 + <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="2" ipadX="324" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="0.0"/>
179.93 + </Constraint>
179.94 + </Constraints>
179.95 + </Component>
179.96 + <Container class="javax.swing.JScrollPane" name="jScrollPane3">
179.97 + <AuxValues>
179.98 + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
179.99 + </AuxValues>
179.100 + <Constraints>
179.101 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
179.102 + <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="1.0"/>
179.103 + </Constraint>
179.104 + </Constraints>
179.105 +
179.106 + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
179.107 + <SubComponents>
179.108 + <Component class="javax.swing.JEditorPane" name="right">
179.109 + </Component>
179.110 + </SubComponents>
179.111 + </Container>
179.112 + </SubComponents>
179.113 + </Container>
179.114 + <Container class="javax.swing.JPanel" name="leftPanel">
179.115 + <Constraints>
179.116 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
179.117 + <JSplitPaneConstraints position="left"/>
179.118 + </Constraint>
179.119 + </Constraints>
179.120 +
179.121 + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
179.122 + <SubComponents>
179.123 + <Container class="javax.swing.JScrollPane" name="jScrollPane2">
179.124 + <AuxValues>
179.125 + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
179.126 + </AuxValues>
179.127 + <Constraints>
179.128 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
179.129 + <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="1.0"/>
179.130 + </Constraint>
179.131 + </Constraints>
179.132 +
179.133 + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
179.134 + <SubComponents>
179.135 + <Component class="javax.swing.JEditorPane" name="left">
179.136 + </Component>
179.137 + </SubComponents>
179.138 + </Container>
179.139 + <Component class="javax.swing.JComboBox" name="leftFileList">
179.140 + <Properties>
179.141 + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
179.142 + <StringArray count="0"/>
179.143 + </Property>
179.144 + </Properties>
179.145 + <Constraints>
179.146 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
179.147 + <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="0.0"/>
179.148 + </Constraint>
179.149 + </Constraints>
179.150 + </Component>
179.151 + </SubComponents>
179.152 + </Container>
179.153 + </SubComponents>
179.154 + </Container>
179.155 + <Container class="javax.swing.JPanel" name="jPanel1">
179.156 +
179.157 + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
179.158 + <SubComponents>
179.159 + <Component class="javax.swing.JLabel" name="progressLabel">
179.160 + <Properties>
179.161 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
179.162 + <ResourceString bundle="org/netbeans/modules/jackpot30/impl/duplicates/Bundle.properties" key="DuplicatesListPanel.progressLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
179.163 + </Property>
179.164 + </Properties>
179.165 + <Constraints>
179.166 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
179.167 + <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="0.0"/>
179.168 + </Constraint>
179.169 + </Constraints>
179.170 + </Component>
179.171 + <Component class="javax.swing.JLabel" name="findMore">
179.172 + <Properties>
179.173 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
179.174 + <ResourceString bundle="org/netbeans/modules/jackpot30/impl/duplicates/Bundle.properties" key="DuplicatesListPanel.findMore.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
179.175 + </Property>
179.176 + <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
179.177 + <Color id="Hand Cursor"/>
179.178 + </Property>
179.179 + </Properties>
179.180 + <Events>
179.181 + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="findMoreMouseClicked"/>
179.182 + </Events>
179.183 + <Constraints>
179.184 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
179.185 + <GridBagConstraints gridX="1" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="6" insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
179.186 + </Constraint>
179.187 + </Constraints>
179.188 + </Component>
179.189 + </SubComponents>
179.190 + </Container>
179.191 + </SubComponents>
179.192 +</Form>
180.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
180.2 +++ b/duplicates/ide/impl/src/org/netbeans/modules/jackpot30/impl/duplicates/DuplicatesListPanel.java Mon Mar 12 21:10:10 2012 +0100
180.3 @@ -0,0 +1,464 @@
180.4 +/*
180.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
180.6 + *
180.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
180.8 + *
180.9 + * The contents of this file are subject to the terms of either the GNU
180.10 + * General Public License Version 2 only ("GPL") or the Common
180.11 + * Development and Distribution License("CDDL") (collectively, the
180.12 + * "License"). You may not use this file except in compliance with the
180.13 + * License. You can obtain a copy of the License at
180.14 + * http://www.netbeans.org/cddl-gplv2.html
180.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
180.16 + * specific language governing permissions and limitations under the
180.17 + * License. When distributing the software, include this License Header
180.18 + * Notice in each file and include the License file at
180.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
180.20 + * particular file as subject to the "Classpath" exception as provided
180.21 + * by Sun in the GPL Version 2 section of the License file that
180.22 + * accompanied this code. If applicable, add the following below the
180.23 + * License Header, with the fields enclosed by brackets [] replaced by
180.24 + * your own identifying information:
180.25 + * "Portions Copyrighted [year] [name of copyright owner]"
180.26 + *
180.27 + * If you wish your version of this file to be governed by only the CDDL
180.28 + * or only the GPL Version 2, indicate your decision by adding
180.29 + * "[Contributor] elects to include this software in this distribution
180.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
180.31 + * single choice of license, a recipient has the option to distribute
180.32 + * your version of this file under either the CDDL, the GPL Version 2 or
180.33 + * to extend the choice of license to its licensees as provided above.
180.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
180.35 + * Version 2 license, then the option applies only if the new code is
180.36 + * made subject to such option by the copyright holder.
180.37 + *
180.38 + * Contributor(s):
180.39 + *
180.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
180.41 + */
180.42 +package org.netbeans.modules.jackpot30.impl.duplicates;
180.43 +
180.44 +import java.awt.Color;
180.45 +import java.awt.Component;
180.46 +import java.awt.Rectangle;
180.47 +import java.awt.event.ActionEvent;
180.48 +import java.awt.event.ActionListener;
180.49 +import java.io.IOException;
180.50 +import java.util.Collection;
180.51 +import java.util.Iterator;
180.52 +import java.util.LinkedHashSet;
180.53 +import java.util.Set;
180.54 +import javax.swing.DefaultComboBoxModel;
180.55 +import javax.swing.DefaultListCellRenderer;
180.56 +import javax.swing.DefaultListModel;
180.57 +import javax.swing.JEditorPane;
180.58 +import javax.swing.JList;
180.59 +import javax.swing.JSplitPane;
180.60 +import javax.swing.SwingUtilities;
180.61 +import javax.swing.event.ListSelectionEvent;
180.62 +import javax.swing.event.ListSelectionListener;
180.63 +import javax.swing.text.AttributeSet;
180.64 +import javax.swing.text.BadLocationException;
180.65 +import javax.swing.text.StyleConstants;
180.66 +import org.netbeans.api.editor.mimelookup.MimePath;
180.67 +import org.netbeans.api.editor.settings.AttributesUtilities;
180.68 +import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.DuplicateDescription;
180.69 +import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.Span;
180.70 +import org.netbeans.spi.editor.highlighting.HighlightsLayer;
180.71 +import org.netbeans.spi.editor.highlighting.HighlightsLayerFactory;
180.72 +import org.netbeans.spi.editor.highlighting.ZOrder;
180.73 +import org.netbeans.spi.editor.highlighting.support.OffsetsBag;
180.74 +import org.netbeans.spi.editor.mimelookup.MimeDataProvider;
180.75 +import org.openide.filesystems.FileObject;
180.76 +import org.openide.filesystems.FileUtil;
180.77 +import org.openide.util.Exceptions;
180.78 +import org.openide.util.Lookup;
180.79 +import org.openide.util.RequestProcessor;
180.80 +import org.openide.util.RequestProcessor.Task;
180.81 +import org.openide.util.lookup.Lookups;
180.82 +import org.openide.util.lookup.ServiceProvider;
180.83 +
180.84 +/**
180.85 + *
180.86 + * @author lahvac
180.87 + */
180.88 +public class DuplicatesListPanel extends javax.swing.JPanel {
180.89 + private final Collection<String> sourceRoots;
180.90 + private final Iterator<? extends DuplicateDescription> dupes;
180.91 +
180.92 + private int targetCount;
180.93 +
180.94 + public DuplicatesListPanel(Collection<String> sourceRoots, final Iterator<? extends DuplicateDescription> dupes) {
180.95 + this.sourceRoots = sourceRoots;
180.96 + this.dupes = dupes;
180.97 +
180.98 + initComponents();
180.99 +
180.100 + left.setContentType("text/x-java");
180.101 + left.putClientProperty(DuplicatesListPanel.class, new OffsetsBag(left.getDocument()));
180.102 +
180.103 + right.setContentType("text/x-java");
180.104 + right.putClientProperty(DuplicatesListPanel.class, new OffsetsBag(right.getDocument()));
180.105 +
180.106 + duplicatesList.setModel(new DefaultListModel());
180.107 + duplicatesList.setCellRenderer(new DuplicatesRendererImpl());
180.108 + duplicatesList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
180.109 + public void valueChanged(ListSelectionEvent arg0) {
180.110 + DuplicateDescription dd = (DuplicateDescription) duplicatesList.getSelectedValue();
180.111 + DefaultComboBoxModel l = new DefaultComboBoxModel();
180.112 + DefaultComboBoxModel r = new DefaultComboBoxModel();
180.113 +
180.114 + for (Span s : dd.dupes) {
180.115 + l.addElement(s);
180.116 + r.addElement(s);
180.117 + }
180.118 +
180.119 + leftFileList.setModel(l);
180.120 + rightFileList.setModel(r);
180.121 +
180.122 + leftFileList.setSelectedIndex(0);
180.123 + rightFileList.setSelectedIndex(1);
180.124 + }
180.125 + });
180.126 +
180.127 + leftFileList.setRenderer(new SpanRendererImpl());
180.128 + leftFileList.addActionListener(new ActionListener() {
180.129 +
180.130 + public void actionPerformed(ActionEvent e) {
180.131 + setSpan(left, (Span) leftFileList.getSelectedItem());
180.132 + }
180.133 + });
180.134 + rightFileList.setRenderer(new SpanRendererImpl());
180.135 + rightFileList.addActionListener(new ActionListener() {
180.136 + public void actionPerformed(ActionEvent e) {
180.137 + setSpan(right, (Span) rightFileList.getSelectedItem());
180.138 + }
180.139 + });
180.140 +
180.141 + progressLabel.setText("Looking for duplicates...");
180.142 +
180.143 + findMore();
180.144 + }
180.145 +
180.146 + /** This method is called from within the constructor to
180.147 + * initialize the form.
180.148 + * WARNING: Do NOT modify this code. The content of this method is
180.149 + * always regenerated by the Form Editor.
180.150 + */
180.151 + @SuppressWarnings("unchecked")
180.152 + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
180.153 + private void initComponents() {
180.154 + java.awt.GridBagConstraints gridBagConstraints;
180.155 +
180.156 + jScrollPane1 = new javax.swing.JScrollPane();
180.157 + duplicatesList = new javax.swing.JList();
180.158 + mainSplit2 = new BalancedSplitPane();
180.159 + rightPanel = new javax.swing.JPanel();
180.160 + rightFileList = new javax.swing.JComboBox();
180.161 + jScrollPane3 = new javax.swing.JScrollPane();
180.162 + right = new javax.swing.JEditorPane();
180.163 + leftPanel = new javax.swing.JPanel();
180.164 + jScrollPane2 = new javax.swing.JScrollPane();
180.165 + left = new javax.swing.JEditorPane();
180.166 + leftFileList = new javax.swing.JComboBox();
180.167 + jPanel1 = new javax.swing.JPanel();
180.168 + progressLabel = new javax.swing.JLabel();
180.169 + findMore = new javax.swing.JLabel();
180.170 +
180.171 + duplicatesList.setPrototypeCellValue("9999999999999999999999999999999999999999999999999999999999999999999999");
180.172 + duplicatesList.setVisibleRowCount(4);
180.173 + jScrollPane1.setViewportView(duplicatesList);
180.174 +
180.175 + mainSplit2.setDividerLocation(400);
180.176 +
180.177 + rightPanel.setLayout(new java.awt.GridBagLayout());
180.178 +
180.179 + gridBagConstraints = new java.awt.GridBagConstraints();
180.180 + gridBagConstraints.gridx = 0;
180.181 + gridBagConstraints.gridy = 0;
180.182 + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
180.183 + gridBagConstraints.ipadx = 324;
180.184 + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
180.185 + gridBagConstraints.weightx = 1.0;
180.186 + rightPanel.add(rightFileList, gridBagConstraints);
180.187 +
180.188 + jScrollPane3.setViewportView(right);
180.189 +
180.190 + gridBagConstraints = new java.awt.GridBagConstraints();
180.191 + gridBagConstraints.gridx = 0;
180.192 + gridBagConstraints.gridy = 1;
180.193 + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
180.194 + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
180.195 + gridBagConstraints.weightx = 1.0;
180.196 + gridBagConstraints.weighty = 1.0;
180.197 + gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
180.198 + rightPanel.add(jScrollPane3, gridBagConstraints);
180.199 +
180.200 + mainSplit2.setRightComponent(rightPanel);
180.201 +
180.202 + leftPanel.setLayout(new java.awt.GridBagLayout());
180.203 +
180.204 + jScrollPane2.setViewportView(left);
180.205 +
180.206 + gridBagConstraints = new java.awt.GridBagConstraints();
180.207 + gridBagConstraints.gridx = 0;
180.208 + gridBagConstraints.gridy = 1;
180.209 + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
180.210 + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
180.211 + gridBagConstraints.weightx = 1.0;
180.212 + gridBagConstraints.weighty = 1.0;
180.213 + gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
180.214 + leftPanel.add(jScrollPane2, gridBagConstraints);
180.215 +
180.216 + gridBagConstraints = new java.awt.GridBagConstraints();
180.217 + gridBagConstraints.gridx = 0;
180.218 + gridBagConstraints.gridy = 0;
180.219 + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
180.220 + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
180.221 + gridBagConstraints.weightx = 1.0;
180.222 + leftPanel.add(leftFileList, gridBagConstraints);
180.223 +
180.224 + mainSplit2.setLeftComponent(leftPanel);
180.225 +
180.226 + jPanel1.setLayout(new java.awt.GridBagLayout());
180.227 +
180.228 + progressLabel.setText(org.openide.util.NbBundle.getMessage(DuplicatesListPanel.class, "DuplicatesListPanel.progressLabel.text")); // NOI18N
180.229 + gridBagConstraints = new java.awt.GridBagConstraints();
180.230 + gridBagConstraints.gridx = 0;
180.231 + gridBagConstraints.gridy = 0;
180.232 + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
180.233 + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
180.234 + gridBagConstraints.weightx = 1.0;
180.235 + jPanel1.add(progressLabel, gridBagConstraints);
180.236 +
180.237 + findMore.setText(org.openide.util.NbBundle.getMessage(DuplicatesListPanel.class, "DuplicatesListPanel.findMore.text")); // NOI18N
180.238 + findMore.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
180.239 + findMore.addMouseListener(new java.awt.event.MouseAdapter() {
180.240 + public void mouseClicked(java.awt.event.MouseEvent evt) {
180.241 + findMoreMouseClicked(evt);
180.242 + }
180.243 + });
180.244 + gridBagConstraints = new java.awt.GridBagConstraints();
180.245 + gridBagConstraints.gridx = 1;
180.246 + gridBagConstraints.gridy = 0;
180.247 + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
180.248 + gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0);
180.249 + jPanel1.add(findMore, gridBagConstraints);
180.250 +
180.251 + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
180.252 + this.setLayout(layout);
180.253 + layout.setHorizontalGroup(
180.254 + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
180.255 + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
180.256 + .addContainerGap()
180.257 + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
180.258 + .addComponent(mainSplit2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 906, Short.MAX_VALUE)
180.259 + .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 906, Short.MAX_VALUE)
180.260 + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
180.261 + .addContainerGap())
180.262 + );
180.263 + layout.setVerticalGroup(
180.264 + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
180.265 + .addGroup(layout.createSequentialGroup()
180.266 + .addContainerGap()
180.267 + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
180.268 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
180.269 + .addComponent(mainSplit2, javax.swing.GroupLayout.DEFAULT_SIZE, 467, Short.MAX_VALUE)
180.270 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
180.271 + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
180.272 + .addContainerGap())
180.273 + );
180.274 + }// </editor-fold>//GEN-END:initComponents
180.275 +
180.276 + private void findMoreMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_findMoreMouseClicked
180.277 + findMore();
180.278 + }//GEN-LAST:event_findMoreMouseClicked
180.279 +
180.280 + private void findMore() {
180.281 + targetCount = duplicatesList.getModel().getSize() + 100;
180.282 + findMore.setVisible(false);
180.283 + WORKER.schedule(0);
180.284 + }
180.285 +
180.286 + private static String computeCommonPrefix(String origCommonPrefix, FileObject file) {
180.287 + String name = FileUtil.getFileDisplayName(file);
180.288 +
180.289 + if (origCommonPrefix == null) return name;
180.290 +
180.291 + int len = Math.min(origCommonPrefix.length(), name.length());
180.292 +
180.293 + for (int cntr = 0; cntr < len; cntr++) {
180.294 + if (origCommonPrefix.charAt(cntr) != name.charAt(cntr)) {
180.295 + return origCommonPrefix.substring(0, cntr);
180.296 + }
180.297 + }
180.298 +
180.299 + return origCommonPrefix;
180.300 + }
180.301 +
180.302 + private static void setSpan(JEditorPane pane, Span s) {
180.303 + try {
180.304 + pane.setText(s.file.asText());
180.305 +
180.306 + Rectangle top = pane.modelToView(0);
180.307 + Rectangle start = pane.modelToView(s.startOff);
180.308 + Rectangle end = pane.modelToView(s.endOff);
180.309 +
180.310 + if (top != null && start != null && end != null) {
180.311 + Rectangle toScroll = start.union(end);
180.312 +
180.313 + pane.scrollRectToVisible(top);
180.314 + pane.scrollRectToVisible(toScroll);
180.315 + }
180.316 +
180.317 + OffsetsBag bag = (OffsetsBag) pane.getClientProperty(DuplicatesListPanel.class);
180.318 +
180.319 + bag.clear();
180.320 + bag.addHighlight(s.startOff, s.endOff, HIGHLIGHT);
180.321 + } catch (IOException ex) {
180.322 + Exceptions.printStackTrace(ex);
180.323 + } catch (BadLocationException ex) {
180.324 + Exceptions.printStackTrace(ex);
180.325 + }
180.326 + }
180.327 +
180.328 + private static final AttributeSet HIGHLIGHT = AttributesUtilities.createImmutable(StyleConstants.Background, new Color(0xDF, 0xDF, 0xDF, 0xff));
180.329 +
180.330 + private final class DuplicatesRendererImpl extends DefaultListCellRenderer {
180.331 + @Override
180.332 + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
180.333 + if (!(value instanceof DuplicateDescription)) return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
180.334 + DuplicateDescription dd = (DuplicateDescription) value;
180.335 + Set<FileObject> files = new LinkedHashSet<FileObject>();
180.336 + String commonPrefix = null;
180.337 +
180.338 + for (Span s : dd.dupes) {
180.339 + commonPrefix = computeCommonPrefix(commonPrefix, s.file);
180.340 + files.add(s.file);
180.341 + }
180.342 +
180.343 + StringBuilder cap = new StringBuilder();
180.344 +
180.345 + OUTER: for (FileObject file : files) {
180.346 + String name = FileUtil.getFileDisplayName(file);
180.347 +
180.348 + if (cap.length() > 0) {
180.349 + cap.append(" ");
180.350 + }
180.351 +
180.352 + for (String sr : sourceRoots) {
180.353 + if (name.startsWith(sr)) {
180.354 + cap.append(name.substring(Math.max(0, sr.lastIndexOf('/') + 1)));
180.355 + continue OUTER;
180.356 + }
180.357 + }
180.358 + }
180.359 +
180.360 + return super.getListCellRendererComponent(list, cap.toString(), index, isSelected, cellHasFocus);
180.361 + }
180.362 + }
180.363 +
180.364 + private final class SpanRendererImpl extends DefaultListCellRenderer {
180.365 + @Override
180.366 + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
180.367 + if (!(value instanceof Span)) {
180.368 + return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
180.369 + }
180.370 + Span span = (Span) value;
180.371 +
180.372 + return super.getListCellRendererComponent(list, FileUtil.getFileDisplayName(span.file), index, isSelected, cellHasFocus);
180.373 + }
180.374 + }
180.375 +
180.376 + public static final class HighlightLayerFactoryImpl implements HighlightsLayerFactory {
180.377 + public HighlightsLayer[] createLayers(Context cntxt) {
180.378 + OffsetsBag bag = (OffsetsBag) cntxt.getComponent().getClientProperty(DuplicatesListPanel.class);
180.379 +
180.380 + if (bag != null) {
180.381 + return new HighlightsLayer[] {
180.382 + HighlightsLayer.create(DuplicatesListPanel.class.getName(), ZOrder.CARET_RACK, true, bag)
180.383 + };
180.384 + }
180.385 +
180.386 + return new HighlightsLayer[0];
180.387 + }
180.388 + }
180.389 +
180.390 + @ServiceProvider(service=MimeDataProvider.class)
180.391 + public static final class MDPI implements MimeDataProvider {
180.392 +
180.393 + private static final Lookup L = Lookups.singleton(new HighlightLayerFactoryImpl());
180.394 +
180.395 + public Lookup getLookup(MimePath mp) {
180.396 + if (mp.getPath().startsWith("text/x-java")) {
180.397 + return L;
180.398 + }
180.399 +
180.400 + return null;
180.401 + }
180.402 +
180.403 + }
180.404 +
180.405 + private static final class BalancedSplitPane extends JSplitPane {
180.406 +
180.407 + @Override
180.408 + @SuppressWarnings("deprecation")
180.409 + public void reshape(int x, int y, int w, int h) {
180.410 + super.reshape(x, y, w, h);
180.411 + SwingUtilities.invokeLater(new Runnable() {
180.412 + public void run() {
180.413 + setDividerLocation(0.5);
180.414 + }
180.415 + });
180.416 + }
180.417 +
180.418 + }
180.419 +
180.420 + // Variables declaration - do not modify//GEN-BEGIN:variables
180.421 + private javax.swing.JList duplicatesList;
180.422 + private javax.swing.JLabel findMore;
180.423 + private javax.swing.JPanel jPanel1;
180.424 + private javax.swing.JScrollPane jScrollPane1;
180.425 + private javax.swing.JScrollPane jScrollPane2;
180.426 + private javax.swing.JScrollPane jScrollPane3;
180.427 + private javax.swing.JEditorPane left;
180.428 + private javax.swing.JComboBox leftFileList;
180.429 + private javax.swing.JPanel leftPanel;
180.430 + private javax.swing.JSplitPane mainSplit2;
180.431 + private javax.swing.JLabel progressLabel;
180.432 + private javax.swing.JEditorPane right;
180.433 + private javax.swing.JComboBox rightFileList;
180.434 + private javax.swing.JPanel rightPanel;
180.435 + // End of variables declaration//GEN-END:variables
180.436 +
180.437 + private static final RequestProcessor DEFAULT_WORKER = new RequestProcessor(DuplicatesListPanel.class.getName(), 1, false, false);
180.438 + private final Task WORKER = DEFAULT_WORKER.create(new Runnable() {
180.439 + public void run() {
180.440 + if (dupes.hasNext()) {
180.441 + final DuplicateDescription dd = dupes.next();
180.442 +
180.443 + SwingUtilities.invokeLater(new Runnable() {
180.444 +
180.445 + public void run() {
180.446 + ((DefaultListModel)duplicatesList.getModel()).addElement(dd);
180.447 +
180.448 + int size = duplicatesList.getModel().getSize();
180.449 +
180.450 + if (size == 1) {
180.451 + duplicatesList.setSelectedIndex(0);
180.452 + }
180.453 +
180.454 + if (size >= targetCount) {
180.455 + findMore.setVisible(true);
180.456 + progressLabel.setText("Found " + size + " duplicated snippets.");
180.457 + } else {
180.458 + progressLabel.setText("Found " + size + " duplicated snippets and searching...");
180.459 + WORKER.schedule(0);
180.460 + }
180.461 + }
180.462 + });
180.463 + }
180.464 + }
180.465 + });
180.466 +
180.467 +}
181.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
181.2 +++ b/duplicates/ide/impl/src/org/netbeans/modules/jackpot30/impl/duplicates/GlobalFindDuplicates.java Mon Mar 12 21:10:10 2012 +0100
181.3 @@ -0,0 +1,179 @@
181.4 +/*
181.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
181.6 + *
181.7 + * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
181.8 + *
181.9 + * The contents of this file are subject to the terms of either the GNU
181.10 + * General Public License Version 2 only ("GPL") or the Common
181.11 + * Development and Distribution License("CDDL") (collectively, the
181.12 + * "License"). You may not use this file except in compliance with the
181.13 + * License. You can obtain a copy of the License at
181.14 + * http://www.netbeans.org/cddl-gplv2.html
181.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
181.16 + * specific language governing permissions and limitations under the
181.17 + * License. When distributing the software, include this License Header
181.18 + * Notice in each file and include the License file at
181.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
181.20 + * particular file as subject to the "Classpath" exception as provided
181.21 + * by Sun in the GPL Version 2 section of the License file that
181.22 + * accompanied this code. If applicable, add the following below the
181.23 + * License Header, with the fields enclosed by brackets [] replaced by
181.24 + * your own identifying information:
181.25 + * "Portions Copyrighted [year] [name of copyright owner]"
181.26 + *
181.27 + * If you wish your version of this file to be governed by only the CDDL
181.28 + * or only the GPL Version 2, indicate your decision by adding
181.29 + * "[Contributor] elects to include this software in this distribution
181.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
181.31 + * single choice of license, a recipient has the option to distribute
181.32 + * your version of this file under either the CDDL, the GPL Version 2 or
181.33 + * to extend the choice of license to its licensees as provided above.
181.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
181.35 + * Version 2 license, then the option applies only if the new code is
181.36 + * made subject to such option by the copyright holder.
181.37 + *
181.38 + * Contributor(s):
181.39 + *
181.40 + * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
181.41 + */
181.42 +package org.netbeans.modules.jackpot30.impl.duplicates;
181.43 +
181.44 +import java.awt.Dialog;
181.45 +import java.awt.GridBagConstraints;
181.46 +import java.awt.GridBagLayout;
181.47 +import java.awt.Insets;
181.48 +import java.awt.event.ActionEvent;
181.49 +import java.awt.event.ActionListener;
181.50 +import java.io.IOException;
181.51 +import java.util.Collection;
181.52 +import java.util.Iterator;
181.53 +import java.util.LinkedList;
181.54 +import java.util.concurrent.atomic.AtomicBoolean;
181.55 +import javax.swing.JLabel;
181.56 +import javax.swing.JPanel;
181.57 +import javax.swing.SwingUtilities;
181.58 +import org.netbeans.api.java.classpath.ClassPath;
181.59 +import org.netbeans.api.java.classpath.GlobalPathRegistry;
181.60 +import org.netbeans.api.progress.ProgressHandle;
181.61 +import org.netbeans.api.progress.ProgressHandleFactory;
181.62 +import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.DuplicateDescription;
181.63 +import org.openide.DialogDescriptor;
181.64 +import org.openide.DialogDisplayer;
181.65 +import org.openide.NotifyDescriptor;
181.66 +import org.openide.filesystems.FileObject;
181.67 +import org.openide.filesystems.FileUtil;
181.68 +import org.openide.util.Exceptions;
181.69 +import org.openide.util.HelpCtx;
181.70 +import org.openide.util.RequestProcessor;
181.71 +
181.72 +public final class GlobalFindDuplicates implements ActionListener {
181.73 +
181.74 + public void actionPerformed(ActionEvent e) {
181.75 + final Iterator<? extends DuplicateDescription>[] dupes = new Iterator[1];
181.76 + final ProgressHandle handle = ProgressHandleFactory.createHandle("Compute Duplicates");
181.77 + JPanel panel = createPanel(handle);
181.78 + final AtomicBoolean cancel = new AtomicBoolean();
181.79 + DialogDescriptor w = new DialogDescriptor(panel, "Computing Duplicates", true, new Object[] {DialogDescriptor.CANCEL_OPTION}, DialogDescriptor.CANCEL_OPTION, DialogDescriptor.DEFAULT_ALIGN, HelpCtx.DEFAULT_HELP, new ActionListener() {
181.80 + public void actionPerformed(ActionEvent e) {
181.81 + cancel.set(true);
181.82 + }
181.83 + });
181.84 +
181.85 + w.setClosingOptions(null);
181.86 +
181.87 + final Dialog d = DialogDisplayer.getDefault().createDialog(w);
181.88 + final AtomicBoolean done = new AtomicBoolean();
181.89 + final Collection<String> sourceRoots = new LinkedList<String>();
181.90 +
181.91 + WORKER.post(new Runnable() {
181.92 + public void run() {
181.93 + try {
181.94 + for (ClassPath cp : GlobalPathRegistry.getDefault().getPaths(ClassPath.SOURCE)) {
181.95 + for (ClassPath.Entry e : cp.entries()) {
181.96 + FileObject root = e.getRoot();
181.97 +
181.98 + if (root == null) continue;
181.99 +
181.100 + sourceRoots.add(FileUtil.getFileDisplayName(root));
181.101 + }
181.102 + }
181.103 +
181.104 + dupes[0] = new ComputeDuplicates().computeDuplicatesForAllOpenedProjects(handle, cancel);
181.105 + done.set(true);
181.106 + } catch (IOException ex) {
181.107 + Exceptions.printStackTrace(ex);
181.108 + } finally {
181.109 + handle.finish();
181.110 +
181.111 + SwingUtilities.invokeLater(new Runnable() {
181.112 + public void run() {
181.113 + d.setVisible(false);
181.114 + }
181.115 + });
181.116 + }
181.117 + }
181.118 + });
181.119 +
181.120 + handle.start();
181.121 + handle.progress(" ");
181.122 +
181.123 + d.setVisible(true);
181.124 +
181.125 + if (!done.get()) {
181.126 + cancel.set(true);
181.127 + return;
181.128 + }
181.129 +
181.130 + if (cancel.get()) return;
181.131 +
181.132 + NotifyDescriptor nd = new NotifyDescriptor.Message(new DuplicatesListPanel(sourceRoots, dupes[0]));
181.133 +
181.134 + DialogDisplayer.getDefault().notifyLater(nd);
181.135 + }
181.136 +
181.137 + private JPanel createPanel(ProgressHandle handle) {
181.138 + JPanel panel = new JPanel(new GridBagLayout());
181.139 + GridBagConstraints gridBagConstraints;
181.140 +
181.141 + gridBagConstraints = new GridBagConstraints();
181.142 + gridBagConstraints.gridx = 0;
181.143 + gridBagConstraints.gridy = 0;
181.144 + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
181.145 + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
181.146 + gridBagConstraints.weightx = 1.0;
181.147 + gridBagConstraints.insets = new Insets(6, 6, 0, 6);
181.148 + panel.add(new JLabel("Computing Duplicates - Please Wait"), gridBagConstraints);
181.149 +
181.150 + gridBagConstraints = new GridBagConstraints();
181.151 + gridBagConstraints.gridx = 0;
181.152 + gridBagConstraints.gridy = 1;
181.153 + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
181.154 + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
181.155 + gridBagConstraints.weightx = 1.0;
181.156 + gridBagConstraints.insets = new Insets(6, 6, 0, 6);
181.157 + panel.add(ProgressHandleFactory.createProgressComponent(handle), gridBagConstraints);
181.158 +
181.159 + gridBagConstraints = new GridBagConstraints();
181.160 + gridBagConstraints.gridx = 0;
181.161 + gridBagConstraints.gridy = 2;
181.162 + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
181.163 + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
181.164 + gridBagConstraints.weightx = 1.0;
181.165 + gridBagConstraints.insets = new Insets(6, 6, 6, 6);
181.166 + panel.add(ProgressHandleFactory.createDetailLabelComponent(handle), gridBagConstraints);
181.167 +
181.168 + gridBagConstraints = new GridBagConstraints();
181.169 + gridBagConstraints.gridx = 0;
181.170 + gridBagConstraints.gridy = 3;
181.171 + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
181.172 + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
181.173 + gridBagConstraints.weightx = 1.0;
181.174 + gridBagConstraints.weighty = 1.0;
181.175 + panel.add(new JPanel(), gridBagConstraints);
181.176 +
181.177 + return panel;
181.178 + }
181.179 +
181.180 + private static final RequestProcessor WORKER = new RequestProcessor(GlobalFindDuplicates.class.getName(), 1);
181.181 +
181.182 +}
182.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
182.2 +++ b/duplicates/ide/impl/src/org/netbeans/modules/jackpot30/impl/duplicates/hints/FindDuplicates.java Mon Mar 12 21:10:10 2012 +0100
182.3 @@ -0,0 +1,133 @@
182.4 +/*
182.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
182.6 + *
182.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
182.8 + *
182.9 + * The contents of this file are subject to the terms of either the GNU
182.10 + * General Public License Version 2 only ("GPL") or the Common
182.11 + * Development and Distribution License("CDDL") (collectively, the
182.12 + * "License"). You may not use this file except in compliance with the
182.13 + * License. You can obtain a copy of the License at
182.14 + * http://www.netbeans.org/cddl-gplv2.html
182.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
182.16 + * specific language governing permissions and limitations under the
182.17 + * License. When distributing the software, include this License Header
182.18 + * Notice in each file and include the License file at
182.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
182.20 + * particular file as subject to the "Classpath" exception as provided
182.21 + * by Sun in the GPL Version 2 section of the License file that
182.22 + * accompanied this code. If applicable, add the following below the
182.23 + * License Header, with the fields enclosed by brackets [] replaced by
182.24 + * your own identifying information:
182.25 + * "Portions Copyrighted [year] [name of copyright owner]"
182.26 + *
182.27 + * If you wish your version of this file to be governed by only the CDDL
182.28 + * or only the GPL Version 2, indicate your decision by adding
182.29 + * "[Contributor] elects to include this software in this distribution
182.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
182.31 + * single choice of license, a recipient has the option to distribute
182.32 + * your version of this file under either the CDDL, the GPL Version 2 or
182.33 + * to extend the choice of license to its licensees as provided above.
182.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
182.35 + * Version 2 license, then the option applies only if the new code is
182.36 + * made subject to such option by the copyright holder.
182.37 + *
182.38 + * Contributor(s):
182.39 + *
182.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
182.41 + */
182.42 +
182.43 +package org.netbeans.modules.jackpot30.impl.duplicates.hints;
182.44 +
182.45 +import java.util.Collection;
182.46 +import java.util.Collections;
182.47 +import java.util.Iterator;
182.48 +import java.util.LinkedList;
182.49 +import java.util.List;
182.50 +import java.util.Map;
182.51 +import java.util.concurrent.atomic.AtomicBoolean;
182.52 +import java.util.logging.Level;
182.53 +import java.util.logging.Logger;
182.54 +import org.netbeans.api.java.source.CancellableTask;
182.55 +import org.netbeans.api.java.source.CompilationInfo;
182.56 +import org.netbeans.api.java.source.JavaSource.Phase;
182.57 +import org.netbeans.api.java.source.JavaSource.Priority;
182.58 +import org.netbeans.api.java.source.JavaSourceTaskFactory;
182.59 +import org.netbeans.api.java.source.support.EditorAwareJavaSourceTaskFactory;
182.60 +import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates;
182.61 +import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.DuplicateDescription;
182.62 +import org.netbeans.modules.jackpot30.impl.duplicates.indexing.RemoteDuplicatesIndex;
182.63 +import org.netbeans.spi.editor.hints.ErrorDescription;
182.64 +import org.netbeans.spi.editor.hints.ErrorDescriptionFactory;
182.65 +import org.netbeans.spi.editor.hints.HintsController;
182.66 +import org.netbeans.spi.editor.hints.Severity;
182.67 +import org.openide.filesystems.FileObject;
182.68 +import org.openide.util.NbCollections;
182.69 +import org.openide.util.lookup.ServiceProvider;
182.70 +
182.71 +/**
182.72 + *
182.73 + * @author lahvac
182.74 + */
182.75 +public class FindDuplicates implements CancellableTask<CompilationInfo> {
182.76 +
182.77 + private final AtomicBoolean cancel = new AtomicBoolean();
182.78 +
182.79 + public void run(CompilationInfo info) throws Exception {
182.80 + cancel.set(false);
182.81 +
182.82 + long start = System.currentTimeMillis();
182.83 + try {
182.84 + Collection<? extends ErrorDescription> eds = computeErrorDescription(info);
182.85 +
182.86 + if (cancel.get()) return;
182.87 +
182.88 + if (eds == null) {
182.89 + eds = Collections.emptyList();
182.90 + }
182.91 +
182.92 + HintsController.setErrors(info.getFileObject(), FindDuplicates.class.getName(), eds);
182.93 + } finally {
182.94 + long end = System.currentTimeMillis();
182.95 +
182.96 + Logger.getLogger("TIMER").log(Level.FINE, "Duplicates in editor", new Object[] {info.getFileObject(), end - start});
182.97 + }
182.98 + }
182.99 +
182.100 + private Collection<? extends ErrorDescription> computeErrorDescription(CompilationInfo info) throws Exception {
182.101 + List<ErrorDescription> result = new LinkedList<ErrorDescription>();
182.102 +
182.103 + Map<String, long[]> encoded = ComputeDuplicates.encodeGeneralized(info);
182.104 + Iterator<? extends DuplicateDescription> duplicates = RemoteDuplicatesIndex.findDuplicates(encoded, info.getFileObject()).iterator();
182.105 +
182.106 + for (DuplicateDescription dd : NbCollections.iterable(duplicates)) {
182.107 + long[] spans = encoded.get(dd.hash);
182.108 +
182.109 + for (int c = 0; c < spans.length; c += 2) {
182.110 + if (cancel.get()) return null;
182.111 + result.add(ErrorDescriptionFactory.createErrorDescription(Severity.WARNING, "Duplicate of code from " + dd.dupes.get(0).file, info.getFileObject(), (int) spans[c], (int) spans[c + 1]));
182.112 + }
182.113 + }
182.114 +
182.115 + return result;
182.116 + }
182.117 +
182.118 + public void cancel() {
182.119 + cancel.set(true);
182.120 + }
182.121 +
182.122 + @ServiceProvider(service=JavaSourceTaskFactory.class)
182.123 + public static final class FactoryImpl extends EditorAwareJavaSourceTaskFactory {
182.124 +
182.125 + public FactoryImpl() {
182.126 + super(Phase.RESOLVED, Priority.LOW);
182.127 + }
182.128 +
182.129 + @Override
182.130 + protected CancellableTask<CompilationInfo> createTask(FileObject file) {
182.131 + return new FindDuplicates();
182.132 + }
182.133 +
182.134 + }
182.135 +
182.136 +}
183.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
183.2 +++ b/duplicates/ide/impl/src/org/netbeans/modules/jackpot30/impl/duplicates/indexing/DeferredCustomIndexer.java Mon Mar 12 21:10:10 2012 +0100
183.3 @@ -0,0 +1,500 @@
183.4 +/*
183.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
183.6 + *
183.7 + * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
183.8 + *
183.9 + * The contents of this file are subject to the terms of either the GNU
183.10 + * General Public License Version 2 only ("GPL") or the Common
183.11 + * Development and Distribution License("CDDL") (collectively, the
183.12 + * "License"). You may not use this file except in compliance with the
183.13 + * License. You can obtain a copy of the License at
183.14 + * http://www.netbeans.org/cddl-gplv2.html
183.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
183.16 + * specific language governing permissions and limitations under the
183.17 + * License. When distributing the software, include this License Header
183.18 + * Notice in each file and include the License file at
183.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
183.20 + * particular file as subject to the "Classpath" exception as provided
183.21 + * by Sun in the GPL Version 2 section of the License file that
183.22 + * accompanied this code. If applicable, add the following below the
183.23 + * License Header, with the fields enclosed by brackets [] replaced by
183.24 + * your own identifying information:
183.25 + * "Portions Copyrighted [year] [name of copyright owner]"
183.26 + *
183.27 + * If you wish your version of this file to be governed by only the CDDL
183.28 + * or only the GPL Version 2, indicate your decision by adding
183.29 + * "[Contributor] elects to include this software in this distribution
183.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
183.31 + * single choice of license, a recipient has the option to distribute
183.32 + * your version of this file under either the CDDL, the GPL Version 2 or
183.33 + * to extend the choice of license to its licensees as provided above.
183.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
183.35 + * Version 2 license, then the option applies only if the new code is
183.36 + * made subject to such option by the copyright holder.
183.37 + *
183.38 + * Contributor(s):
183.39 + *
183.40 + * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
183.41 + */
183.42 +
183.43 +package org.netbeans.modules.jackpot30.impl.duplicates.indexing;
183.44 +
183.45 +import java.io.BufferedWriter;
183.46 +import java.io.File;
183.47 +import java.io.IOException;
183.48 +import java.io.OutputStreamWriter;
183.49 +import java.io.Writer;
183.50 +import java.net.URL;
183.51 +import java.util.Collection;
183.52 +import java.util.Collections;
183.53 +import java.util.HashMap;
183.54 +import java.util.HashSet;
183.55 +import java.util.Iterator;
183.56 +import java.util.Map;
183.57 +import java.util.Map.Entry;
183.58 +import java.util.Set;
183.59 +import java.util.concurrent.atomic.AtomicBoolean;
183.60 +import java.util.logging.Level;
183.61 +import java.util.logging.Logger;
183.62 +import javax.swing.JButton;
183.63 +import javax.swing.SwingUtilities;
183.64 +import org.netbeans.api.annotations.common.NonNull;
183.65 +import org.netbeans.api.java.classpath.ClassPath;
183.66 +import org.netbeans.api.java.source.CancellableTask;
183.67 +import org.netbeans.api.java.source.ClasspathInfo;
183.68 +import org.netbeans.api.java.source.CompilationController;
183.69 +import org.netbeans.api.java.source.CompilationInfo;
183.70 +import org.netbeans.api.java.source.JavaSource;
183.71 +import org.netbeans.api.java.source.JavaSource.Phase;
183.72 +import org.netbeans.api.java.source.JavaSource.Priority;
183.73 +import org.netbeans.api.java.source.JavaSourceTaskFactory;
183.74 +import org.netbeans.api.java.source.Task;
183.75 +import org.netbeans.api.progress.ProgressHandle;
183.76 +import org.netbeans.api.progress.ProgressHandleFactory;
183.77 +import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
183.78 +import org.netbeans.modules.parsing.impl.indexing.SPIAccessor;
183.79 +import org.netbeans.modules.parsing.spi.indexing.Context;
183.80 +import org.netbeans.modules.parsing.spi.indexing.CustomIndexer;
183.81 +import org.netbeans.modules.parsing.spi.indexing.CustomIndexerFactory;
183.82 +import org.netbeans.modules.parsing.spi.indexing.Indexable;
183.83 +import org.openide.DialogDescriptor;
183.84 +import org.openide.DialogDisplayer;
183.85 +import org.openide.filesystems.FileAlreadyLockedException;
183.86 +import org.openide.filesystems.FileObject;
183.87 +import org.openide.filesystems.FileUtil;
183.88 +import org.openide.filesystems.URLMapper;
183.89 +import org.openide.util.Cancellable;
183.90 +import org.openide.util.Exceptions;
183.91 +import org.openide.util.Lookup;
183.92 +import org.openide.util.lookup.ServiceProvider;
183.93 +
183.94 +/**
183.95 + *
183.96 + * @author lahvac
183.97 + */
183.98 +public abstract class DeferredCustomIndexer extends CustomIndexer {
183.99 +
183.100 + private static final Logger LOG = Logger.getLogger(DeferredCustomIndexer.class.getName());
183.101 +
183.102 + private final DeferredCustomIndexerFactory factory;
183.103 +
183.104 + protected DeferredCustomIndexer(DeferredCustomIndexerFactory factory) {
183.105 + this.factory = factory;
183.106 + }
183.107 +
183.108 + protected abstract void doIndex(DeferredContext ctx, Collection<? extends FileObject> modifiedAndAdded, Collection<? extends String> removed) throws IOException;
183.109 +
183.110 + @Override
183.111 + protected final void index(Iterable<? extends Indexable> files, Context context) {
183.112 + update(factory, context.getRootURI(), files, Collections.<Indexable>emptyList());
183.113 + }
183.114 +
183.115 + private static void dump(File where, Iterable<? extends String> lines) {
183.116 + Writer out = null;
183.117 +
183.118 + try {
183.119 + out = new BufferedWriter(new OutputStreamWriter(FileUtil.createData(where).getOutputStream(), "UTF-8"));
183.120 +
183.121 + for (String line : lines) {
183.122 + out.write(line);
183.123 + out.write("\n");
183.124 + }
183.125 + } catch (FileAlreadyLockedException ex) {
183.126 + Exceptions.printStackTrace(ex);
183.127 + } catch (IOException ex) {
183.128 + Exceptions.printStackTrace(ex);
183.129 + } finally {
183.130 + if (out != null) {
183.131 + try {
183.132 + out.close();
183.133 + } catch (IOException ex) {
183.134 + Exceptions.printStackTrace(ex);
183.135 + }
183.136 + }
183.137 + }
183.138 + }
183.139 +
183.140 + private static Set<String> gatherRelativePaths(Iterable<? extends Indexable> it) {
183.141 + Set<String> result = new HashSet<String>();
183.142 +
183.143 + for (Indexable i : it) {
183.144 + result.add(i.getRelativePath());
183.145 + }
183.146 +
183.147 + return result;
183.148 + }
183.149 +
183.150 + private static void update(DeferredCustomIndexerFactory factory, URL root, Iterable<? extends Indexable> modified, Iterable<? extends Indexable> deleted) {
183.151 + try {
183.152 + Set<String> mod = gatherRelativePaths(modified);
183.153 + Set<String> del = gatherRelativePaths(deleted);
183.154 +
183.155 + File cacheRoot = cacheRoot(root, factory);
183.156 +
183.157 + File modifiedFile = new File(cacheRoot, "modified");
183.158 + FileObject modifiedFileFO = FileUtil.toFileObject(modifiedFile);
183.159 + Set<String> modifiedFiles = modifiedFileFO != null ? new HashSet<String>(modifiedFileFO.asLines("UTF-8")) : new HashSet<String>();
183.160 + boolean modifiedFilesChanged = modifiedFiles.removeAll(del);
183.161 +
183.162 + modifiedFilesChanged |= modifiedFiles.addAll(mod);
183.163 +
183.164 + if (modifiedFilesChanged) {
183.165 + dump(modifiedFile, modifiedFiles);
183.166 + }
183.167 +
183.168 + File deletedFile = new File(cacheRoot, "deleted");
183.169 + FileObject deletedFileFO = FileUtil.toFileObject(deletedFile);
183.170 + Set<String> deletedFiles = deletedFileFO != null ? new HashSet<String>(deletedFileFO.asLines("UTF-8")) : new HashSet<String>();
183.171 +
183.172 + boolean deletedFilesChanged = deletedFiles.removeAll(mod);
183.173 +
183.174 + deletedFilesChanged |= deletedFiles.addAll(del);
183.175 +
183.176 + if (deletedFilesChanged) {
183.177 + dump(deletedFile, deletedFiles);
183.178 + }
183.179 +
183.180 + if (!modifiedFiles.isEmpty() || !deletedFiles.isEmpty()) {
183.181 + add2TODO(root, factory);
183.182 + }
183.183 + } catch (IOException ex) {
183.184 + Exceptions.printStackTrace(ex);
183.185 + }
183.186 + }
183.187 +
183.188 + public static abstract class DeferredCustomIndexerFactory extends CustomIndexerFactory {
183.189 +
183.190 + public abstract DeferredCustomIndexer createIndexer();
183.191 +
183.192 + @Override
183.193 + public final void filesDeleted(Iterable<? extends Indexable> deleted, Context context) {
183.194 + update(this, context.getRootURI(), Collections.<Indexable>emptyList(), deleted);
183.195 + }
183.196 +
183.197 + @Override
183.198 + public final void filesDirty(Iterable<? extends Indexable> dirty, Context context) {}
183.199 +
183.200 + @Override
183.201 + public final boolean supportsEmbeddedIndexers() {
183.202 + return false;
183.203 + }
183.204 +
183.205 + @Override
183.206 + public final void rootsRemoved(Iterable<? extends URL> removedRoots) {
183.207 + super.rootsRemoved(removedRoots);
183.208 + }
183.209 +
183.210 + @Override
183.211 + public final void scanFinished(Context context) {
183.212 + super.scanFinished(context);
183.213 + }
183.214 +
183.215 + @Override
183.216 + public final boolean scanStarted(Context context) {
183.217 + return super.scanStarted(context);
183.218 + }
183.219 +
183.220 + public void updateIndex(final URL root, final AtomicBoolean cancel) throws IOException {
183.221 + final FileObject rootFO = URLMapper.findFileObject(root);
183.222 + final ClasspathInfo cpInfo = ClasspathInfo.create(ClassPath.EMPTY, ClassPath.EMPTY, ClassPath.EMPTY);
183.223 +
183.224 + JavaSource.create(cpInfo).runUserActionTask(new Task<CompilationController>() {
183.225 + public void run(CompilationController parameter) throws Exception {
183.226 + if (cancel.get()) return ;
183.227 + updateRoot(DeferredCustomIndexerFactory.this, root, rootFO, cancel);
183.228 + }
183.229 + }, true);
183.230 + }
183.231 +
183.232 + }
183.233 +
183.234 + public static final class DeferredContext {
183.235 + private final @NonNull URL root;
183.236 + private final @NonNull FileObject rootFileObject;
183.237 + private final @NonNull FileObject cacheRoot;
183.238 + private final @NonNull Set<? extends FileObject> modifiedAndAdded;
183.239 + private final @NonNull Set<? extends String> removed;
183.240 + private final @NonNull AtomicBoolean cancel;
183.241 +
183.242 + public DeferredContext(URL root, FileObject rootFileObject, FileObject cacheRoot, Set<? extends FileObject> modifiedAndAdded, Set<? extends String> removed, AtomicBoolean cancel) {
183.243 + this.root = root;
183.244 + this.rootFileObject = rootFileObject;
183.245 + this.cacheRoot = cacheRoot;
183.246 + this.modifiedAndAdded = modifiedAndAdded;
183.247 + this.removed = removed;
183.248 + this.cancel = cancel;
183.249 + }
183.250 +
183.251 + public @NonNull URL getRoot() {
183.252 + return root;
183.253 + }
183.254 +
183.255 + public @NonNull FileObject getRootFileObject() {
183.256 + return rootFileObject;
183.257 + }
183.258 +
183.259 + public FileObject getCacheRoot() {
183.260 + return cacheRoot;
183.261 + }
183.262 +
183.263 + public boolean isCancelled() {
183.264 + return cancel.get();
183.265 + }
183.266 +
183.267 + public void handledModifiedFile(FileObject file) {
183.268 + modifiedAndAdded.remove(file);
183.269 + }
183.270 +
183.271 + public void handledRemovedFile(String relative) {
183.272 + removed.remove(relative);
183.273 + }
183.274 + }
183.275 +
183.276 + /*return: true == done*/
183.277 + private static boolean updateRoot(DeferredCustomIndexerFactory factory, URL root, FileObject rootFO, AtomicBoolean cancel) throws IOException {
183.278 + LOG.log(Level.FINE, "updating: {0}, for indexer: {1}", new Object[] {root.toExternalForm(), factory.getIndexerName()});
183.279 + File cacheRoot = cacheRoot(root, factory);
183.280 + FileObject deletedFile = FileUtil.toFileObject(new File(cacheRoot, "deleted"));
183.281 + Set<String> deletedFiles = deletedFile != null ? new HashSet<String>(deletedFile.asLines("UTF-8")) : Collections.<String>emptySet();
183.282 +
183.283 + FileObject modifiedFile = FileUtil.toFileObject(new File(cacheRoot, "modified"));
183.284 + Set<String> modifiedFiles = modifiedFile != null ? new HashSet<String>(modifiedFile.asLines("UTF-8")) : Collections.<String>emptySet();
183.285 +
183.286 + Set<FileObject> toIndex = new HashSet<FileObject>();
183.287 +
183.288 + for (String r : modifiedFiles) {
183.289 + FileObject f = rootFO.getFileObject(r);
183.290 +
183.291 + if (f != null) {
183.292 + toIndex.add(f);
183.293 + }
183.294 + }
183.295 +
183.296 + if (!toIndex.isEmpty() || !modifiedFiles.isEmpty()) {
183.297 + factory.createIndexer().doIndex(new DeferredContext(root, rootFO, FileUtil.toFileObject(cacheRoot), toIndex, deletedFiles, cancel), new HashSet<FileObject>(toIndex), new HashSet<String>(deletedFiles));
183.298 + }
183.299 +
183.300 + boolean done = true;
183.301 +
183.302 + if (deletedFile != null) {
183.303 + if (deletedFiles.isEmpty()) {
183.304 + deletedFile.delete();
183.305 + } else {
183.306 + dump(new File(cacheRoot, "deleted"), deletedFiles);
183.307 + done = false;
183.308 + }
183.309 + }
183.310 + if (modifiedFile != null) {
183.311 + if (toIndex.isEmpty()) {
183.312 + modifiedFile.delete();
183.313 + } else {
183.314 + modifiedFiles.clear();
183.315 +
183.316 + for (FileObject f : toIndex) {
183.317 + modifiedFiles.add(FileUtil.getRelativePath(rootFO, f));
183.318 + }
183.319 +
183.320 + dump(new File(cacheRoot, "modified"), modifiedFiles);
183.321 + done = false;
183.322 + }
183.323 + }
183.324 +
183.325 + return done;
183.326 + }
183.327 +
183.328 + private static final Map<String, TODO> todo = new HashMap<String, TODO>(); //XXX: synchronization!!!
183.329 +
183.330 + private static void add2TODO(URL root, DeferredCustomIndexerFactory factory) {
183.331 + if (DISABLED_INDEXERS.contains(factory.getIndexerName())) return;
183.332 +
183.333 + boolean wasEmpty = todo.isEmpty();
183.334 + TODO roots = todo.get(factory.getIndexerName());
183.335 +
183.336 + if (roots == null) {
183.337 + todo.put(factory.getIndexerName(), roots = new TODO(factory));
183.338 + }
183.339 +
183.340 + roots.roots.add(root);
183.341 +
183.342 + LOG.log(Level.FINE, "add2TODO, root: {0}, for factory: {1}, wasEmpty: {2}, todo: {3}", new Object[] {root.toExternalForm(), factory.getIndexerName(), wasEmpty, todo.toString()});
183.343 +
183.344 + if (wasEmpty) RunAsNeededFactory.fileChanged();
183.345 + else RunAsNeededFactory.refresh();
183.346 + }
183.347 +
183.348 + private static File cacheRoot(URL root, CustomIndexerFactory factory) throws IOException {
183.349 + FileObject indexBaseFolder = CacheFolder.getDataFolder(root);
183.350 + String path = SPIAccessor.getInstance().getIndexerPath(factory.getIndexerName(), factory.getIndexVersion());
183.351 + FileObject indexFolder = FileUtil.createFolder(indexBaseFolder, path);
183.352 + return FileUtil.toFile(indexFolder);
183.353 + }
183.354 +
183.355 + private static final Set<String> DISABLED_INDEXERS = Collections.synchronizedSet(new HashSet<String>());
183.356 +
183.357 + private static class UpdateWorker implements CancellableTask<CompilationInfo> {
183.358 +
183.359 + private static ProgressHandle progressForCurrentFactory;
183.360 + private static DeferredCustomIndexerFactory currentFactory;
183.361 +
183.362 + private final AtomicBoolean cancel = new AtomicBoolean();
183.363 +
183.364 + public void run(CompilationInfo parameter) throws Exception {
183.365 + cancel.set(false);
183.366 +
183.367 + for (Iterator<Entry<String, TODO>> it = todo.entrySet().iterator(); it.hasNext();) {
183.368 + if (cancel.get()) return;
183.369 +
183.370 + final Entry<String, TODO> e = it.next();
183.371 +
183.372 + if (DISABLED_INDEXERS.contains(e.getKey())) {
183.373 + it.remove();
183.374 + continue;
183.375 + }
183.376 +
183.377 + if (currentFactory != e.getValue().factory) {
183.378 + if (progressForCurrentFactory != null) {
183.379 + progressForCurrentFactory.finish();
183.380 + }
183.381 +
183.382 + currentFactory = e.getValue().factory;
183.383 + progressForCurrentFactory = ProgressHandleFactory.createSystemHandle("Background indexing for: " + currentFactory.getIndexerName(), new Cancellable() {
183.384 + public boolean cancel() {
183.385 + assert SwingUtilities.isEventDispatchThread();
183.386 +
183.387 + JButton disableInThisSession = new JButton("Disable in This Session");
183.388 + JButton disablePermanently = new JButton("Disable Permanently");
183.389 +
183.390 + disablePermanently.setEnabled(false);
183.391 +
183.392 + Object[] buttons = new Object[]{disableInThisSession, disablePermanently, DialogDescriptor.CANCEL_OPTION};
183.393 + DialogDescriptor dd = new DialogDescriptor("Disable background indexing for: " + e.getValue().factory.getIndexerName(), "Disable Background Indexing", true, buttons, disableInThisSession, DialogDescriptor.DEFAULT_ALIGN, null, null);
183.394 +
183.395 + dd.setClosingOptions(buttons);
183.396 +
183.397 + Object result = DialogDisplayer.getDefault().notify(dd);
183.398 +
183.399 + if (result == disableInThisSession) {
183.400 + DISABLED_INDEXERS.add(e.getKey());
183.401 + return true;
183.402 + } else if (result == disablePermanently) {
183.403 + throw new UnsupportedOperationException();
183.404 + } else {
183.405 + return false;
183.406 + }
183.407 + }
183.408 + });
183.409 +
183.410 + progressForCurrentFactory.start();
183.411 + }
183.412 +
183.413 + for (Iterator<URL> factIt = e.getValue().roots.iterator(); factIt.hasNext();) {
183.414 + if (cancel.get()) return;
183.415 +
183.416 + URL root = factIt.next();
183.417 + FileObject rootFO = URLMapper.findFileObject(root);
183.418 +
183.419 + if (rootFO == null) {
183.420 + //already deleted
183.421 + it.remove();
183.422 + continue;
183.423 + }
183.424 +
183.425 + if (updateRoot(e.getValue().factory, root, rootFO, cancel)) {
183.426 + factIt.remove();
183.427 + } else {
183.428 + if (!cancel.get()) {
183.429 + LOG.log(Level.WARNING, "indexer: {0} did not update all files even if the process was not cancelled", currentFactory.getIndexerName());
183.430 + }
183.431 + }
183.432 + }
183.433 +
183.434 + if (e.getValue().roots.isEmpty())
183.435 + it.remove();
183.436 +
183.437 + progressForCurrentFactory.finish();
183.438 + progressForCurrentFactory = null;
183.439 + currentFactory = null;
183.440 + }
183.441 +
183.442 + if (todo.isEmpty()) RunAsNeededFactory.fileChanged();
183.443 + }
183.444 +
183.445 + public void cancel() {
183.446 + cancel.set(true);
183.447 + }
183.448 + }
183.449 +
183.450 + private static final class TODO {
183.451 + final DeferredCustomIndexerFactory factory;
183.452 + final Collection<URL> roots = new HashSet<URL>();
183.453 + TODO(DeferredCustomIndexerFactory factory) {
183.454 + this.factory = factory;
183.455 + }
183.456 + }
183.457 +
183.458 + private static final boolean DEFERRED_INDEXER_ENABLED = Boolean.getBoolean(DeferredCustomIndexerFactory.class.getName() + ".enable");
183.459 +
183.460 + private static final FileObject EMPTY_FILE;
183.461 +
183.462 + static {
183.463 + try {
183.464 + EMPTY_FILE = FileUtil.createMemoryFileSystem().getRoot().createData("empty.java");
183.465 + } catch (IOException ex) {
183.466 + throw new IllegalStateException(ex);
183.467 + }
183.468 + }
183.469 +
183.470 + @ServiceProvider(service=JavaSourceTaskFactory.class)
183.471 + public static final class RunAsNeededFactory extends JavaSourceTaskFactory {
183.472 +
183.473 + public RunAsNeededFactory() {
183.474 + super(Phase.PARSED, Priority.MIN);
183.475 + }
183.476 +
183.477 + @Override
183.478 + protected CancellableTask<CompilationInfo> createTask(FileObject file) {
183.479 + return new UpdateWorker();
183.480 + }
183.481 +
183.482 + @Override
183.483 + protected Collection<FileObject> getFileObjects() {
183.484 + return DEFERRED_INDEXER_ENABLED && !todo.isEmpty() ? Collections.singletonList(EMPTY_FILE) : Collections.<FileObject>emptyList();
183.485 + }
183.486 +
183.487 + public static void fileChanged() {
183.488 + for (JavaSourceTaskFactory f : Lookup.getDefault().lookupAll(JavaSourceTaskFactory.class)) {
183.489 + if (f instanceof RunAsNeededFactory) {
183.490 + ((RunAsNeededFactory) f).fileObjectsChanged();
183.491 + }
183.492 + }
183.493 + }
183.494 +
183.495 + public static void refresh() {
183.496 + for (JavaSourceTaskFactory f : Lookup.getDefault().lookupAll(JavaSourceTaskFactory.class)) {
183.497 + if (f instanceof RunAsNeededFactory) {
183.498 + ((RunAsNeededFactory) f).reschedule(EMPTY_FILE);
183.499 + }
183.500 + }
183.501 + }
183.502 + }
183.503 +}
184.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
184.2 +++ b/duplicates/ide/impl/src/org/netbeans/modules/jackpot30/impl/duplicates/indexing/DuplicatesCustomIndexerImpl.java Mon Mar 12 21:10:10 2012 +0100
184.3 @@ -0,0 +1,131 @@
184.4 +/*
184.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
184.6 + *
184.7 + * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
184.8 + *
184.9 + * The contents of this file are subject to the terms of either the GNU
184.10 + * General Public License Version 2 only ("GPL") or the Common
184.11 + * Development and Distribution License("CDDL") (collectively, the
184.12 + * "License"). You may not use this file except in compliance with the
184.13 + * License. You can obtain a copy of the License at
184.14 + * http://www.netbeans.org/cddl-gplv2.html
184.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
184.16 + * specific language governing permissions and limitations under the
184.17 + * License. When distributing the software, include this License Header
184.18 + * Notice in each file and include the License file at
184.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
184.20 + * particular file as subject to the "Classpath" exception as provided
184.21 + * by Sun in the GPL Version 2 section of the License file that
184.22 + * accompanied this code. If applicable, add the following below the
184.23 + * License Header, with the fields enclosed by brackets [] replaced by
184.24 + * your own identifying information:
184.25 + * "Portions Copyrighted [year] [name of copyright owner]"
184.26 + *
184.27 + * If you wish your version of this file to be governed by only the CDDL
184.28 + * or only the GPL Version 2, indicate your decision by adding
184.29 + * "[Contributor] elects to include this software in this distribution
184.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
184.31 + * single choice of license, a recipient has the option to distribute
184.32 + * your version of this file under either the CDDL, the GPL Version 2 or
184.33 + * to extend the choice of license to its licensees as provided above.
184.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
184.35 + * Version 2 license, then the option applies only if the new code is
184.36 + * made subject to such option by the copyright holder.
184.37 + *
184.38 + * Contributor(s):
184.39 + *
184.40 + * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
184.41 + */
184.42 +
184.43 +package org.netbeans.modules.jackpot30.impl.duplicates.indexing;
184.44 +
184.45 +import java.io.IOException;
184.46 +import java.net.URL;
184.47 +import java.util.Collection;
184.48 +import org.netbeans.api.java.source.ClasspathInfo;
184.49 +import org.netbeans.api.java.source.CompilationController;
184.50 +import org.netbeans.api.java.source.JavaSource;
184.51 +import org.netbeans.api.java.source.JavaSource.Phase;
184.52 +import org.netbeans.api.java.source.Task;
184.53 +import org.netbeans.modules.parsing.impl.indexing.IndexableImpl;
184.54 +import org.netbeans.modules.parsing.impl.indexing.SPIAccessor;
184.55 +import org.openide.filesystems.FileObject;
184.56 +import org.openide.util.Exceptions;
184.57 +
184.58 +/**
184.59 + *
184.60 + * @author lahvac
184.61 + */
184.62 +public class DuplicatesCustomIndexerImpl extends DeferredCustomIndexer {
184.63 +
184.64 + public DuplicatesCustomIndexerImpl(DeferredCustomIndexerFactory factory) {
184.65 + super(factory);
184.66 + }
184.67 +
184.68 + protected void doIndex(final DeferredContext ctx, Collection<? extends FileObject> modifiedAndAdded, Collection<? extends String> removed) throws IOException {
184.69 + final DuplicatesIndex[] w = new DuplicatesIndex[1];
184.70 +
184.71 + try {
184.72 + w[0] = new DuplicatesIndex(ctx.getRoot(), ctx.getCacheRoot());
184.73 +
184.74 + for (String r : removed) {
184.75 + w[0].remove(r);
184.76 + ctx.handledRemovedFile(r);
184.77 + }
184.78 +
184.79 + final ClasspathInfo cpInfo = ClasspathInfo.create(ctx.getRootFileObject());
184.80 +
184.81 + JavaSource.create(cpInfo, modifiedAndAdded).runUserActionTask(new Task<CompilationController>() {
184.82 + public void run(final CompilationController cc) throws Exception {
184.83 + if (cc.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0)
184.84 + return ;
184.85 +
184.86 + w[0].record(cc, SPIAccessor.getInstance().create(new IndexableImpl() {
184.87 + @Override public String getRelativePath() {
184.88 + throw new UnsupportedOperationException("Not supported yet.");
184.89 + }
184.90 + @Override public URL getURL() {
184.91 + return cc.getFileObject().toURL();
184.92 + }
184.93 + @Override public String getMimeType() {
184.94 + throw new UnsupportedOperationException("Not supported yet.");
184.95 + }
184.96 + @Override public boolean isTypeOf(String mimeType) {
184.97 + throw new UnsupportedOperationException("Not supported yet.");
184.98 + }
184.99 + }), cc.getCompilationUnit());
184.100 +
184.101 + ctx.handledModifiedFile(cc.getFileObject());
184.102 + }
184.103 + }, true);
184.104 + } finally {
184.105 + if (w[0] != null) {
184.106 + try {
184.107 + w[0].close();
184.108 + } catch (IOException ex) {
184.109 + Exceptions.printStackTrace(ex);
184.110 + }
184.111 + }
184.112 + }
184.113 + }
184.114 +
184.115 + public static final class FactoryImpl extends DeferredCustomIndexerFactory {
184.116 +
184.117 + @Override
184.118 + public DeferredCustomIndexer createIndexer() {
184.119 + return new DuplicatesCustomIndexerImpl(this);
184.120 + }
184.121 +
184.122 + @Override
184.123 + public String getIndexerName() {
184.124 + return DuplicatesIndex.NAME;
184.125 + }
184.126 +
184.127 + @Override
184.128 + public int getIndexVersion() {
184.129 + return DuplicatesIndex.VERSION;
184.130 + }
184.131 +
184.132 + }
184.133 +
184.134 +}
185.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
185.2 +++ b/duplicates/ide/impl/src/org/netbeans/modules/jackpot30/impl/duplicates/indexing/DuplicatesIndex.java Mon Mar 12 21:10:10 2012 +0100
185.3 @@ -0,0 +1,116 @@
185.4 +/*
185.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
185.6 + *
185.7 + * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
185.8 + *
185.9 + * The contents of this file are subject to the terms of either the GNU
185.10 + * General Public License Version 2 only ("GPL") or the Common
185.11 + * Development and Distribution License("CDDL") (collectively, the
185.12 + * "License"). You may not use this file except in compliance with the
185.13 + * License. You can obtain a copy of the License at
185.14 + * http://www.netbeans.org/cddl-gplv2.html
185.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
185.16 + * specific language governing permissions and limitations under the
185.17 + * License. When distributing the software, include this License Header
185.18 + * Notice in each file and include the License file at
185.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
185.20 + * particular file as subject to the "Classpath" exception as provided
185.21 + * by Sun in the GPL Version 2 section of the License file that
185.22 + * accompanied this code. If applicable, add the following below the
185.23 + * License Header, with the fields enclosed by brackets [] replaced by
185.24 + * your own identifying information:
185.25 + * "Portions Copyrighted [year] [name of copyright owner]"
185.26 + *
185.27 + * If you wish your version of this file to be governed by only the CDDL
185.28 + * or only the GPL Version 2, indicate your decision by adding
185.29 + * "[Contributor] elects to include this software in this distribution
185.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
185.31 + * single choice of license, a recipient has the option to distribute
185.32 + * your version of this file under either the CDDL, the GPL Version 2 or
185.33 + * to extend the choice of license to its licensees as provided above.
185.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
185.35 + * Version 2 license, then the option applies only if the new code is
185.36 + * made subject to such option by the copyright holder.
185.37 + *
185.38 + * Contributor(s):
185.39 + *
185.40 + * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
185.41 + */
185.42 +
185.43 +package org.netbeans.modules.jackpot30.impl.duplicates.indexing;
185.44 +
185.45 +import com.sun.source.tree.CompilationUnitTree;
185.46 +import java.io.IOException;
185.47 +import java.net.URL;
185.48 +import java.util.Map;
185.49 +import java.util.Map.Entry;
185.50 +import java.util.logging.Level;
185.51 +import java.util.logging.Logger;
185.52 +import org.apache.lucene.document.Document;
185.53 +import org.apache.lucene.document.Field;
185.54 +import org.apache.lucene.document.Field.Index;
185.55 +import org.apache.lucene.document.Field.Store;
185.56 +import org.apache.lucene.index.Term;
185.57 +import org.netbeans.api.java.source.CompilationInfo;
185.58 +import org.netbeans.modules.jackpot30.common.api.IndexAccess;
185.59 +import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates;
185.60 +import org.netbeans.modules.java.source.JavaSourceAccessor;
185.61 +import org.netbeans.modules.parsing.spi.indexing.Indexable;
185.62 +import org.openide.filesystems.FileObject;
185.63 +import org.openide.filesystems.FileUtil;
185.64 +import org.openide.util.Lookup;
185.65 +
185.66 +/**
185.67 + *
185.68 + * @author lahvac
185.69 + */
185.70 +public class DuplicatesIndex {
185.71 +
185.72 + private final org.apache.lucene.index.IndexWriter luceneWriter;
185.73 +
185.74 + DuplicatesIndex(URL sourceRoot, FileObject cacheRoot) throws IOException {
185.75 + luceneWriter = Lookup.getDefault().lookup(IndexAccess.class).getIndexWriter(sourceRoot, cacheRoot, NAME);
185.76 + }
185.77 +
185.78 + public void record(final CompilationInfo info, Indexable idx, final CompilationUnitTree cut) throws IOException {
185.79 + String relative = Lookup.getDefault().lookup(IndexAccess.class).getRelativePath(idx);
185.80 +
185.81 + try {
185.82 + final Document doc = new Document();
185.83 +
185.84 + doc.add(new Field("path", relative, Field.Store.YES, Field.Index.NOT_ANALYZED));
185.85 +
185.86 + final Map<String, long[]> positions = ComputeDuplicates.encodeGeneralized(JavaSourceAccessor.getINSTANCE().getJavacTask(info), cut);
185.87 +
185.88 + for (Entry<String, long[]> e : positions.entrySet()) {
185.89 + doc.add(new Field("generalized", e.getKey(), Store.YES, Index.NOT_ANALYZED));
185.90 +
185.91 + StringBuilder positionsSpec = new StringBuilder();
185.92 +
185.93 + for (int i = 0; i < e.getValue().length; i += 2) {
185.94 + if (positionsSpec.length() > 0) positionsSpec.append(';');
185.95 + positionsSpec.append(e.getValue()[i]).append(':').append(e.getValue()[i + 1] - e.getValue()[i]);
185.96 + }
185.97 +
185.98 + doc.add(new Field("positions", positionsSpec.toString(), Store.YES, Index.NO));
185.99 + }
185.100 +
185.101 + luceneWriter.addDocument(doc);
185.102 + } catch (ThreadDeath td) {
185.103 + throw td;
185.104 + } catch (Throwable t) {
185.105 + Logger.getLogger(DuplicatesIndex.class.getName()).log(Level.WARNING, null, t);
185.106 + }
185.107 + }
185.108 +
185.109 + public void remove(String relativePath) throws IOException {
185.110 + luceneWriter.deleteDocuments(new Term("path", relativePath));
185.111 + }
185.112 +
185.113 + public void close() throws IOException {
185.114 + Lookup.getDefault().lookup(IndexAccess.class).finish();
185.115 + }
185.116 +
185.117 + public static final String NAME = "duplicates"; //NOI18N
185.118 + public static final int VERSION = 1; //NOI18N
185.119 +}
186.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
186.2 +++ b/duplicates/ide/impl/src/org/netbeans/modules/jackpot30/impl/duplicates/indexing/RemoteDuplicatesIndex.java Mon Mar 12 21:10:10 2012 +0100
186.3 @@ -0,0 +1,413 @@
186.4 +/*
186.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
186.6 + *
186.7 + * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
186.8 + *
186.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
186.10 + * Other names may be trademarks of their respective owners.
186.11 + *
186.12 + * The contents of this file are subject to the terms of either the GNU
186.13 + * General Public License Version 2 only ("GPL") or the Common
186.14 + * Development and Distribution License("CDDL") (collectively, the
186.15 + * "License"). You may not use this file except in compliance with the
186.16 + * License. You can obtain a copy of the License at
186.17 + * http://www.netbeans.org/cddl-gplv2.html
186.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
186.19 + * specific language governing permissions and limitations under the
186.20 + * License. When distributing the software, include this License Header
186.21 + * Notice in each file and include the License file at
186.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
186.23 + * particular file as subject to the "Classpath" exception as provided
186.24 + * by Oracle in the GPL Version 2 section of the License file that
186.25 + * accompanied this code. If applicable, add the following below the
186.26 + * License Header, with the fields enclosed by brackets [] replaced by
186.27 + * your own identifying information:
186.28 + * "Portions Copyrighted [year] [name of copyright owner]"
186.29 + *
186.30 + * If you wish your version of this file to be governed by only the CDDL
186.31 + * or only the GPL Version 2, indicate your decision by adding
186.32 + * "[Contributor] elects to include this software in this distribution
186.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
186.34 + * single choice of license, a recipient has the option to distribute
186.35 + * your version of this file under either the CDDL, the GPL Version 2 or
186.36 + * to extend the choice of license to its licensees as provided above.
186.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
186.38 + * Version 2 license, then the option applies only if the new code is
186.39 + * made subject to such option by the copyright holder.
186.40 + *
186.41 + * Contributor(s):
186.42 + *
186.43 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
186.44 + */
186.45 +
186.46 +package org.netbeans.modules.jackpot30.impl.duplicates.indexing;
186.47 +
186.48 +import java.io.File;
186.49 +import java.io.IOException;
186.50 +import java.net.URI;
186.51 +import java.net.URISyntaxException;
186.52 +import java.util.ArrayList;
186.53 +import java.util.Arrays;
186.54 +import java.util.BitSet;
186.55 +import java.util.Collection;
186.56 +import java.util.Collections;
186.57 +import java.util.Comparator;
186.58 +import java.util.HashSet;
186.59 +import java.util.Iterator;
186.60 +import java.util.LinkedHashMap;
186.61 +import java.util.LinkedHashSet;
186.62 +import java.util.LinkedList;
186.63 +import java.util.List;
186.64 +import java.util.Map;
186.65 +import java.util.Map.Entry;
186.66 +import java.util.Set;
186.67 +import java.util.TreeMap;
186.68 +import java.util.logging.Level;
186.69 +import java.util.logging.Logger;
186.70 +import org.apache.lucene.document.Document;
186.71 +import org.apache.lucene.document.Field;
186.72 +import org.apache.lucene.document.Field.Index;
186.73 +import org.apache.lucene.document.Field.Store;
186.74 +import org.apache.lucene.index.IndexReader;
186.75 +import org.apache.lucene.index.IndexWriter;
186.76 +import org.apache.lucene.index.IndexWriter.MaxFieldLength;
186.77 +import org.apache.lucene.index.Term;
186.78 +import org.apache.lucene.search.Collector;
186.79 +import org.apache.lucene.search.IndexSearcher;
186.80 +import org.apache.lucene.search.Query;
186.81 +import org.apache.lucene.search.Searcher;
186.82 +import org.apache.lucene.search.TermQuery;
186.83 +import org.apache.lucene.store.FSDirectory;
186.84 +import org.codeviation.pojson.Pojson;
186.85 +import org.netbeans.modules.jackpot30.common.api.IndexAccess.NoAnalyzer;
186.86 +import org.netbeans.modules.jackpot30.common.api.LuceneHelpers.BitSetCollector;
186.87 +import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.DuplicateDescription;
186.88 +import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.Span;
186.89 +import org.netbeans.modules.jackpot30.remoting.api.RemoteIndex;
186.90 +import org.netbeans.modules.jackpot30.remoting.api.WebUtilities;
186.91 +import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
186.92 +import org.openide.filesystems.FileObject;
186.93 +import org.openide.filesystems.FileUtil;
186.94 +import org.openide.filesystems.URLMapper;
186.95 +import org.openide.util.Exceptions;
186.96 +
186.97 +/**
186.98 + *
186.99 + * @author lahvac
186.100 + */
186.101 +public class RemoteDuplicatesIndex {
186.102 +
186.103 + private static final Logger TIMER = Logger.getLogger("TIMER");
186.104 +
186.105 + public static List<DuplicateDescription> findDuplicates(Map<String, long[]> hashes, FileObject currentFile) throws IOException {
186.106 + return translate(hashes, findHashOccurrences(hashes.keySet(), currentFile), currentFile);
186.107 + }
186.108 +
186.109 + private static Map<String, Map<RemoteIndex, Collection<String>>> findHashOccurrences(Collection<? extends String> hashes, FileObject currentFile) throws IOException {
186.110 + Map<URI, Collection<RemoteIndex>> indices = new LinkedHashMap<URI, Collection<RemoteIndex>>();
186.111 +
186.112 + for (RemoteIndex ri : RemoteIndex.loadIndices()) {
186.113 + try {
186.114 + URI uri = ri.remote.toURI();
186.115 + Collection<RemoteIndex> list = indices.get(uri);
186.116 +
186.117 + if (list == null) {
186.118 + indices.put(uri, list = new ArrayList<RemoteIndex>());
186.119 + }
186.120 +
186.121 + list.add(ri);
186.122 + } catch (URISyntaxException ex) {
186.123 + Exceptions.printStackTrace(ex);
186.124 + }
186.125 + }
186.126 +
186.127 + Map<String, Map<RemoteIndex, Collection<String>>> result = new LinkedHashMap<String, Map<RemoteIndex, Collection<String>>>();
186.128 + long localTime = 0;
186.129 + long remoteTime = 0;
186.130 +
186.131 + for (URI ri : indices.keySet()) {
186.132 + Set<String> toProcess = new LinkedHashSet<String>(hashes);
186.133 + Map<String, Map<String, Collection<? extends String>>> indexResult = new LinkedHashMap<String, Map<String, Collection<? extends String>>>();
186.134 +
186.135 + long locS = System.currentTimeMillis();
186.136 + indexResult.putAll(findHashOccurrencesInLocalCache(ri, toProcess));
186.137 + localTime += System.currentTimeMillis() - locS;
186.138 +
186.139 + toProcess.removeAll(result.keySet());
186.140 +
186.141 + if (!toProcess.isEmpty()) {
186.142 + long remS = System.currentTimeMillis();
186.143 + Map<String, Map<String, Collection<? extends String>>> remoteResults = findHashOccurrencesRemote(ri, toProcess);
186.144 + remoteTime += System.currentTimeMillis() - remS;
186.145 +
186.146 + Map<String, Map<String, Collection<? extends String>>> toSave = new LinkedHashMap<String, Map<String, Collection<? extends String>>>(remoteResults);
186.147 +
186.148 + for (String hash : toProcess) {
186.149 + if (!toSave.containsKey(hash)) {
186.150 + toSave.put(hash, Collections.<String, Collection<? extends String>>emptyMap());
186.151 + }
186.152 + }
186.153 +
186.154 + saveToLocalCache(ri, toSave);
186.155 +
186.156 + indexResult.putAll(remoteResults);
186.157 + }
186.158 +
186.159 + for (Entry<String, Map<String, Collection<? extends String>>> e : indexResult.entrySet()) {
186.160 + Map<RemoteIndex, Collection<String>> hashResult = result.get(e.getKey());
186.161 +
186.162 + if (hashResult == null) {
186.163 + result.put(e.getKey(), hashResult = new LinkedHashMap<RemoteIndex, Collection<String>>());
186.164 + }
186.165 +
186.166 + for (Entry<String, Collection<? extends String>> insideHash : e.getValue().entrySet()) {
186.167 + RemoteIndex current = null;
186.168 +
186.169 + for (RemoteIndex r : indices.get(ri)) {
186.170 + if (r.remoteSegment.equals(insideHash.getKey())) {
186.171 + current = r;
186.172 + break;
186.173 + }
186.174 + }
186.175 +
186.176 + if (current == null) {
186.177 + continue;
186.178 + }
186.179 +
186.180 + Collection<String> dupes = hashResult.get(current);
186.181 +
186.182 + if (dupes == null) {
186.183 + hashResult.put(current, dupes = new HashSet<String>());
186.184 + }
186.185 +
186.186 + dupes.addAll(insideHash.getValue());
186.187 + }
186.188 + }
186.189 + }
186.190 +
186.191 + TIMER.log(Level.FINE, "local hash duplicates", new Object[] {currentFile, localTime});
186.192 + TIMER.log(Level.FINE, "remote hash duplicates", new Object[] {currentFile, remoteTime});
186.193 + return result;
186.194 + }
186.195 +
186.196 + private static Map<String, Map<String, Collection<? extends String>>> findHashOccurrencesRemote(URI remoteIndex, Iterable<? extends String> hashes) {
186.197 + try {
186.198 + String indexURL = remoteIndex.toASCIIString();
186.199 + URI u = new URI(indexURL + "/findDuplicates?hashes=" + WebUtilities.escapeForQuery(Pojson.save(hashes)));
186.200 + String hashesMap = WebUtilities.requestStringResponse(u);
186.201 +
186.202 + if (hashesMap == null) {
186.203 + //some kind of error while getting the duplicates (cannot access remote server)?
186.204 + //ignore:
186.205 + return Collections.emptyMap();
186.206 + }
186.207 + return Pojson.load(LinkedHashMap.class, hashesMap);
186.208 + } catch (URISyntaxException ex) {
186.209 + //XXX: better handling?
186.210 + Exceptions.printStackTrace(ex);
186.211 + return Collections.emptyMap();
186.212 + }
186.213 + }
186.214 +
186.215 + private static volatile IndexReader readerCache;
186.216 +
186.217 + private static File findLocalCacheDir(URI uri) throws IOException {
186.218 + return FileUtil.toFile(FileUtil.createFolder(CacheFolder.getDataFolder(uri.toURL()), "remote-duplicates"));
186.219 + }
186.220 +
186.221 + private static Map<String, Map<String, Collection<? extends String>>> findHashOccurrencesInLocalCache(URI uri, Iterable<? extends String> hashes) throws IOException {
186.222 + IndexReader reader = readerCache;
186.223 +
186.224 + if (reader == null) {
186.225 + File dir = findLocalCacheDir(uri);
186.226 +
186.227 + if (dir.listFiles() != null && dir.listFiles().length > 0) {
186.228 + readerCache = reader = IndexReader.open(FSDirectory.open(dir), true);
186.229 + }
186.230 + }
186.231 +
186.232 + if (reader == null) {
186.233 + return Collections.emptyMap();
186.234 + }
186.235 +
186.236 + Map<String, Map<String, Collection<String>>> result = new LinkedHashMap<String, Map<String, Collection<String>>>();
186.237 +
186.238 + for (Entry<String, Collection<? extends String>> e : containsHash(reader, hashes).entrySet()) {
186.239 + Map<String, Collection<String>> forHash = result.get(e.getKey());
186.240 +
186.241 + if (forHash == null) {
186.242 + result.put(e.getKey(), forHash = new LinkedHashMap<String, Collection<String>>());
186.243 + }
186.244 +
186.245 + for (String path : e.getValue()) {
186.246 + String segment = path.substring(0, path.indexOf('/'));
186.247 +
186.248 + path = path.substring(path.indexOf('/') + 1);
186.249 +
186.250 + Collection<String> list = forHash.get(segment);
186.251 +
186.252 + if (list == null) {
186.253 + forHash.put(segment, list = new LinkedList<String>());
186.254 + }
186.255 +
186.256 + list.add(path);
186.257 + }
186.258 + }
186.259 +
186.260 + return (Map)result; //XXX
186.261 + }
186.262 +
186.263 + private static void saveToLocalCache(URI uri, Map<String, Map<String, Collection<? extends String>>> what) throws IOException {
186.264 + IndexReader r = readerCache;
186.265 +
186.266 + if (r != null) {
186.267 + r.close();
186.268 + readerCache = null;
186.269 + }
186.270 +
186.271 + IndexWriter w = new IndexWriter(FSDirectory.open(findLocalCacheDir(uri)), new NoAnalyzer(), MaxFieldLength.UNLIMITED);
186.272 +
186.273 + for (Entry<String, Map<String, Collection<? extends String>>> e : what.entrySet()) {
186.274 + Document doc = new Document();
186.275 +
186.276 + doc.add(new Field("hash", e.getKey(), Store.YES, Index.NOT_ANALYZED));
186.277 +
186.278 + for (Entry<String, Collection<? extends String>> pe : e.getValue().entrySet()) {
186.279 + for (String path : pe.getValue()) {
186.280 + doc.add(new Field("path", pe.getKey() + "/" + path, Store.YES, Index.NO));
186.281 + }
186.282 + }
186.283 +
186.284 + w.addDocument(doc);
186.285 + }
186.286 +
186.287 + w.optimize();
186.288 + w.close();
186.289 + }
186.290 +
186.291 + private static List<DuplicateDescription> translate(Map<String, long[]> hashes, Map<String, Map<RemoteIndex, Collection<String>>> occ, FileObject currentFile) {
186.292 + Map<String, Map<RemoteIndex, Collection<String>>> sorted = hashMap();
186.293 + Map<long[], DuplicateDescription> result = new LinkedHashMap<long[], DuplicateDescription>();
186.294 + List<long[]> seen = new LinkedList<long[]>();
186.295 +
186.296 + sorted.putAll(occ);
186.297 +
186.298 + OUTER: for (Entry<String, Map<RemoteIndex, Collection<String>>> e : occ.entrySet()) {
186.299 + long[] currentSpan = hashes.get(e.getKey());
186.300 +
186.301 + for (Iterator<Entry<long[], DuplicateDescription>> it = result.entrySet().iterator(); it.hasNext();) {
186.302 + Entry<long[], DuplicateDescription> span = it.next();
186.303 +
186.304 + if (span.getKey()[0] <= currentSpan[0] && span.getKey()[1] >= currentSpan[1]) {
186.305 + continue OUTER;
186.306 + }
186.307 +
186.308 + if (currentSpan[0] <= span.getKey()[0] && currentSpan[1] >= span.getKey()[1]) {
186.309 + it.remove();
186.310 + }
186.311 + }
186.312 +
186.313 + if (currentSpan[0] == (-1) || currentSpan[1] == (-1)) continue;
186.314 +
186.315 + seen.add(currentSpan);
186.316 +
186.317 + String longest = e.getKey();
186.318 + List<Span> foundDuplicates = new LinkedList<Span>();
186.319 +
186.320 + for (Entry<RemoteIndex, Collection<String>> root2Occurrences : e.getValue().entrySet()) {
186.321 + FileObject localRoot = URLMapper.findFileObject(root2Occurrences.getKey().getLocalFolder());
186.322 +
186.323 + for (String cand : root2Occurrences.getValue()) {
186.324 + FileObject o = localRoot.getFileObject(cand);
186.325 +
186.326 + if (o == null) continue; //XXX log!
186.327 + if (areEquivalent(currentFile, o)) continue;
186.328 +
186.329 + foundDuplicates.add(new Span(o, -1, -1));
186.330 + }
186.331 + }
186.332 +
186.333 + if (foundDuplicates.isEmpty()) continue;
186.334 +
186.335 + DuplicateDescription current = DuplicateDescription.of(foundDuplicates, getValue(longest), longest);
186.336 +
186.337 + result.put(currentSpan, current);
186.338 + }
186.339 +
186.340 + return new LinkedList<DuplicateDescription>(result.values());
186.341 + }
186.342 +
186.343 + private static boolean areEquivalent(FileObject f1, FileObject f2) {
186.344 + return f1.equals(f2);
186.345 + }
186.346 +
186.347 + private static long getValue(String encoded) {
186.348 + return Long.parseLong(encoded.substring(encoded.lastIndexOf(":") + 1));
186.349 + }
186.350 +
186.351 + private static <T> TreeMap<String, T> hashMap() {
186.352 + return new TreeMap<String, T>(new Comparator<String>() {
186.353 + public int compare(String arg0, String arg1) {
186.354 + return (int) Math.signum(getValue(arg1) - getValue(arg0));
186.355 + }
186.356 + });
186.357 + }
186.358 +
186.359 + private static boolean subsumes(DuplicateDescription bigger, DuplicateDescription smaller) {
186.360 + Set<FileObject> bFiles = new HashSet<FileObject>();
186.361 +
186.362 + for (Span s : bigger.dupes) {
186.363 + bFiles.add(s.file);
186.364 + }
186.365 +
186.366 + Set<FileObject> sFiles = new HashSet<FileObject>();
186.367 +
186.368 + for (Span s : smaller.dupes) {
186.369 + sFiles.add(s.file);
186.370 + }
186.371 +
186.372 + if (!bFiles.equals(sFiles)) return false;
186.373 +
186.374 + Span testAgainst = bigger.dupes.get(0);
186.375 +
186.376 + for (Span s : smaller.dupes) {
186.377 + if (s.file == testAgainst.file) {
186.378 + if ( (testAgainst.startOff <= s.startOff && testAgainst.endOff > s.endOff)
186.379 + || (testAgainst.startOff < s.startOff && testAgainst.endOff >= s.endOff)) {
186.380 + return true;
186.381 + }
186.382 + }
186.383 + }
186.384 +
186.385 + return false;
186.386 + }
186.387 +
186.388 + public static Map<String, Collection<? extends String>> containsHash(IndexReader reader, Iterable<? extends String> hashes) throws IOException {
186.389 + Map<String, Collection<? extends String>> result = new LinkedHashMap<String, Collection<? extends String>>();
186.390 +
186.391 + for (String hash : hashes) {
186.392 + Collection<String> found = new LinkedList<String>();
186.393 + Query query = new TermQuery(new Term("hash", hash));
186.394 + Searcher s = new IndexSearcher(reader);
186.395 + BitSet matchingDocuments = new BitSet(reader.maxDoc());
186.396 + Collector c = new BitSetCollector(matchingDocuments);
186.397 +
186.398 + s.search(query, c);
186.399 +
186.400 + boolean wasFound = false;
186.401 +
186.402 + for (int docNum = matchingDocuments.nextSetBit(0); docNum >= 0; docNum = matchingDocuments.nextSetBit(docNum + 1)) {
186.403 + final Document doc = reader.document(docNum);
186.404 +
186.405 + found.addAll(Arrays.asList(doc.getValues("path")));
186.406 + wasFound = true;
186.407 + }
186.408 +
186.409 + if (wasFound) {
186.410 + result.put(hash, found);
186.411 + }
186.412 + }
186.413 +
186.414 + return result;
186.415 + }
186.416 +}
187.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
187.2 +++ b/duplicates/ide/impl/test/unit/src/org/netbeans/modules/jackpot30/impl/duplicates/ComputeDuplicatesTest.java Mon Mar 12 21:10:10 2012 +0100
187.3 @@ -0,0 +1,133 @@
187.4 +/*
187.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
187.6 + *
187.7 + * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
187.8 + *
187.9 + * The contents of this file are subject to the terms of either the GNU
187.10 + * General Public License Version 2 only ("GPL") or the Common
187.11 + * Development and Distribution License("CDDL") (collectively, the
187.12 + * "License"). You may not use this file except in compliance with the
187.13 + * License. You can obtain a copy of the License at
187.14 + * http://www.netbeans.org/cddl-gplv2.html
187.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
187.16 + * specific language governing permissions and limitations under the
187.17 + * License. When distributing the software, include this License Header
187.18 + * Notice in each file and include the License file at
187.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
187.20 + * particular file as subject to the "Classpath" exception as provided
187.21 + * by Sun in the GPL Version 2 section of the License file that
187.22 + * accompanied this code. If applicable, add the following below the
187.23 + * License Header, with the fields enclosed by brackets [] replaced by
187.24 + * your own identifying information:
187.25 + * "Portions Copyrighted [year] [name of copyright owner]"
187.26 + *
187.27 + * If you wish your version of this file to be governed by only the CDDL
187.28 + * or only the GPL Version 2, indicate your decision by adding
187.29 + * "[Contributor] elects to include this software in this distribution
187.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
187.31 + * single choice of license, a recipient has the option to distribute
187.32 + * your version of this file under either the CDDL, the GPL Version 2 or
187.33 + * to extend the choice of license to its licensees as provided above.
187.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
187.35 + * Version 2 license, then the option applies only if the new code is
187.36 + * made subject to such option by the copyright holder.
187.37 + *
187.38 + * Contributor(s):
187.39 + *
187.40 + * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
187.41 + */
187.42 +
187.43 +package org.netbeans.modules.jackpot30.impl.duplicates;
187.44 +
187.45 +import org.netbeans.api.progress.ProgressHandle;
187.46 +import org.openide.filesystems.FileObject;
187.47 +import java.util.HashMap;
187.48 +import java.util.Map;
187.49 +import java.util.concurrent.atomic.AtomicBoolean;
187.50 +import org.netbeans.api.java.source.TestUtilities;
187.51 +import org.netbeans.api.progress.ProgressHandleFactory;
187.52 +import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.DuplicateDescription;
187.53 +import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.Span;
187.54 +import org.netbeans.modules.jackpot30.common.test.IndexTestBase;
187.55 +import org.openide.filesystems.FileUtil;
187.56 +import org.openide.util.NbCollections;
187.57 +import static org.junit.Assert.*;
187.58 +import org.netbeans.api.editor.mimelookup.MimePath;
187.59 +import org.netbeans.modules.jackpot30.impl.duplicates.indexing.DuplicatesCustomIndexerImpl;
187.60 +import org.netbeans.spi.editor.mimelookup.MimeDataProvider;
187.61 +import org.openide.util.Lookup;
187.62 +import org.openide.util.lookup.Lookups;
187.63 +import org.openide.util.lookup.ServiceProvider;
187.64 +
187.65 +/**
187.66 + *
187.67 + * @author lahvac
187.68 + */
187.69 +public class ComputeDuplicatesTest extends IndexTestBase {
187.70 +
187.71 + public ComputeDuplicatesTest(String name) {
187.72 + super(name);
187.73 + }
187.74 +
187.75 + public void testDuplicateDuplicates() throws Exception {
187.76 + writeFilesAndWaitForScan(src,
187.77 + new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }"),
187.78 + new File("test/Test2.java", "package test; public class Test2 { private int a; private void test() { java.io.File f = null; f.isDirectory(); } }"));
187.79 +
187.80 + verifyDuplicates("test/Test1.java",
187.81 + "private void test() { java.io.File f = null; f.isDirectory(); }",
187.82 + "test/Test2.java",
187.83 + "private void test() { java.io.File f = null; f.isDirectory(); }");
187.84 + }
187.85 +
187.86 + public void testCrossIndex() throws Exception {
187.87 + writeFilesAndWaitForScan(src,
187.88 + new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }"));
187.89 +
187.90 + writeFilesAndWaitForScan(src2,
187.91 + new File("test/Test2.java", "package test; public class Test2 { private int a; private void test() { java.io.File f = null; f.isDirectory(); } }"));
187.92 +
187.93 + verifyDuplicates("test/Test1.java",
187.94 + "private void test() { java.io.File f = null; f.isDirectory(); }",
187.95 + "test/Test2.java",
187.96 + "private void test() { java.io.File f = null; f.isDirectory(); }");
187.97 + }
187.98 +
187.99 + private void verifyDuplicates(String... fileAndDuplicateCode) throws Exception {
187.100 + Map<String, String> duplicatesGolden = new HashMap<String, String>();
187.101 +
187.102 + for (int cntr = 0; cntr < fileAndDuplicateCode.length; cntr += 2) {
187.103 + duplicatesGolden.put(fileAndDuplicateCode[cntr], fileAndDuplicateCode[cntr + 1]);
187.104 + }
187.105 +
187.106 + Map<String, String> duplicatesReal = new HashMap<String, String>();
187.107 + ProgressHandle handle = ProgressHandleFactory.createHandle("test");
187.108 +
187.109 + handle.start();
187.110 +
187.111 + for (DuplicateDescription dd : NbCollections.iterable(new ComputeDuplicates().computeDuplicatesForAllOpenedProjects(handle, new AtomicBoolean()))) {
187.112 + for (Span s : dd.dupes) {
187.113 + duplicatesReal.put(relativePath(s.file), TestUtilities.copyFileToString(FileUtil.toFile(s.file)).substring(s.startOff, s.endOff));
187.114 + }
187.115 + }
187.116 +
187.117 + assertEquals(duplicatesGolden, duplicatesReal);
187.118 + }
187.119 +
187.120 + private String relativePath(FileObject file) {
187.121 + return FileUtil.isParentOf(src, file) ? FileUtil.getRelativePath(src, file) : FileUtil.getRelativePath(src2, file);
187.122 + }
187.123 +
187.124 + @ServiceProvider(service=MimeDataProvider.class)
187.125 + public static final class MimeDataProviderImpl implements MimeDataProvider {
187.126 +
187.127 + private final Lookup L = Lookups.fixed(new DuplicatesCustomIndexerImpl.FactoryImpl());
187.128 +
187.129 + @Override
187.130 + public Lookup getLookup(MimePath mimePath) {
187.131 + if ("text/x-java".equals(mimePath.getPath())) return L;
187.132 + return Lookup.EMPTY;
187.133 + }
187.134 +
187.135 + }
187.136 +}
187.137 \ No newline at end of file
188.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
188.2 +++ b/duplicates/ide/impl/test/unit/src/org/netbeans/modules/jackpot30/impl/duplicates/indexing/RemoteDuplicatesIndexTest.java Mon Mar 12 21:10:10 2012 +0100
188.3 @@ -0,0 +1,133 @@
188.4 +/*
188.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
188.6 + *
188.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
188.8 + *
188.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
188.10 + * Other names may be trademarks of their respective owners.
188.11 + *
188.12 + * The contents of this file are subject to the terms of either the GNU
188.13 + * General Public License Version 2 only ("GPL") or the Common
188.14 + * Development and Distribution License("CDDL") (collectively, the
188.15 + * "License"). You may not use this file except in compliance with the
188.16 + * License. You can obtain a copy of the License at
188.17 + * http://www.netbeans.org/cddl-gplv2.html
188.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
188.19 + * specific language governing permissions and limitations under the
188.20 + * License. When distributing the software, include this License Header
188.21 + * Notice in each file and include the License file at
188.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
188.23 + * particular file as subject to the "Classpath" exception as provided
188.24 + * by Oracle in the GPL Version 2 section of the License file that
188.25 + * accompanied this code. If applicable, add the following below the
188.26 + * License Header, with the fields enclosed by brackets [] replaced by
188.27 + * your own identifying information:
188.28 + * "Portions Copyrighted [year] [name of copyright owner]"
188.29 + *
188.30 + * If you wish your version of this file to be governed by only the CDDL
188.31 + * or only the GPL Version 2, indicate your decision by adding
188.32 + * "[Contributor] elects to include this software in this distribution
188.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
188.34 + * single choice of license, a recipient has the option to distribute
188.35 + * your version of this file under either the CDDL, the GPL Version 2 or
188.36 + * to extend the choice of license to its licensees as provided above.
188.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
188.38 + * Version 2 license, then the option applies only if the new code is
188.39 + * made subject to such option by the copyright holder.
188.40 + *
188.41 + * Contributor(s):
188.42 + *
188.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
188.44 + */
188.45 +package org.netbeans.modules.jackpot30.impl.duplicates.indexing;
188.46 +
188.47 +import java.io.File;
188.48 +import java.net.URL;
188.49 +import java.util.ArrayList;
188.50 +import java.util.Arrays;
188.51 +import java.util.HashMap;
188.52 +import java.util.List;
188.53 +import java.util.Map;
188.54 +import org.netbeans.api.java.source.TestUtilities;
188.55 +import static org.junit.Assert.*;
188.56 +import org.netbeans.api.java.source.SourceUtilsTestUtil;
188.57 +import org.netbeans.core.startup.Main;
188.58 +import org.netbeans.junit.NbTestCase;
188.59 +import org.netbeans.modules.jackpot30.impl.TestUtils;
188.60 +import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.DuplicateDescription;
188.61 +import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates.Span;
188.62 +import org.netbeans.modules.jackpot30.remoting.api.RemoteIndex;
188.63 +import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
188.64 +import org.openide.filesystems.FileObject;
188.65 +import org.openide.filesystems.FileUtil;
188.66 +
188.67 +/**
188.68 + *
188.69 + * @author lahvac
188.70 + */
188.71 +public class RemoteDuplicatesIndexTest extends NbTestCase {
188.72 +
188.73 + public RemoteDuplicatesIndexTest(String name) {
188.74 + super(name);
188.75 + }
188.76 +
188.77 + public void setUp() throws Exception {
188.78 + SourceUtilsTestUtil.prepareTest(new String[0], new Object[0]);
188.79 + Main.initializeURLFactory();
188.80 + TestUtils.clearRemoteContent();
188.81 + super.setUp();
188.82 + }
188.83 +
188.84 + public void testFindHashOccurrences() throws Exception {
188.85 + clearWorkDir();
188.86 + File cacheDir = new File(getWorkDir(), "cache");
188.87 + File dataDir = new File(getWorkDir(), "data");
188.88 +
188.89 + CacheFolder.setCacheFolder(FileUtil.createFolder(cacheDir));
188.90 +
188.91 + FileObject data1 = FileUtil.createFolder(new File(dataDir, "data1"));
188.92 + FileObject data2 = FileUtil.createFolder(new File(dataDir, "data2"));
188.93 + FileObject source = FileUtil.createData(new File(dataDir, "src/Test.java"));
188.94 +
188.95 + TestUtilities.copyStringToFile(data1.createData("T1.java"), "0123456789");
188.96 + TestUtilities.copyStringToFile(data1.createData("T2.java"), "0123456789");
188.97 + TestUtilities.copyStringToFile(data2.createData("T3.java"), "0123456789");
188.98 + TestUtilities.copyStringToFile(data2.createData("T4.java"), "0123456789");
188.99 +
188.100 + TestUtils.addRemoteContent(new URL("test://test/index/findDuplicates?hashes=[%0A%20%20%20%20%2200%22,%0A%20%20%20%20%2201%22,%0A%20%20%20%20%2202%22%0A]"), "{ \"00\": { \"foo1\": [ \"T1.java\", \"T2.java\" ], \"foo2\": [ \"T3.java\", \"T4.java\" ] } }");
188.101 + RemoteIndex.saveIndices(Arrays.asList(RemoteIndex.create(FileUtil.toFile(data1).toURI().toURL(), new URL("test://test/index"), "foo1"),
188.102 + RemoteIndex.create(FileUtil.toFile(data2).toURI().toURL(), new URL("test://test/index"), "foo2")));
188.103 +
188.104 + TestUtilities.copyStringToFile(source, "01234567890123456789");
188.105 +
188.106 + Map<String, long[]> hashes = new HashMap<String, long[]>();
188.107 +
188.108 + hashes.put("00", new long[] {1, 2, 5, 6});
188.109 + hashes.put("01", new long[] {8, 9});
188.110 + hashes.put("02", new long[] {3, 4});
188.111 +
188.112 + List<DuplicateDescription> duplicates = RemoteDuplicatesIndex.findDuplicates(hashes, source);
188.113 + List<String> duplicatesReal = new ArrayList<String>();
188.114 +
188.115 + for (DuplicateDescription dd : duplicates) {
188.116 + for (Span s : dd.dupes) {
188.117 + duplicatesReal.add(s.file.getName());
188.118 + }
188.119 + }
188.120 +
188.121 + assertEquals(Arrays.asList("T2", "T1", "T4", "T3"), duplicatesReal);
188.122 +
188.123 + //check local cache:
188.124 + duplicates = RemoteDuplicatesIndex.findDuplicates(hashes, source);
188.125 + duplicatesReal = new ArrayList<String>();
188.126 +
188.127 + for (DuplicateDescription dd : duplicates) {
188.128 + for (Span s : dd.dupes) {
188.129 + duplicatesReal.add(s.file.getName());
188.130 + }
188.131 + }
188.132 +
188.133 + assertEquals(Arrays.asList("T2", "T1", "T4", "T3"), duplicatesReal);
188.134 + }
188.135 +
188.136 +}
189.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
189.2 +++ b/duplicates/ide/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
189.3 @@ -0,0 +1,50 @@
189.4 +<?xml version="1.0" encoding="UTF-8"?>
189.5 +<!--
189.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
189.7 +*** EDIT ../build.xml INSTEAD ***
189.8 +-->
189.9 +<project name="duplicates-ide-impl" basedir=".." xmlns:sproject="http://www.netbeans.org/ns/nb-module-suite-project/1">
189.10 + <fail message="Please build using Ant 1.7.1 or higher.">
189.11 + <condition>
189.12 + <not>
189.13 + <antversion atleast="1.7.1"/>
189.14 + </not>
189.15 + </condition>
189.16 + </fail>
189.17 + <property file="nbproject/private/platform-private.properties"/>
189.18 + <property file="nbproject/platform.properties"/>
189.19 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-suite-project/1">
189.20 + <attribute name="name"/>
189.21 + <attribute name="value"/>
189.22 + <sequential>
189.23 + <property name="@{name}" value="${@{value}}"/>
189.24 + </sequential>
189.25 + </macrodef>
189.26 + <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-suite-project/1">
189.27 + <attribute name="property"/>
189.28 + <attribute name="value"/>
189.29 + <sequential>
189.30 + <property name="@{property}" value="@{value}"/>
189.31 + </sequential>
189.32 + </macrodef>
189.33 + <property file="${user.properties.file}"/>
189.34 + <sproject:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir"/>
189.35 + <sproject:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir"/>
189.36 + <sproject:evalprops property="cluster.path.evaluated" value="${cluster.path}"/>
189.37 + <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
189.38 + <condition>
189.39 + <not>
189.40 + <contains string="${cluster.path.evaluated}" substring="platform"/>
189.41 + </not>
189.42 + </condition>
189.43 + </fail>
189.44 + <ant antfile="nbproject/platform.xml"/>
189.45 + <fail message="Cannot find NetBeans build harness. ${line.separator}Check that nbplatform.${nbplatform.active}.netbeans.dest.dir and nbplatform.${nbplatform.active}.harness.dir are defined. ${line.separator}On a developer machine these are normally defined in ${user.properties.file}=${netbeans.user}/build.properties ${line.separator}but for automated builds you should pass these properties to Ant explicitly. ${line.separator}You may instead download the harness and platform: -Dbootstrap.url=.../tasks.jar -Dautoupdate.catalog.url=.../updates.xml">
189.46 + <condition>
189.47 + <not>
189.48 + <available file="${harness.dir}/suite.xml"/>
189.49 + </not>
189.50 + </condition>
189.51 + </fail>
189.52 + <import file="${harness.dir}/suite.xml"/>
189.53 +</project>
190.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
190.2 +++ b/duplicates/ide/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
190.3 @@ -0,0 +1,11 @@
190.4 +build.xml.data.CRC32=891734f5
190.5 +build.xml.script.CRC32=82b74f72
190.6 +build.xml.stylesheet.CRC32=eaf9f76a@2.49
190.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
190.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
190.9 +nbproject/build-impl.xml.data.CRC32=44b3f6ba
190.10 +nbproject/build-impl.xml.script.CRC32=d800a24f
190.11 +nbproject/build-impl.xml.stylesheet.CRC32=0f381476@2.49
190.12 +nbproject/platform.xml.data.CRC32=44b3f6ba
190.13 +nbproject/platform.xml.script.CRC32=db9e1f43
190.14 +nbproject/platform.xml.stylesheet.CRC32=df8ac4dd@2.49
191.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
191.2 +++ b/duplicates/ide/nbproject/platform.properties Mon Mar 12 21:10:10 2012 +0100
191.3 @@ -0,0 +1,19 @@
191.4 +cluster.path=\
191.5 + ${nbplatform.active.dir}/apisupport:\
191.6 + ${nbplatform.active.dir}/cnd:\
191.7 + ${nbplatform.active.dir}/dlight:\
191.8 + ${nbplatform.active.dir}/enterprise:\
191.9 + ${nbplatform.active.dir}/harness:\
191.10 + ${nbplatform.active.dir}/ide:\
191.11 + ${nbplatform.active.dir}/java:\
191.12 + ${nbplatform.active.dir}/nb:\
191.13 + ${nbplatform.active.dir}/platform:\
191.14 + ${nbplatform.active.dir}/profiler:\
191.15 + ${nbplatform.active.dir}/websvccommon:\
191.16 + ../../remoting/common/build/cluster:\
191.17 + ../../remoting/ide/build/cluster
191.18 +extcluster.../../remoting/common/build/cluster.javadoc=
191.19 +extcluster.../../remoting/common/build/cluster.sources=../../remoting/common
191.20 +extcluster.../../remoting/ide/build/cluster.javadoc=
191.21 +extcluster.../../remoting/ide/build/cluster.sources=../../remoting/ide
191.22 +nbplatform.active=default
192.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
192.2 +++ b/duplicates/ide/nbproject/platform.xml Mon Mar 12 21:10:10 2012 +0100
192.3 @@ -0,0 +1,34 @@
192.4 +<?xml version="1.0" encoding="UTF-8"?>
192.5 +<project name="platform" default="download" basedir="..">
192.6 + <condition property="download.required">
192.7 + <and>
192.8 + <not>
192.9 + <available file="${harness.dir}/suite.xml"/>
192.10 + </not>
192.11 + <isset property="bootstrap.url"/>
192.12 + <isset property="autoupdate.catalog.url"/>
192.13 + </and>
192.14 + </condition>
192.15 + <target name="download" if="download.required">
192.16 + <mkdir dir="${harness.dir}"/>
192.17 + <pathconvert pathsep="|" property="download.clusters">
192.18 + <mapper type="flatten"/>
192.19 + <path path="${cluster.path}"/>
192.20 + </pathconvert>
192.21 + <property name="disabled.modules" value=""/>
192.22 + <pathconvert property="module.includes" pathsep="">
192.23 + <mapper type="glob" from="${basedir}${file.separator}*" to="(?!\Q*\E)"/>
192.24 + <path>
192.25 + <filelist files="${disabled.modules}" dir="."/>
192.26 + </path>
192.27 + </pathconvert>
192.28 + <echo message="Downloading clusters ${download.clusters}"/>
192.29 + <property name="tasks.jar" location="${java.io.tmpdir}/tasks.jar"/>
192.30 + <get src="${bootstrap.url}" dest="${tasks.jar}" usetimestamp="true" verbose="true"/>
192.31 + <taskdef name="autoupdate" classname="org.netbeans.nbbuild.AutoUpdate" classpath="${tasks.jar}"/>
192.32 + <autoupdate installdir="${nbplatform.active.dir}" updatecenter="${autoupdate.catalog.url}">
192.33 + <modules includes="${module.includes}.*" clusters="${download.clusters}"/>
192.34 + <modules includes="org[.]netbeans[.]modules[.]apisupport[.]harness" clusters="harness"/>
192.35 + </autoupdate>
192.36 + </target>
192.37 +</project>
193.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
193.2 +++ b/duplicates/ide/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
193.3 @@ -0,0 +1,3 @@
193.4 +modules=\
193.5 + ${project.org.netbeans.modules.jackpot30.duplicates.impl}
193.6 +project.org.netbeans.modules.jackpot30.duplicates.impl=impl
194.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
194.2 +++ b/duplicates/ide/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
194.3 @@ -0,0 +1,9 @@
194.4 +<?xml version="1.0" encoding="UTF-8"?>
194.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
194.6 + <type>org.netbeans.modules.apisupport.project.suite</type>
194.7 + <configuration>
194.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-suite-project/1">
194.9 + <name>duplicates-ide</name>
194.10 + </data>
194.11 + </configuration>
194.12 +</project>
195.1 --- a/help/build.xml Fri Jan 27 13:35:56 2012 +0100
195.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
195.3 @@ -1,48 +0,0 @@
195.4 -<?xml version="1.0" encoding="UTF-8"?>
195.5 -<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
195.6 -<!-- for some information on what you could do (e.g. targets to override). -->
195.7 -<!-- If you delete this file and reopen the project it will be recreated. -->
195.8 -<project name="org.netbeans.modules.jackpot30.help" default="netbeans" basedir=".">
195.9 - <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.help.</description>
195.10 - <import file="nbproject/build-impl.xml"/>
195.11 - <import file="${suite.dir}/findbugs-import.xml"/>
195.12 -
195.13 - <target name="help-init">
195.14 - <property environment="ENV." />
195.15 - <condition property="hasLaTeX2HTML">
195.16 - <available file="latex2html" filepath="${ENV.PATH}" />
195.17 - </condition>
195.18 - </target>
195.19 -
195.20 - <target name="compile-help" depends="help-init" if="hasLaTeX2HTML">
195.21 - <mkdir dir="${basedir}/build/help/org/netbeans/modules/jackpot30/help/docs" />
195.22 -
195.23 - <copy file="jackpot30-helpset.xml" todir="${basedir}/build/help/org/netbeans/modules/jackpot30/help/docs" />
195.24 -
195.25 - <exec executable="latex2html">
195.26 - <arg value="-antialias" />
195.27 - <arg value="-antialias_text" />
195.28 - <arg value="-dir" />
195.29 - <arg value="build/help/org/netbeans/modules/jackpot30/help/docs" />
195.30 - <arg value="jackpot30-help.tex" />
195.31 - </exec>
195.32 -
195.33 - <java classname="org.netbeans.modules.jackpot30.help.CreateMap"
195.34 - classpath="build/classes">
195.35 - <arg value="${basedir}/build/help/org/netbeans/modules/jackpot30/help/docs" />
195.36 - </java>
195.37 -
195.38 - <mkdir dir="${suite.dir}/build/cluster/modules/docs" />
195.39 -
195.40 - <jar destfile="${suite.dir}/build/cluster/modules/docs/org-netbeans-modules-jackpot30-help.jar" basedir="${basedir}/build/help">
195.41 -
195.42 - </jar>
195.43 - </target>
195.44 -
195.45 - <target name="compile" depends="projectized-common.compile,compile-help" />
195.46 -
195.47 - <target name="test" />
195.48 - <target name="test-coverage" />
195.49 - <target name="coverage-report" />
195.50 -
195.51 -</project>
196.1 --- a/help/jackpot30-help.tex Fri Jan 27 13:35:56 2012 +0100
196.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
196.3 @@ -1,119 +0,0 @@
196.4 -\documentclass{article}
196.5 -\usepackage{verbdef}
196.6 -\usepackage{hyperref}
196.7 -
196.8 -\verbdef\simplevariable=$[0-9A-Za-z_]+=
196.9 -\verbdef\statementvariable=$[0-9A-Za-z_]+;=
196.10 -\verbdef\multipletreevariable=$[0-9A-Za-z_]+$=
196.11 -\verbdef\multiplestatementvariable=$[0-9A-Za-z_]+$;=
196.12 -\verbdef\wholepattern=$_=
196.13 -\verbdef\reserved=$$[0-9A-Za-z_]+=
196.14 -
196.15 -\begin{document}
196.16 -
196.17 -\section{Rules Language}
196.18 -
196.19 -\subsection{Basic Structure}
196.20 -
196.21 -The rules file consists of any number of transformation rules.
196.22 -The rule is defined as follows:
196.23 -\begin{verbatim}
196.24 - <pattern>
196.25 -=> <fix-pattern>
196.26 -=> <fix-pattern>
196.27 -;;
196.28 -\end{verbatim}
196.29 -
196.30 -Each occurrence of \verb=<pattern>= in the source code can be rewritten to one
196.31 -of the \verb=<fix-pattern>=s. For example, the following transformation rule:
196.32 -\begin{verbatim}
196.33 - $1 == null
196.34 -=> null == $1
196.35 -;;
196.36 -\end{verbatim}
196.37 -
196.38 -will rewrite the following code:
196.39 -\begin{verbatim}
196.40 -if (a == null) {
196.41 - System.err.println("a is null");
196.42 -}
196.43 -\end{verbatim}
196.44 -to:
196.45 -\begin{verbatim}
196.46 -if (null == a) {
196.47 - System.err.println("a is null");
196.48 -}
196.49 -\end{verbatim}
196.50 -
196.51 -Note: \verb=$1$= is a variable, explained \hyperref{below}{in Section~}{variables}{}.
196.52 -
196.53 -Note: batch refactoring will typically use only the first applicable fix patterns
196.54 -of each applicable rule.
196.55 -
196.56 -\subsection{Patterns}
196.57 -
196.58 -The pattern is a Java expression, statement or several statements.
196.59 -All references to classes in the pattern need to be resolvable, i.e. either fully
196.60 -qualified names need to be used, or the custom import section must be used
196.61 -(see \hyperref{Custom Imports}{Section~}{custom-import}{}).
196.62 -
196.63 -TODO: equivalence - static elements are checked only against themselves, blocks with
196.64 -one statement considered equivalent to single statement.
196.65 -
196.66 -Note: variable declaration is a Java statement.
196.67 -
196.68 -\subsection{Variables}
196.69 -
196.70 -Variables start with the dollar sign (\verb=$=). In the pattern, first occurrences
196.71 -of a variable is bound to the actual sub-tree that appears in the code. Second and
196.72 -following occurrences of the variable the actual sub-tree is verified against the subtree
196.73 -bound to the variable. The pattern occurs in the text only if the actual sub-tree
196.74 -matches the sub-tree bound to the variable. In the fix pattern, all occurrences of
196.75 -the variables are replaced with the tree(s) bound to the respective variables.
196.76 -
196.77 -The forms of the variables are:
196.78 -\begin{description}
196.79 -\item[\simplevariable]{any expression}
196.80 -\item[\statementvariable]{any statement}
196.81 -\item[\multipletreevariable]{any number of sub-trees (except statements - see next definition)}
196.82 -\item[\multiplestatementvariable]{any number of statements}
196.83 -\item[\wholepattern]{for patterns undefined, for fixes and conditions automatically bound to the current matched region}
196.84 -\item[\reserved]{reserved -- do not use}
196.85 -\end{description}
196.86 -
196.87 -\subsection{Conditions}
196.88 -
196.89 -Both the search and fix patterns may specify additional conditions. These conditions
196.90 -are specified after \verb=::=. Currently, the conditions have the following
196.91 -limitations:
196.92 -
196.93 -\begin{verbatim}
196.94 - $1.isDirectory() :: $1 instanceof java.io.File
196.95 -=> !$1.isFile()
196.96 -;;
196.97 -\end{verbatim}
196.98 -
196.99 -will rewrite the following code:
196.100 -\begin{verbatim}
196.101 -java.io.File testFile = new java.io.File("/tmp");
196.102 -if (testFile.isDirectory()) {
196.103 - System.err.println("/tmp is a directory");
196.104 -}
196.105 -\end{verbatim}
196.106 -to:
196.107 -\begin{verbatim}
196.108 -java.io.File testFile = new java.io.File("/tmp");
196.109 -if (!testFile.isFile()) {
196.110 - System.err.println("/tmp is a directory");
196.111 -}
196.112 -\end{verbatim}
196.113 -
196.114 -\subsection{Display Names and Localization}
196.115 -
196.116 -\subsection{Custom Conditions}
196.117 -
196.118 -\subsection{Custom Import}
196.119 -
196.120 -\subsection{Options}
196.121 -
196.122 -\end{document}
197.1 --- a/help/jackpot30-helpset.xml Fri Jan 27 13:35:56 2012 +0100
197.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
197.3 @@ -1,31 +0,0 @@
197.4 -<?xml version="1.0" encoding="UTF-8"?>
197.5 -<!--
197.6 -To change this template, choose Tools | Templates
197.7 -and open the template in the editor.
197.8 --->
197.9 -<!DOCTYPE helpset PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 2.0//EN" "http://java.sun.com/products/javahelp/helpset_2_0.dtd">
197.10 -<helpset version="2.0">
197.11 - <title>Jackpot 3.0 Help</title>
197.12 - <maps>
197.13 - <homeID>jackpot30.about</homeID>
197.14 - <mapref location="jackpot30-map.xml"/>
197.15 - </maps>
197.16 - <view mergetype="javax.help.AppendMerge">
197.17 - <name>TOC</name>
197.18 - <label>Table of Contents</label>
197.19 - <type>javax.help.TOCView</type>
197.20 - <data>jackpot30-toc.xml</data>
197.21 - </view>
197.22 -<!-- <view mergetype="javax.help.AppendMerge">
197.23 - <name>Index</name>
197.24 - <label>Index</label>
197.25 - <type>javax.help.IndexView</type>
197.26 - <data>dsaf-idx.xml</data>
197.27 - </view>-->
197.28 -<!-- <view>
197.29 - <name>Search</name>
197.30 - <label>Search</label>
197.31 - <type>javax.help.SearchView</type>
197.32 - <data engine="com.sun.java.help.search.DefaultSearchEngine">JavaHelpSearch</data>
197.33 - </view>-->
197.34 -</helpset>
198.1 --- a/help/manifest.mf Fri Jan 27 13:35:56 2012 +0100
198.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
198.3 @@ -1,7 +0,0 @@
198.4 -Manifest-Version: 1.0
198.5 -OpenIDE-Module: org.netbeans.modules.jackpot30.help
198.6 -OpenIDE-Module-Layer: org/netbeans/modules/jackpot30/help/layer.xml
198.7 -OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/help/Bundle.properties
198.8 -OpenIDE-Module-Specification-Version: 1.16
198.9 -OpenIDE-Module-Requires: org.netbeans.api.javahelp.Help
198.10 -Class-Path: docs/org-netbeans-modules-jackpot30-help.jar
199.1 --- a/help/nbproject-help.tex/build-settings.properties Fri Jan 27 13:35:56 2012 +0100
199.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
199.3 @@ -1,3 +0,0 @@
199.4 -build-configuration-name=latexdvips
199.5 -
199.6 -mainfile=../jackpot30-help.tex
200.1 --- a/help/nbproject/build-impl.xml Fri Jan 27 13:35:56 2012 +0100
200.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
200.3 @@ -1,45 +0,0 @@
200.4 -<?xml version="1.0" encoding="UTF-8"?>
200.5 -<!--
200.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
200.7 -*** EDIT ../build.xml INSTEAD ***
200.8 --->
200.9 -<project name="org.netbeans.modules.jackpot30.help-impl" basedir="..">
200.10 - <fail message="Please build using Ant 1.7.1 or higher.">
200.11 - <condition>
200.12 - <not>
200.13 - <antversion atleast="1.7.1"/>
200.14 - </not>
200.15 - </condition>
200.16 - </fail>
200.17 - <property file="nbproject/private/suite-private.properties"/>
200.18 - <property file="nbproject/suite.properties"/>
200.19 - <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
200.20 - <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
200.21 - <property file="${suite.dir}/nbproject/platform.properties"/>
200.22 - <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
200.23 - <attribute name="name"/>
200.24 - <attribute name="value"/>
200.25 - <sequential>
200.26 - <property name="@{name}" value="${@{value}}"/>
200.27 - </sequential>
200.28 - </macrodef>
200.29 - <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
200.30 - <attribute name="property"/>
200.31 - <attribute name="value"/>
200.32 - <sequential>
200.33 - <property name="@{property}" value="@{value}"/>
200.34 - </sequential>
200.35 - </macrodef>
200.36 - <property file="${user.properties.file}"/>
200.37 - <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
200.38 - <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
200.39 - <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
200.40 - <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
200.41 - <condition>
200.42 - <not>
200.43 - <contains string="${cluster.path.evaluated}" substring="platform"/>
200.44 - </not>
200.45 - </condition>
200.46 - </fail>
200.47 - <import file="${harness.dir}/build.xml"/>
200.48 -</project>
201.1 --- a/help/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
201.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
201.3 @@ -1,8 +0,0 @@
201.4 -build.xml.data.CRC32=ffaf56d3
201.5 -build.xml.script.CRC32=12cad5e6
201.6 -build.xml.stylesheet.CRC32=79c3b980@1.29.0.7
201.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
201.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
201.9 -nbproject/build-impl.xml.data.CRC32=ffaf56d3
201.10 -nbproject/build-impl.xml.script.CRC32=68ad079b
201.11 -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.43
202.1 --- a/help/nbproject/project.properties Fri Jan 27 13:35:56 2012 +0100
202.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
202.3 @@ -1,2 +0,0 @@
202.4 -javac.source=1.5
202.5 -javac.compilerargs=-Xlint -Xlint:-serial
203.1 --- a/help/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
203.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
203.3 @@ -1,12 +0,0 @@
203.4 -<?xml version="1.0" encoding="UTF-8"?>
203.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
203.6 - <type>org.netbeans.modules.apisupport.project</type>
203.7 - <configuration>
203.8 - <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
203.9 - <code-name-base>org.netbeans.modules.jackpot30.help</code-name-base>
203.10 - <suite-component/>
203.11 - <module-dependencies/>
203.12 - <public-packages/>
203.13 - </data>
203.14 - </configuration>
203.15 -</project>
204.1 --- a/help/nbproject/suite.properties Fri Jan 27 13:35:56 2012 +0100
204.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
204.3 @@ -1,1 +0,0 @@
204.4 -suite.dir=${basedir}/..
205.1 --- a/help/src/org/netbeans/modules/jackpot30/help/Bundle.properties Fri Jan 27 13:35:56 2012 +0100
205.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
205.3 @@ -1,38 +0,0 @@
205.4 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
205.5 -#
205.6 -# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
205.7 -#
205.8 -# The contents of this file are subject to the terms of either the GNU
205.9 -# General Public License Version 2 only ("GPL") or the Common
205.10 -# Development and Distribution License("CDDL") (collectively, the
205.11 -# "License"). You may not use this file except in compliance with the
205.12 -# License. You can obtain a copy of the License at
205.13 -# http://www.netbeans.org/cddl-gplv2.html
205.14 -# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
205.15 -# specific language governing permissions and limitations under the
205.16 -# License. When distributing the software, include this License Header
205.17 -# Notice in each file and include the License file at
205.18 -# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
205.19 -# particular file as subject to the "Classpath" exception as provided
205.20 -# by Sun in the GPL Version 2 section of the License file that
205.21 -# accompanied this code. If applicable, add the following below the
205.22 -# License Header, with the fields enclosed by brackets [] replaced by
205.23 -# your own identifying information:
205.24 -# "Portions Copyrighted [year] [name of copyright owner]"
205.25 -#
205.26 -# If you wish your version of this file to be governed by only the CDDL
205.27 -# or only the GPL Version 2, indicate your decision by adding
205.28 -# "[Contributor] elects to include this software in this distribution
205.29 -# under the [CDDL or GPL Version 2] license." If you do not indicate a
205.30 -# single choice of license, a recipient has the option to distribute
205.31 -# your version of this file under either the CDDL, the GPL Version 2 or
205.32 -# to extend the choice of license to its licensees as provided above.
205.33 -# However, if you add GPL Version 2 code and therefore, elected the GPL
205.34 -# Version 2 license, then the option applies only if the new code is
205.35 -# made subject to such option by the copyright holder.
205.36 -#
205.37 -# Contributor(s):
205.38 -#
205.39 -# Portions Copyrighted 2009 Sun Microsystems, Inc.
205.40 -
205.41 -OpenIDE-Module-Name=Jackpot 3.0 Help
206.1 --- a/help/src/org/netbeans/modules/jackpot30/help/CreateMap.java Fri Jan 27 13:35:56 2012 +0100
206.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
206.3 @@ -1,196 +0,0 @@
206.4 -/*
206.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
206.6 - *
206.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
206.8 - *
206.9 - * The contents of this file are subject to the terms of either the GNU
206.10 - * General Public License Version 2 only ("GPL") or the Common
206.11 - * Development and Distribution License("CDDL") (collectively, the
206.12 - * "License"). You may not use this file except in compliance with the
206.13 - * License. You can obtain a copy of the License at
206.14 - * http://www.netbeans.org/cddl-gplv2.html
206.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
206.16 - * specific language governing permissions and limitations under the
206.17 - * License. When distributing the software, include this License Header
206.18 - * Notice in each file and include the License file at
206.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
206.20 - * particular file as subject to the "Classpath" exception as provided
206.21 - * by Sun in the GPL Version 2 section of the License file that
206.22 - * accompanied this code. If applicable, add the following below the
206.23 - * License Header, with the fields enclosed by brackets [] replaced by
206.24 - * your own identifying information:
206.25 - * "Portions Copyrighted [year] [name of copyright owner]"
206.26 - *
206.27 - * Contributor(s):
206.28 - *
206.29 - * The Original Software is the LaTeX module.
206.30 - * The Initial Developer of the Original Software is Jan Lahoda.
206.31 - * Portions created by Jan Lahoda_ are Copyright (C) 2002-2009.
206.32 - * All Rights Reserved.
206.33 - *
206.34 - * If you wish your version of this file to be governed by only the CDDL
206.35 - * or only the GPL Version 2, indicate your decision by adding
206.36 - * "[Contributor] elects to include this software in this distribution
206.37 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
206.38 - * single choice of license, a recipient has the option to distribute
206.39 - * your version of this file under either the CDDL, the GPL Version 2 or
206.40 - * to extend the choice of license to its licensees as provided above.
206.41 - * However, if you add GPL Version 2 code and therefore, elected the GPL
206.42 - * Version 2 license, then the option applies only if the new code is
206.43 - * made subject to such option by the copyright holder.
206.44 - *
206.45 - * Contributor(s): Jan Lahoda.
206.46 - */
206.47 -package org.netbeans.modules.jackpot30.help;
206.48 -
206.49 -import java.io.BufferedReader;
206.50 -import java.io.File;
206.51 -import java.io.FileReader;
206.52 -import java.io.FileWriter;
206.53 -import java.io.IOException;
206.54 -import java.io.PrintWriter;
206.55 -import java.util.HashMap;
206.56 -import java.util.Map;
206.57 -
206.58 -/**
206.59 - *
206.60 - * @author Jan Lahoda
206.61 - */
206.62 -public class CreateMap {
206.63 -
206.64 - public CreateMap() {}
206.65 -
206.66 - /**
206.67 - * @param args the command line arguments
206.68 - */
206.69 - public static void main(String[] args) throws IOException {
206.70 - if (args.length != 1) {
206.71 - System.err.println("Incorrect number of arguments, one argument containing the location of the base dir is required.");
206.72 - return ;
206.73 - }
206.74 -
206.75 - File baseDir = new File(args[0]);
206.76 -
206.77 - if (!baseDir.exists()) {
206.78 - System.err.println(baseDir.getAbsolutePath() + " does not exist.");
206.79 - return ;
206.80 - }
206.81 -
206.82 - if (!baseDir.isDirectory()) {
206.83 - System.err.println(baseDir.getAbsolutePath() + " is not a directory.");
206.84 - return ;
206.85 - }
206.86 -
206.87 - File in = new File(baseDir, "labels.pl");
206.88 - File out = new File(baseDir, "jackpot30-map.xml");
206.89 -
206.90 - Map<String, String> map = createMapFile(in, out);
206.91 -
206.92 - File outTOC = new File(baseDir, "jackpot30-toc.xml");
206.93 - File inTOC = new File(baseDir, "jackpot30-help.html");
206.94 -
206.95 - createTOC(inTOC, outTOC, map);
206.96 - }
206.97 -
206.98 - private static Map<String, String> createMapFile(File in, File out) throws IOException {
206.99 - BufferedReader input = new BufferedReader(new FileReader(in));
206.100 - PrintWriter output = new PrintWriter(new FileWriter(out));
206.101 - Map<String, String> map = new HashMap<String, String>();
206.102 -
206.103 - output.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
206.104 - output.println();
206.105 - output.println("<!DOCTYPE map");
206.106 - output.println(" PUBLIC \"-//Sun Microsystems Inc.//DTD JavaHelp Map Version 1.0//EN\"");
206.107 - output.println(" \"file:///home/lahvac/netbeans/netbeans/bin/nbuser/sampledir/javahelp/map_1_0.dtd\">");
206.108 - output.println("<!--This is the original DTD: \"http://java.sun.com/products/javahelp/map_1_0.dtd\"-->");
206.109 - output.println();
206.110 - output.println("<map version=\"1.0\">");
206.111 -
206.112 - output.println("<mapID target=\"jackpot30.default\" url=\"jackpot30-help.html\" />");
206.113 -
206.114 - String line = null;
206.115 - String actualKey = null;
206.116 -
206.117 - while ((line = input.readLine()) != null) {
206.118 - if (line.startsWith("$key")) {
206.119 - actualKey = line.split("/")[1];
206.120 - actualKey = "jackpot30." + actualKey.replace(':', '.');
206.121 - }
206.122 -
206.123 - if (line.startsWith("$external_labels")) {
206.124 - String url = line.split("\\|")[1];
206.125 -
206.126 - output.print("<mapID target=\"");
206.127 - output.print(actualKey);
206.128 - output.print("\" url=\"");
206.129 - output.print(url);
206.130 - output.println("\"/>");
206.131 -
206.132 - map.put(url, actualKey);
206.133 -
206.134 - actualKey = null;
206.135 - }
206.136 - }
206.137 -
206.138 - output.println("</map>");
206.139 - output.close();
206.140 - input.close();
206.141 -
206.142 - return map;
206.143 - }
206.144 -
206.145 - private static void createTOC(File in, File out, Map<String, String> map) throws IOException {
206.146 - BufferedReader input = new BufferedReader(new FileReader(in));
206.147 - PrintWriter output = new PrintWriter(new FileWriter(out));
206.148 -
206.149 - String line = null;
206.150 - boolean noStop = false;
206.151 -
206.152 - output.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
206.153 - output.println();
206.154 - output.println("<!DOCTYPE toc");
206.155 - output.println(" PUBLIC \"-//Sun Microsystems Inc.//DTD JavaHelp TOC Version 1.0//EN\"");
206.156 - output.println(" \"file:///home/lahvac/netbeans/netbeans/bin/nbuser/sampledir/javahelp/toc_1_0.dtd\">");
206.157 - output.println("<!--This is the original DTD: \"http://java.sun.com/products/javahelp/toc_1_0.dtd\"-->");
206.158 - output.println();
206.159 - output.println("<toc version=\"1.0\">");
206.160 -
206.161 - while ((line = input.readLine()) != null && line.indexOf("<!--Table of Child-Links-->") == (-1))
206.162 - ;
206.163 -
206.164 - output.println("<tocitem text=\"Jackpot 3.0 Support Help\" target=\"jackpot30.default\">");
206.165 - while ((line = input.readLine()) != null && line.indexOf("<!--End of Table of Child-Links-->") == (-1)) {
206.166 - if (line.startsWith("<UL ")) {
206.167 - noStop = true;
206.168 - continue;
206.169 - }
206.170 -
206.171 - if (line.indexOf("HREF=\"") != (-1)) {
206.172 - if (noStop) {
206.173 - noStop = false;
206.174 - } else {
206.175 - output.println("</tocitem>");
206.176 - }
206.177 -
206.178 - String file = line.split("\"")[1];
206.179 - String name = line.split(">")[1].split("<")[0];
206.180 -
206.181 - output.println("<tocitem text=\"" + name + "\" target=\"" + (map.get(file) != null ? map.get(file) : "test") + "\">");
206.182 -
206.183 - continue;
206.184 - }
206.185 -
206.186 - if (line.startsWith("</UL>") && !noStop) {
206.187 - output.println("</tocitem>");
206.188 - continue;
206.189 - }
206.190 - }
206.191 -
206.192 - output.println("</tocitem>");
206.193 -
206.194 - output.println("</toc>");
206.195 -
206.196 - output.close();
206.197 - input.close();
206.198 - }
206.199 -}
207.1 --- a/help/src/org/netbeans/modules/jackpot30/help/jackpot30-helpset.xml Fri Jan 27 13:35:56 2012 +0100
207.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
207.3 @@ -1,3 +0,0 @@
207.4 -<?xml version="1.0" encoding="UTF-8"?>
207.5 -<!DOCTYPE helpsetref PUBLIC "-//NetBeans//DTD JavaHelp Help Set Reference 1.0//EN" "http://www.netbeans.org/dtds/helpsetref-1_0.dtd">
207.6 -<helpsetref url="nbdocs:/org/netbeans/modules/jackpot30/help/docs/jackpot30-helpset.xml" />
208.1 --- a/help/src/org/netbeans/modules/jackpot30/help/layer.xml Fri Jan 27 13:35:56 2012 +0100
208.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
208.3 @@ -1,11 +0,0 @@
208.4 -<?xml version="1.0" encoding="UTF-8"?>
208.5 -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
208.6 -<filesystem>
208.7 - <folder name="Services">
208.8 - <folder name="JavaHelp">
208.9 - <file name="jackpot30-helpset.xml" url="jackpot30-helpset.xml">
208.10 - <attr name="position" intvalue="3456"/>
208.11 - </file>
208.12 - </folder>
208.13 - </folder>
208.14 -</filesystem>
209.1 --- a/hintsimpl/build.xml Fri Jan 27 13:35:56 2012 +0100
209.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
209.3 @@ -1,11 +0,0 @@
209.4 -<?xml version="1.0" encoding="UTF-8"?>
209.5 -<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
209.6 -<!-- for some information on what you could do (e.g. targets to override). -->
209.7 -<!-- If you delete this file and reopen the project it will be recreated. -->
209.8 -<project name="org.netbeans.modules.jackpot30.hintsimpl" default="netbeans" basedir=".">
209.9 - <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.hintsimpl.</description>
209.10 - <import file="nbproject/build-impl.xml"/>
209.11 - <import file="${suite.dir}/findbugs-import.xml"/>
209.12 - <target name="test-coverage" />
209.13 - <target name="coverage-report" />
209.14 -</project>
210.1 --- a/hintsimpl/manifest.mf Fri Jan 27 13:35:56 2012 +0100
210.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
210.3 @@ -1,7 +0,0 @@
210.4 -Manifest-Version: 1.0
210.5 -AutoUpdate-Show-In-Client: false
210.6 -OpenIDE-Module: org.netbeans.modules.jackpot30.hintsimpl
210.7 -OpenIDE-Module-Implementation-Version: 1
210.8 -OpenIDE-Module-Layer: org/netbeans/modules/jackpot30/hintsimpl/layer.xml
210.9 -OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/hintsimpl/Bundle.properties
210.10 -
211.1 --- a/hintsimpl/nbproject/build-impl.xml Fri Jan 27 13:35:56 2012 +0100
211.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
211.3 @@ -1,45 +0,0 @@
211.4 -<?xml version="1.0" encoding="UTF-8"?>
211.5 -<!--
211.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
211.7 -*** EDIT ../build.xml INSTEAD ***
211.8 --->
211.9 -<project name="org.netbeans.modules.jackpot30.hintsimpl-impl" basedir="..">
211.10 - <fail message="Please build using Ant 1.7.1 or higher.">
211.11 - <condition>
211.12 - <not>
211.13 - <antversion atleast="1.7.1"/>
211.14 - </not>
211.15 - </condition>
211.16 - </fail>
211.17 - <property file="nbproject/private/suite-private.properties"/>
211.18 - <property file="nbproject/suite.properties"/>
211.19 - <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
211.20 - <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
211.21 - <property file="${suite.dir}/nbproject/platform.properties"/>
211.22 - <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
211.23 - <attribute name="name"/>
211.24 - <attribute name="value"/>
211.25 - <sequential>
211.26 - <property name="@{name}" value="${@{value}}"/>
211.27 - </sequential>
211.28 - </macrodef>
211.29 - <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
211.30 - <attribute name="property"/>
211.31 - <attribute name="value"/>
211.32 - <sequential>
211.33 - <property name="@{property}" value="@{value}"/>
211.34 - </sequential>
211.35 - </macrodef>
211.36 - <property file="${user.properties.file}"/>
211.37 - <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
211.38 - <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
211.39 - <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
211.40 - <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
211.41 - <condition>
211.42 - <not>
211.43 - <contains string="${cluster.path.evaluated}" substring="platform"/>
211.44 - </not>
211.45 - </condition>
211.46 - </fail>
211.47 - <import file="${harness.dir}/build.xml"/>
211.48 -</project>
212.1 --- a/hintsimpl/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
212.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
212.3 @@ -1,8 +0,0 @@
212.4 -build.xml.data.CRC32=772824b9
212.5 -build.xml.script.CRC32=ef577a91
212.6 -build.xml.stylesheet.CRC32=79c3b980@1.28.0.7
212.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
212.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
212.9 -nbproject/build-impl.xml.data.CRC32=2dfd5d11
212.10 -nbproject/build-impl.xml.script.CRC32=9204f652
212.11 -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.47
213.1 --- a/hintsimpl/nbproject/project.properties Fri Jan 27 13:35:56 2012 +0100
213.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
213.3 @@ -1,4 +0,0 @@
213.4 -javac.source=1.5
213.5 -javac.compilerargs=-Xlint -Xlint:-serial
213.6 -project.license=cddl-netbeans-sun
213.7 -spec.version.base=1.16.0
214.1 --- a/hintsimpl/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
214.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
214.3 @@ -1,276 +0,0 @@
214.4 -<?xml version="1.0" encoding="UTF-8"?>
214.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
214.6 - <type>org.netbeans.modules.apisupport.project</type>
214.7 - <configuration>
214.8 - <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
214.9 - <code-name-base>org.netbeans.modules.jackpot30.hintsimpl</code-name-base>
214.10 - <suite-component/>
214.11 - <module-dependencies>
214.12 - <dependency>
214.13 - <code-name-base>org.jdesktop.layout</code-name-base>
214.14 - <build-prerequisite/>
214.15 - <compile-dependency/>
214.16 - <run-dependency>
214.17 - <release-version>1</release-version>
214.18 - <specification-version>1.7.0.103</specification-version>
214.19 - </run-dependency>
214.20 - </dependency>
214.21 - <dependency>
214.22 - <code-name-base>org.netbeans.api.java.classpath</code-name-base>
214.23 - <build-prerequisite/>
214.24 - <compile-dependency/>
214.25 - <run-dependency>
214.26 - <release-version>1</release-version>
214.27 - <specification-version>1.19</specification-version>
214.28 - </run-dependency>
214.29 - </dependency>
214.30 - <dependency>
214.31 - <code-name-base>org.netbeans.api.progress</code-name-base>
214.32 - <build-prerequisite/>
214.33 - <compile-dependency/>
214.34 - <run-dependency>
214.35 - <release-version>1</release-version>
214.36 - <specification-version>1.13.0.1</specification-version>
214.37 - </run-dependency>
214.38 - </dependency>
214.39 - <dependency>
214.40 - <code-name-base>org.netbeans.libs.javacapi</code-name-base>
214.41 - <build-prerequisite/>
214.42 - <compile-dependency/>
214.43 - <run-dependency>
214.44 - <specification-version>0.8.0.1</specification-version>
214.45 - </run-dependency>
214.46 - </dependency>
214.47 - <dependency>
214.48 - <code-name-base>org.netbeans.modules.editor</code-name-base>
214.49 - <build-prerequisite/>
214.50 - <compile-dependency/>
214.51 - <run-dependency>
214.52 - <release-version>3</release-version>
214.53 - <specification-version>1.42.0.3.9.2</specification-version>
214.54 - </run-dependency>
214.55 - </dependency>
214.56 - <dependency>
214.57 - <code-name-base>org.netbeans.modules.editor.guards</code-name-base>
214.58 - <build-prerequisite/>
214.59 - <compile-dependency/>
214.60 - <run-dependency>
214.61 - <release-version>1</release-version>
214.62 - <specification-version>1.3</specification-version>
214.63 - </run-dependency>
214.64 - </dependency>
214.65 - <dependency>
214.66 - <code-name-base>org.netbeans.modules.editor.lib</code-name-base>
214.67 - <build-prerequisite/>
214.68 - <compile-dependency/>
214.69 - <run-dependency>
214.70 - <release-version>1-3</release-version>
214.71 - <specification-version>1.38.0.9.2</specification-version>
214.72 - </run-dependency>
214.73 - </dependency>
214.74 - <dependency>
214.75 - <code-name-base>org.netbeans.modules.jackpot30.api</code-name-base>
214.76 - <build-prerequisite/>
214.77 - <compile-dependency/>
214.78 - <run-dependency>
214.79 - <specification-version>1.0</specification-version>
214.80 - </run-dependency>
214.81 - </dependency>
214.82 - <dependency>
214.83 - <code-name-base>org.netbeans.modules.java.editor</code-name-base>
214.84 - <run-dependency>
214.85 - <release-version>1</release-version>
214.86 - <specification-version>2.22</specification-version>
214.87 - </run-dependency>
214.88 - </dependency>
214.89 - <dependency>
214.90 - <code-name-base>org.netbeans.modules.java.hints</code-name-base>
214.91 - <build-prerequisite/>
214.92 - <compile-dependency/>
214.93 - <run-dependency>
214.94 - <release-version>1</release-version>
214.95 - <implementation-version/>
214.96 - </run-dependency>
214.97 - </dependency>
214.98 - <dependency>
214.99 - <code-name-base>org.netbeans.modules.java.lexer</code-name-base>
214.100 - <build-prerequisite/>
214.101 - <compile-dependency/>
214.102 - <run-dependency>
214.103 - <release-version>1</release-version>
214.104 - <specification-version>1.5</specification-version>
214.105 - </run-dependency>
214.106 - </dependency>
214.107 - <dependency>
214.108 - <code-name-base>org.netbeans.modules.java.source</code-name-base>
214.109 - <build-prerequisite/>
214.110 - <compile-dependency/>
214.111 - <run-dependency>
214.112 - <specification-version>0.53</specification-version>
214.113 - </run-dependency>
214.114 - </dependency>
214.115 - <dependency>
214.116 - <code-name-base>org.netbeans.modules.lexer</code-name-base>
214.117 - <build-prerequisite/>
214.118 - <compile-dependency/>
214.119 - <run-dependency>
214.120 - <release-version>2</release-version>
214.121 - <specification-version>1.30.0.1</specification-version>
214.122 - </run-dependency>
214.123 - </dependency>
214.124 - <dependency>
214.125 - <code-name-base>org.netbeans.modules.options.api</code-name-base>
214.126 - <build-prerequisite/>
214.127 - <compile-dependency/>
214.128 - <run-dependency>
214.129 - <release-version>1</release-version>
214.130 - <specification-version>1.12</specification-version>
214.131 - </run-dependency>
214.132 - </dependency>
214.133 - <dependency>
214.134 - <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
214.135 - <build-prerequisite/>
214.136 - <compile-dependency/>
214.137 - <run-dependency>
214.138 - <release-version>1</release-version>
214.139 - <specification-version>1.12.1</specification-version>
214.140 - </run-dependency>
214.141 - </dependency>
214.142 - <dependency>
214.143 - <code-name-base>org.netbeans.modules.projectapi</code-name-base>
214.144 - <build-prerequisite/>
214.145 - <compile-dependency/>
214.146 - <run-dependency>
214.147 - <release-version>1</release-version>
214.148 - <specification-version>1.24</specification-version>
214.149 - </run-dependency>
214.150 - </dependency>
214.151 - <dependency>
214.152 - <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
214.153 - <build-prerequisite/>
214.154 - <compile-dependency/>
214.155 - <run-dependency>
214.156 - <release-version>1</release-version>
214.157 - <specification-version>1.34.0.6</specification-version>
214.158 - </run-dependency>
214.159 - </dependency>
214.160 - <dependency>
214.161 - <code-name-base>org.netbeans.modules.sendopts</code-name-base>
214.162 - <build-prerequisite/>
214.163 - <compile-dependency/>
214.164 - <run-dependency>
214.165 - <release-version>2</release-version>
214.166 - <specification-version>2.4</specification-version>
214.167 - </run-dependency>
214.168 - </dependency>
214.169 - <dependency>
214.170 - <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
214.171 - <build-prerequisite/>
214.172 - <compile-dependency/>
214.173 - <run-dependency>
214.174 - <release-version>0-1</release-version>
214.175 - <specification-version>1.7.0.7.2</specification-version>
214.176 - </run-dependency>
214.177 - </dependency>
214.178 - <dependency>
214.179 - <code-name-base>org.netbeans.spi.tasklist</code-name-base>
214.180 - <build-prerequisite/>
214.181 - <compile-dependency/>
214.182 - <run-dependency>
214.183 - <release-version>1</release-version>
214.184 - <specification-version>1.4.0.1</specification-version>
214.185 - </run-dependency>
214.186 - </dependency>
214.187 - <dependency>
214.188 - <code-name-base>org.openide.awt</code-name-base>
214.189 - <build-prerequisite/>
214.190 - <compile-dependency/>
214.191 - <run-dependency>
214.192 - <specification-version>7.7.0.1</specification-version>
214.193 - </run-dependency>
214.194 - </dependency>
214.195 - <dependency>
214.196 - <code-name-base>org.openide.dialogs</code-name-base>
214.197 - <build-prerequisite/>
214.198 - <compile-dependency/>
214.199 - <run-dependency>
214.200 - <specification-version>7.10</specification-version>
214.201 - </run-dependency>
214.202 - </dependency>
214.203 - <dependency>
214.204 - <code-name-base>org.openide.filesystems</code-name-base>
214.205 - <build-prerequisite/>
214.206 - <compile-dependency/>
214.207 - <run-dependency>
214.208 - <specification-version>7.21.0.1.1</specification-version>
214.209 - </run-dependency>
214.210 - </dependency>
214.211 - <dependency>
214.212 - <code-name-base>org.openide.loaders</code-name-base>
214.213 - <build-prerequisite/>
214.214 - <compile-dependency/>
214.215 - <run-dependency>
214.216 - <specification-version>7.5</specification-version>
214.217 - </run-dependency>
214.218 - </dependency>
214.219 - <dependency>
214.220 - <code-name-base>org.openide.nodes</code-name-base>
214.221 - <build-prerequisite/>
214.222 - <compile-dependency/>
214.223 - <run-dependency>
214.224 - <specification-version>7.9.0.1</specification-version>
214.225 - </run-dependency>
214.226 - </dependency>
214.227 - <dependency>
214.228 - <code-name-base>org.openide.text</code-name-base>
214.229 - <build-prerequisite/>
214.230 - <compile-dependency/>
214.231 - <run-dependency>
214.232 - <specification-version>6.22</specification-version>
214.233 - </run-dependency>
214.234 - </dependency>
214.235 - <dependency>
214.236 - <code-name-base>org.openide.util</code-name-base>
214.237 - <build-prerequisite/>
214.238 - <compile-dependency/>
214.239 - <run-dependency>
214.240 - <specification-version>7.22.0.1</specification-version>
214.241 - </run-dependency>
214.242 - </dependency>
214.243 - <dependency>
214.244 - <code-name-base>org.openide.windows</code-name-base>
214.245 - <build-prerequisite/>
214.246 - <compile-dependency/>
214.247 - <run-dependency>
214.248 - <specification-version>6.26</specification-version>
214.249 - </run-dependency>
214.250 - </dependency>
214.251 - </module-dependencies>
214.252 - <test-dependencies>
214.253 - <test-type>
214.254 - <name>unit</name>
214.255 - <test-dependency>
214.256 - <code-name-base>org.netbeans.libs.junit4</code-name-base>
214.257 - <compile-dependency/>
214.258 - </test-dependency>
214.259 - <test-dependency>
214.260 - <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
214.261 - <recursive/>
214.262 - <compile-dependency/>
214.263 - </test-dependency>
214.264 - <test-dependency>
214.265 - <code-name-base>org.netbeans.modules.java.hints.declarative.test</code-name-base>
214.266 - <recursive/>
214.267 - <compile-dependency/>
214.268 - </test-dependency>
214.269 - <test-dependency>
214.270 - <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
214.271 - <recursive/>
214.272 - <compile-dependency/>
214.273 - </test-dependency>
214.274 - </test-type>
214.275 - </test-dependencies>
214.276 - <public-packages/>
214.277 - </data>
214.278 - </configuration>
214.279 -</project>
215.1 --- a/hintsimpl/nbproject/suite.properties Fri Jan 27 13:35:56 2012 +0100
215.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
215.3 @@ -1,1 +0,0 @@
215.4 -suite.dir=${basedir}/..
216.1 --- a/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/Bundle.properties Fri Jan 27 13:35:56 2012 +0100
216.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
216.3 @@ -1,38 +0,0 @@
216.4 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
216.5 -#
216.6 -# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
216.7 -#
216.8 -# The contents of this file are subject to the terms of either the GNU
216.9 -# General Public License Version 2 only ("GPL") or the Common
216.10 -# Development and Distribution License("CDDL") (collectively, the
216.11 -# "License"). You may not use this file except in compliance with the
216.12 -# License. You can obtain a copy of the License at
216.13 -# http://www.netbeans.org/cddl-gplv2.html
216.14 -# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
216.15 -# specific language governing permissions and limitations under the
216.16 -# License. When distributing the software, include this License Header
216.17 -# Notice in each file and include the License file at
216.18 -# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
216.19 -# particular file as subject to the "Classpath" exception as provided
216.20 -# by Sun in the GPL Version 2 section of the License file that
216.21 -# accompanied this code. If applicable, add the following below the
216.22 -# License Header, with the fields enclosed by brackets [] replaced by
216.23 -# your own identifying information:
216.24 -# "Portions Copyrighted [year] [name of copyright owner]"
216.25 -#
216.26 -# If you wish your version of this file to be governed by only the CDDL
216.27 -# or only the GPL Version 2, indicate your decision by adding
216.28 -# "[Contributor] elects to include this software in this distribution
216.29 -# under the [CDDL or GPL Version 2] license." If you do not indicate a
216.30 -# single choice of license, a recipient has the option to distribute
216.31 -# your version of this file under either the CDDL, the GPL Version 2 or
216.32 -# to extend the choice of license to its licensees as provided above.
216.33 -# However, if you add GPL Version 2 code and therefore, elected the GPL
216.34 -# Version 2 license, then the option applies only if the new code is
216.35 -# made subject to such option by the copyright holder.
216.36 -#
216.37 -# Contributor(s):
216.38 -#
216.39 -# Portions Copyrighted 2009 Sun Microsystems, Inc.
216.40 -
216.41 -OpenIDE-Module-Name=Hints Impl
217.1 --- a/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/abstract-document.hint Fri Jan 27 13:35:56 2012 +0100
217.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
217.3 @@ -1,37 +0,0 @@
217.4 -{ $1$;
217.5 -$0.readLock();
217.6 -$stmts$;
217.7 -$0.readUnlock();
217.8 -$2$;
217.9 -}
217.10 -:: $0 instanceof javax.swing.text.AbstractDocument
217.11 -=>
217.12 -{ $1$;
217.13 -$0.readLock();
217.14 -try {
217.15 - $stmts$;
217.16 -} finally {
217.17 - $0.readUnlock();
217.18 -}
217.19 -$2$;
217.20 -}
217.21 -;;
217.22 -
217.23 -{ $1$;
217.24 -$0.writeLock();
217.25 -$stmts$;
217.26 -$0.writeUnlock();
217.27 -$2$;
217.28 -}
217.29 -:: $0 instanceof javax.swing.text.AbstractDocument
217.30 -=>
217.31 -{ $1$;
217.32 -$0.writeLock();
217.33 -try {
217.34 - $stmts$;
217.35 -} finally {
217.36 - $0.writeUnlock();
217.37 -}
217.38 -$2$;
217.39 -}
217.40 -;;
218.1 --- a/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/assert2if.hint Fri Jan 27 13:35:56 2012 +0100
218.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
218.3 @@ -1,4 +0,0 @@
218.4 -'Use of assert':
218.5 -assert $1 : $2; :: $1 instanceof boolean && $2 instanceof java.lang.Object
218.6 - => if (!$1) throw new IllegalStateException($2);
218.7 - ;;
219.1 --- a/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/double-checked-locking.hint Fri Jan 27 13:35:56 2012 +0100
219.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
219.3 @@ -1,14 +0,0 @@
219.4 -'Double checked locking':
219.5 -if ($var == null) {
219.6 - synchronized ($lock) {
219.7 - if ($var == null) {
219.8 - $s2$;
219.9 - }
219.10 - }
219.11 -} :: !hasModifier($var, Modifier.VOLATILE)
219.12 -=>
219.13 -synchronized ($lock) {
219.14 - if ($var == null) {
219.15 - $s2$;
219.16 - }
219.17 -};;
220.1 --- a/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/jackpot/AddConditionals.hint Fri Jan 27 13:35:56 2012 +0100
220.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
220.3 @@ -1,7 +0,0 @@
220.4 -if ($a) return $b; else return $c; => return $a ? $b : $c; ;;
220.5 -if ($a) $ret = $b; else $ret = $c; => $ret = $a ? $b : $c; ;;
220.6 -if ($a) $b=$c; else if ($a2) $b = $d; => $b = $a ? $c : $a2 ? $d : $b; ;;
220.7 -$a ? ($T)$b : ($T)$c => ($T)($a ? $b : $c) ;;
220.8 -//the following hint causes BulkSearch to be extremelly slow:
220.9 -//{ $p$; $T $v; if($a) $v = $b; else $v = $c; $q$; } => { $p$; $T $v = $a ? $b : $c; $q$; } ;;
220.10 -
221.1 --- a/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/jackpot/EnhancedFor.hint Fri Jan 27 13:35:56 2012 +0100
221.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
221.3 @@ -1,43 +0,0 @@
221.4 -'Convert to Enhanced For':
221.5 -for(int $i = 0; $i < $array.length; $i++) {
221.6 - $T $var = ($T) $array[$i];
221.7 - $stmts$;
221.8 -} :: !referencedIn($i, $stmts$) && sourceVersionGE(SourceVersion.RELEASE_5)
221.9 -=>
221.10 -for($T $var : $array) {
221.11 - $stmts$;
221.12 -}
221.13 -;;
221.14 -
221.15 -'Convert to Enhanced For':
221.16 -for(int $i = 0; $i < $array.length; $i++) {
221.17 - $T $var = $array[$i];
221.18 - $stmts$;
221.19 -} :: !referencedIn($i, $stmts$) && sourceVersionGE(SourceVersion.RELEASE_5)
221.20 -=>
221.21 -for($T $var : $array) {
221.22 - $stmts$;
221.23 -}
221.24 -;;
221.25 -
221.26 -'Convert to Enhanced For':
221.27 -for($I $i = $iterable.iterator(); $i.hasNext();) {
221.28 - $T $var = ($T)$i.next();
221.29 - $stmts$;
221.30 -} :: $iterable instanceof java.lang.Iterable && !referencedIn($i, $stmts$) && sourceVersionGE(SourceVersion.RELEASE_5)
221.31 -=>
221.32 -for($T $var : $iterable) {
221.33 - $stmts$;
221.34 -}
221.35 -;;
221.36 -
221.37 -'Convert to Enhanced For':
221.38 -for($I $i = $iterable.iterator(); $i.hasNext();) {
221.39 - $T $var = $i.next();
221.40 - $stmts$;
221.41 -} :: $iterable instanceof java.lang.Iterable && !referencedIn($i, $stmts$) && sourceVersionGE(SourceVersion.RELEASE_5)
221.42 -=>
221.43 -for($T $var : $iterable) {
221.44 - $stmts$;
221.45 -}
221.46 -;;
222.1 --- a/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/jdk7/Bundle.properties Fri Jan 27 13:35:56 2012 +0100
222.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
222.3 @@ -1,7 +0,0 @@
222.4 -DN_org.netbeans.modules.jackpot30.hintsimpl.jdk7.ConvertToDiamondBulkHint=Convert to diamond bulk hint
222.5 -DESC_org.netbeans.modules.jackpot30.hintsimpl.jdk7.ConvertToDiamondBulkHint=Convert to diamond bulk hint
222.6 -DN_jdk7_upgrade=To JDK7
222.7 -DN_java.util.Objects=Convert to use java.util.Objects.{equals,hashCode}
222.8 -DESC_java.util.Objects=Convert to use java.util.Objects.{equals,hashCode}
222.9 -DN_org.netbeans.modules.jackpot30.hintsimpl.jdk7.SafeConvertToSwitchString=Convert to switch over Strings ignoring the eq operator
222.10 -DESC_org.netbeans.modules.jackpot30.hintsimpl.jdk7.SafeConvertToSwitchString=Convert to switch over Strings, ignoring the == operator
223.1 --- a/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/jdk7/SafeConvertToSwitchString.java Fri Jan 27 13:35:56 2012 +0100
223.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
223.3 @@ -1,80 +0,0 @@
223.4 -/*
223.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
223.6 - *
223.7 - * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
223.8 - *
223.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
223.10 - * Other names may be trademarks of their respective owners.
223.11 - *
223.12 - * The contents of this file are subject to the terms of either the GNU
223.13 - * General Public License Version 2 only ("GPL") or the Common
223.14 - * Development and Distribution License("CDDL") (collectively, the
223.15 - * "License"). You may not use this file except in compliance with the
223.16 - * License. You can obtain a copy of the License at
223.17 - * http://www.netbeans.org/cddl-gplv2.html
223.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
223.19 - * specific language governing permissions and limitations under the
223.20 - * License. When distributing the software, include this License Header
223.21 - * Notice in each file and include the License file at
223.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
223.23 - * particular file as subject to the "Classpath" exception as provided
223.24 - * by Oracle in the GPL Version 2 section of the License file that
223.25 - * accompanied this code. If applicable, add the following below the
223.26 - * License Header, with the fields enclosed by brackets [] replaced by
223.27 - * your own identifying information:
223.28 - * "Portions Copyrighted [year] [name of copyright owner]"
223.29 - *
223.30 - * If you wish your version of this file to be governed by only the CDDL
223.31 - * or only the GPL Version 2, indicate your decision by adding
223.32 - * "[Contributor] elects to include this software in this distribution
223.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
223.34 - * single choice of license, a recipient has the option to distribute
223.35 - * your version of this file under either the CDDL, the GPL Version 2 or
223.36 - * to extend the choice of license to its licensees as provided above.
223.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
223.38 - * Version 2 license, then the option applies only if the new code is
223.39 - * made subject to such option by the copyright holder.
223.40 - *
223.41 - * Contributor(s):
223.42 - *
223.43 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
223.44 - */
223.45 -
223.46 -package org.netbeans.modules.jackpot30.hintsimpl.jdk7;
223.47 -
223.48 -import java.util.List;
223.49 -import java.util.prefs.Preferences;
223.50 -import org.netbeans.modules.java.hints.jackpot.code.spi.Hint;
223.51 -import org.netbeans.modules.java.hints.jackpot.code.spi.TriggerPattern;
223.52 -import org.netbeans.modules.java.hints.jackpot.impl.RulesManager;
223.53 -import org.netbeans.modules.java.hints.jackpot.spi.HintContext;
223.54 -import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata.Options;
223.55 -import org.netbeans.modules.java.hints.jdk.ConvertToStringSwitch;
223.56 -import org.netbeans.modules.java.hints.options.HintsSettings;
223.57 -import org.netbeans.spi.editor.hints.ErrorDescription;
223.58 -
223.59 -/**
223.60 - *
223.61 - * @author lahvac
223.62 - */
223.63 -@Hint(category="rules15",enabled=false, options=Options.NON_GUI)
223.64 -public class SafeConvertToSwitchString {
223.65 -
223.66 - static final String KEY_ALSO_EQ = "also-equals";
223.67 - static final boolean DEF_ALSO_EQ = true;
223.68 -
223.69 - @TriggerPattern(value="if ($cond) $body; else $else;")
223.70 - public static List<ErrorDescription> hint(HintContext ctx) {
223.71 - Preferences prefs = RulesManager.getPreferences("org.netbeans.modules.java.hints.jdk.ConvertToStringSwitch", HintsSettings.getCurrentProfileId());
223.72 - boolean old = prefs.getBoolean(KEY_ALSO_EQ, DEF_ALSO_EQ);
223.73 -
223.74 - prefs.putBoolean(KEY_ALSO_EQ, false);
223.75 -
223.76 - try {
223.77 - return ConvertToStringSwitch.hint(ctx);
223.78 - } finally {
223.79 - prefs.putBoolean(KEY_ALSO_EQ, old);
223.80 - }
223.81 - }
223.82 -
223.83 -}
224.1 --- a/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/jdk7/java.util.Objects.hint Fri Jan 27 13:35:56 2012 +0100
224.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
224.3 @@ -1,99 +0,0 @@
224.4 -<!hint="java.util.Objects">
224.5 -//java.util.Objects.equals:
224.6 -($1 == null) ? ($2 != null) : !$1.equals($2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
224.7 -=>java.util.Objects.equals($1, $2)
224.8 -;;
224.9 -
224.10 -(null == $1) ? ($2 != null) : !$1.equals($2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
224.11 -=>java.util.Objects.equals($1, $2)
224.12 -;;
224.13 -
224.14 -($1 == null) ? (null != $2) : !$1.equals($2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
224.15 -=>java.util.Objects.equals($1, $2)
224.16 -;;
224.17 -
224.18 -(null == $1) ? (null != $2) : !$1.equals($2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
224.19 -=>java.util.Objects.equals($1, $2)
224.20 -;;
224.21 -
224.22 -$1 != $2 && ($1 == null || !$1.equals($2)) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
224.23 -=>java.util.Objects.equals($1, $2)
224.24 -;;
224.25 -
224.26 -$1 != $2 && (null == $1 || !$1.equals($2)) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
224.27 -=>java.util.Objects.equals($1, $2)
224.28 -;;
224.29 -
224.30 -($1 == null) ? ($2 == null) : $1.equals($2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
224.31 -=>java.util.Objects.equals($1, $2)
224.32 -;;
224.33 -
224.34 -(null == $1) ? ($2 == null) : $1.equals($2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
224.35 -=>java.util.Objects.equals($1, $2)
224.36 -;;
224.37 -
224.38 -($1 == null) ? (null == $2) : $1.equals($2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
224.39 -=>java.util.Objects.equals($1, $2)
224.40 -;;
224.41 -
224.42 -(null == $1) ? (null == $2) : $1.equals($2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
224.43 -=>java.util.Objects.equals($1, $2)
224.44 -;;
224.45 -
224.46 -($1 != null) ? $1.equals($2) : ($2 == null) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
224.47 -=>java.util.Objects.equals($1, $2)
224.48 -;;
224.49 -
224.50 -(null != $1) ? $1.equals($2) : ($2 == null) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
224.51 -=>java.util.Objects.equals($1, $2)
224.52 -;;
224.53 -
224.54 -($1 != null) ? $1.equals($2) : (null == $2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
224.55 -=>java.util.Objects.equals($1, $2)
224.56 -;;
224.57 -
224.58 -(null != $1) ? $1.equals($2) : (null == $2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
224.59 -=>java.util.Objects.equals($1, $2)
224.60 -;;
224.61 -
224.62 -$1 == $2 && ($1 == null || $1.equals($2)) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
224.63 -=>java.util.Objects.equals($1, $2)
224.64 -;;
224.65 -
224.66 -$1 == $2 && (null == $1 || $1.equals($2)) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
224.67 -=>java.util.Objects.equals($1, $2)
224.68 -;;
224.69 -
224.70 -//java.util.Objects.hashCode:
224.71 -$1 != null ? $1.hashCode() : 0 :: $1 instanceof java.lang.Object
224.72 -=>java.util.Objects.hashCode($1)
224.73 -;;
224.74 -
224.75 -null != $1 ? $1.hashCode() : 0 :: $1 instanceof java.lang.Object
224.76 -=>java.util.Objects.hashCode($1)
224.77 -;;
224.78 -
224.79 -$1 == null ? 0 : $1.hashCode() :: $1 instanceof java.lang.Object
224.80 -=>java.util.Objects.hashCode($1)
224.81 -;;
224.82 -
224.83 -null == $1 ? 0 : $1.hashCode() :: $1 instanceof java.lang.Object
224.84 -=>java.util.Objects.hashCode($1)
224.85 -;;
224.86 -
224.87 -//java.util.Objects.toString:
224.88 -$1 != null ? $1.toString() : $def :: $1 instanceof java.lang.Object
224.89 -=>java.util.Objects.toString($1, $def)
224.90 -;;
224.91 -
224.92 -null != $1 ? $1.toString() : $def :: $1 instanceof java.lang.Object
224.93 -=>java.util.Objects.toString($1, $def)
224.94 -;;
224.95 -
224.96 -$1 == null ? $def : $1.hashCode() :: $1 instanceof java.lang.Object
224.97 -=>java.util.Objects.hashCode($1, $def)
224.98 -;;
224.99 -
224.100 -null == $1 ? $def : $1.hashCode() :: $1 instanceof java.lang.Object
224.101 -=>java.util.Objects.hashCode($1, $def)
224.102 -;;
225.1 --- a/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/jdk7/jdk7.upgrade Fri Jan 27 13:35:56 2012 +0100
225.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
225.3 @@ -1,12 +0,0 @@
225.4 -{
225.5 - "upgradeName" : "jdk7_upgrade",
225.6 - "bundle" : "org/netbeans/modules/jackpot30/hintsimpl/jdk7/Bundle",
225.7 - "hints" : [
225.8 - "org.netbeans.modules.jackpot30.hintsimpl.jdk7.ConvertToDiamondBulkHint",
225.9 - "org.netbeans.modules.java.hints.jdk.ConvertToStringSwitch",
225.10 - "org.netbeans.modules.java.hints.jdk.ConvertToARM",
225.11 - "org.netbeans.modules.java.hints.jdk.JoinCatches",
225.12 - "org.netbeans.modules.java.hints.jdk.UseSpecificCatch",
225.13 - "java.util.Objects"
225.14 - ]
225.15 -}
226.1 --- a/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/layer.xml Fri Jan 27 13:35:56 2012 +0100
226.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
226.3 @@ -1,63 +0,0 @@
226.4 -<?xml version="1.0" encoding="UTF-8"?>
226.5 -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.0//EN" "http://www.netbeans.org/dtds/filesystem-1_0.dtd">
226.6 -<!--
226.7 -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
226.8 -
226.9 -Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
226.10 -
226.11 -
226.12 -The contents of this file are subject to the terms of either the GNU
226.13 -General Public License Version 2 only ("GPL") or the Common
226.14 -Development and Distribution License("CDDL") (collectively, the
226.15 -"License"). You may not use this file except in compliance with the
226.16 -License. You can obtain a copy of the License at
226.17 -http://www.netbeans.org/cddl-gplv2.html
226.18 -or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
226.19 -specific language governing permissions and limitations under the
226.20 -License. When distributing the software, include this License Header
226.21 -Notice in each file and include the License file at
226.22 -nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
226.23 -particular file as subject to the "Classpath" exception as provided
226.24 -by Sun in the GPL Version 2 section of the License file that
226.25 -accompanied this code. If applicable, add the following below the
226.26 -License Header, with the fields enclosed by brackets [] replaced by
226.27 -your own identifying information:
226.28 -"Portions Copyrighted [year] [name of copyright owner]"
226.29 -
226.30 -Contributor(s):
226.31 -
226.32 -The Original Software is NetBeans. The Initial Developer of the Original
226.33 -Software is Sun Microsystems, Inc. Portions Copyright 2009-2010 Sun
226.34 -Microsystems, Inc. All Rights Reserved.
226.35 -
226.36 -If you wish your version of this file to be governed by only the CDDL
226.37 -or only the GPL Version 2, indicate your decision by adding
226.38 -"[Contributor] elects to include this software in this distribution
226.39 -under the [CDDL or GPL Version 2] license." If you do not indicate a
226.40 -single choice of license, a recipient has the option to distribute
226.41 -your version of this file under either the CDDL, the GPL Version 2 or
226.42 -to extend the choice of license to its licensees as provided above.
226.43 -However, if you add GPL Version 2 code and therefore, elected the GPL
226.44 -Version 2 license, then the option applies only if the new code is
226.45 -made subject to such option by the copyright holder.
226.46 --->
226.47 -<filesystem>
226.48 -
226.49 - <folder name="org-netbeans-modules-java-hints">
226.50 - <folder name="declarative">
226.51 - <file name="Bundle.properties" url="jdk7/Bundle.properties" /> <!--XXX-->
226.52 - <file name="assert2if.hint" url="assert2if.hint" />
226.53 - <file name="variable-decl-assignment.hint" url="variable-decl-assignment.hint" />
226.54 - <file name="double-checked-locking.hint" url="double-checked-locking.hint" />
226.55 - <file name="sync-on-non-final.hint" url="sync-on-non-final.hint" />
226.56 - <file name="abstract-document.hint" url="abstract-document.hint" />
226.57 - <file name="AddConditionals.hint" url="jackpot/AddConditionals.hint" />
226.58 - <file name="EnhancedFor.hint" url="jackpot/EnhancedFor.hint" />
226.59 - <file name="java.util.Objects.hint" url="jdk7/java.util.Objects.hint" />
226.60 - </folder>
226.61 - <folder name="upgrades">
226.62 - <file name="jdk7.upgrade" url="jdk7/jdk7.upgrade" />
226.63 - </folder>
226.64 - </folder>
226.65 -
226.66 -</filesystem>
227.1 --- a/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/sync-on-non-final.hint Fri Jan 27 13:35:56 2012 +0100
227.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
227.3 @@ -1,5 +0,0 @@
227.4 -'Synchronizing on non-final field':
227.5 -synchronized($var) {
227.6 - $stmts$;
227.7 -} :: !hasModifier($var, Modifier.FINAL) && elementKindMatches($var, ElementKind.FIELD)
227.8 -;;
228.1 --- a/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/variable-decl-assignment.hint Fri Jan 27 13:35:56 2012 +0100
228.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
228.3 @@ -1,4 +0,0 @@
228.4 -'Separated variable declaration and assignment':
228.5 -{ $1 $2; $2 = $3; }
228.6 - => { $1 $2 = $3; }
228.7 - ;;
229.1 --- a/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/wrong-string-comparison.hint Fri Jan 27 13:35:56 2012 +0100
229.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
229.3 @@ -1,31 +0,0 @@
229.4 -'Wrong string comparison':
229.5 -$left == $right :: $left instanceof java.lang.String
229.6 - && $right instanceof java.lang.String
229.7 - && !isNullLiteral($left)
229.8 - && !isNullLiteral($right)
229.9 -=>$left == null ? $right == null : $left.equals($right)
229.10 -=>$left.equals($right)
229.11 -;;
229.12 -
229.13 -'Wrong string comparison':
229.14 -$left != $right :: $left instanceof java.lang.String
229.15 - && $right instanceof java.lang.String
229.16 - && !isNullLiteral($left)
229.17 - && !isNullLiteral($right)
229.18 - && !acceptGenerated($left, $right)
229.19 -=>!($left == null ? $right == null : $left.equals($right))
229.20 -=>!$left.equals($right)
229.21 -;;
229.22 -
229.23 -<?
229.24 -private boolean acceptGenerated(Variable left, Variable right) {
229.25 - Variable parent = left;
229.26 -
229.27 - while ((parent = context.parent(parent)) != null) {
229.28 - if (matcher.matches(parent, "$left != $right && ($left == null || $left.equals($right))"))
229.29 - return true;
229.30 - }
229.31 -
229.32 - return false;
229.33 -}
229.34 -?>
230.1 --- a/hintsimpl/test/unit/src/org/netbeans/modules/jackpot30/hintsimpl/HintsTest.java Fri Jan 27 13:35:56 2012 +0100
230.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
230.3 @@ -1,55 +0,0 @@
230.4 -/*
230.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
230.6 - *
230.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
230.8 - *
230.9 - * The contents of this file are subject to the terms of either the GNU
230.10 - * General Public License Version 2 only ("GPL") or the Common
230.11 - * Development and Distribution License("CDDL") (collectively, the
230.12 - * "License"). You may not use this file except in compliance with the
230.13 - * License. You can obtain a copy of the License at
230.14 - * http://www.netbeans.org/cddl-gplv2.html
230.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
230.16 - * specific language governing permissions and limitations under the
230.17 - * License. When distributing the software, include this License Header
230.18 - * Notice in each file and include the License file at
230.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
230.20 - * particular file as subject to the "Classpath" exception as provided
230.21 - * by Sun in the GPL Version 2 section of the License file that
230.22 - * accompanied this code. If applicable, add the following below the
230.23 - * License Header, with the fields enclosed by brackets [] replaced by
230.24 - * your own identifying information:
230.25 - * "Portions Copyrighted [year] [name of copyright owner]"
230.26 - *
230.27 - * If you wish your version of this file to be governed by only the CDDL
230.28 - * or only the GPL Version 2, indicate your decision by adding
230.29 - * "[Contributor] elects to include this software in this distribution
230.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
230.31 - * single choice of license, a recipient has the option to distribute
230.32 - * your version of this file under either the CDDL, the GPL Version 2 or
230.33 - * to extend the choice of license to its licensees as provided above.
230.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
230.35 - * Version 2 license, then the option applies only if the new code is
230.36 - * made subject to such option by the copyright holder.
230.37 - *
230.38 - * Contributor(s):
230.39 - *
230.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
230.41 - */
230.42 -
230.43 -package org.netbeans.modules.jackpot30.hintsimpl;
230.44 -
230.45 -import junit.framework.TestSuite;
230.46 -import org.netbeans.modules.java.hints.declarative.test.api.DeclarativeHintsTestBase;
230.47 -
230.48 -/**
230.49 - *
230.50 - * @author lahvac
230.51 - */
230.52 -public class HintsTest extends DeclarativeHintsTestBase {
230.53 -
230.54 - public static TestSuite suite() {
230.55 - return suite(HintsTest.class);
230.56 - }
230.57 -
230.58 -}
231.1 --- a/hintsimpl/test/unit/src/org/netbeans/modules/jackpot30/hintsimpl/abstract-document.test Fri Jan 27 13:35:56 2012 +0100
231.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
231.3 @@ -1,46 +0,0 @@
231.4 -%%TestCase simple-readlock
231.5 -package test;
231.6 -import javax.swing.text.AbstractDocument;
231.7 -public class Test {
231.8 - private void test(AbstractDocument d) {
231.9 - d.readLock();
231.10 - System.err.println(d.getText(0, d.getLength()));
231.11 - d.readUnlock();
231.12 - }
231.13 -}
231.14 -%%=>
231.15 -package test;
231.16 -import javax.swing.text.AbstractDocument;
231.17 -public class Test {
231.18 - private void test(AbstractDocument d) {
231.19 - d.readLock();
231.20 - try {
231.21 - System.err.println(d.getText(0, d.getLength()));
231.22 - } finally {
231.23 - d.readUnlock();
231.24 - }
231.25 - }
231.26 -}
231.27 -%%TestCase simple-writelock
231.28 -package test;
231.29 -import javax.swing.text.AbstractDocument;
231.30 -public class Test {
231.31 - private void test(AbstractDocument d) {
231.32 - d.writeLock();
231.33 - System.err.println(d.getText(0, d.getLength()));
231.34 - d.writeUnlock();
231.35 - }
231.36 -}
231.37 -%%=>
231.38 -package test;
231.39 -import javax.swing.text.AbstractDocument;
231.40 -public class Test {
231.41 - private void test(AbstractDocument d) {
231.42 - d.writeLock();
231.43 - try {
231.44 - System.err.println(d.getText(0, d.getLength()));
231.45 - } finally {
231.46 - d.writeUnlock();
231.47 - }
231.48 - }
231.49 -}
232.1 --- a/hintsimpl/test/unit/src/org/netbeans/modules/jackpot30/hintsimpl/double-checked-locking.test Fri Jan 27 13:35:56 2012 +0100
232.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
232.3 @@ -1,46 +0,0 @@
232.4 -%%TestCase simple
232.5 -package test;
232.6 -public class Test {
232.7 - private static Object TEST;
232.8 - public static Object get() {
232.9 - if (TEST == null) {
232.10 - synchronized (Test.class) {
232.11 - if (TEST == null) {
232.12 - TEST = new Object();
232.13 - }
232.14 - }
232.15 - }
232.16 -
232.17 - return TEST;
232.18 - }
232.19 -}
232.20 -%%=>
232.21 -package test;
232.22 -public class Test {
232.23 - private static Object TEST;
232.24 - public static Object get() {
232.25 - synchronized (Test.class) {
232.26 - if (TEST == null) {
232.27 - TEST = new Object();
232.28 - }
232.29 - }
232.30 -
232.31 - return TEST;
232.32 - }
232.33 -}
232.34 -%%TestCase volatile
232.35 -package test;
232.36 -public class Test {
232.37 - private static volatile Object TEST;
232.38 - public static Object get() {
232.39 - if (TEST == null) {
232.40 - synchronized (Test.class) {
232.41 - if (TEST == null) {
232.42 - TEST = new Object();
232.43 - }
232.44 - }
232.45 - }
232.46 -
232.47 - return TEST;
232.48 - }
232.49 -}
233.1 --- a/hintsimpl/test/unit/src/org/netbeans/modules/jackpot30/hintsimpl/jackpot/AddConditionals.test Fri Jan 27 13:35:56 2012 +0100
233.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
233.3 @@ -1,87 +0,0 @@
233.4 -%%TestCase simple-return
233.5 -package test;
233.6 -public class Test {
233.7 - public int test(boolean b) {
233.8 - if (b)
233.9 - return 1;
233.10 - else
233.11 - return 2;
233.12 - }
233.13 -}
233.14 -%%=>
233.15 -package test;
233.16 -public class Test {
233.17 - public int test(boolean b) {
233.18 - return b ? 1 : 2;
233.19 - }
233.20 -}
233.21 -%%TestCase blocks-return
233.22 -package test;
233.23 -public class Test {
233.24 - public int test(boolean b) {
233.25 - if (b) {
233.26 - return 1;
233.27 - } else {
233.28 - return 2;
233.29 - }
233.30 - }
233.31 -}
233.32 -%%=>
233.33 -package test;
233.34 -public class Test {
233.35 - public int test(boolean b) {
233.36 - return b ? 1 : 2;
233.37 - }
233.38 -}
233.39 -%%TestCase simple-assignment
233.40 -package test;
233.41 -public class Test {
233.42 - public void test(boolean b) {
233.43 - int q = 3;
233.44 - if (b)
233.45 - q = 1;
233.46 - else
233.47 - q = 2;
233.48 - }
233.49 -}
233.50 -%%=>
233.51 -package test;
233.52 -public class Test {
233.53 - public void test(boolean b) {
233.54 - int q = 3;
233.55 - q = b ? 1 : 2;
233.56 - }
233.57 -}
233.58 -%%TestCase simplify-conditional-with-casts
233.59 -package test;
233.60 -public class Test {
233.61 - public void test(boolean b, Object o1, Object o2) {
233.62 - String s = b ? (String) o1 : (String) o2;
233.63 - }
233.64 -}
233.65 -%%=>
233.66 -package test;
233.67 -public class Test {
233.68 - public void test(boolean b, Object o1, Object o2) {
233.69 - String s = (String) (b ? o1 : o2);
233.70 - }
233.71 -}
233.72 -%%TestCase simplify-with-declaration
233.73 -package test;
233.74 -public class Test {
233.75 - public void test(boolean b) {
233.76 - int q;
233.77 - if (b)
233.78 - q = 1;
233.79 - else
233.80 - q = 2;
233.81 - }
233.82 -}
233.83 -%%=>
233.84 -package test;
233.85 -public class Test {
233.86 - public void test(boolean b) {
233.87 - int q;
233.88 - q = b ? 1 : 2;
233.89 - }
233.90 -}
234.1 --- a/hintsimpl/test/unit/src/org/netbeans/modules/jackpot30/hintsimpl/jackpot/EnhancedFor.test Fri Jan 27 13:35:56 2012 +0100
234.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
234.3 @@ -1,64 +0,0 @@
234.4 -%%TestCase simple-array
234.5 -package test;
234.6 -public class Test {
234.7 - private void test() {
234.8 - String[] a = new String[2];
234.9 -
234.10 - for (int c = 0; c < a.length; c++) {
234.11 - String s = a[c];
234.12 - System.err.println(s);
234.13 - }
234.14 - }
234.15 -}
234.16 -%%=>
234.17 -package test;
234.18 -public class Test {
234.19 - private void test() {
234.20 - String[] a = new String[2];
234.21 - for (String s : a) {
234.22 - System.err.println(s);
234.23 - }
234.24 - }
234.25 -}
234.26 -%%TestCase simple-iterable
234.27 -package test;
234.28 -import java.util.Iterator;
234.29 -public class Test {
234.30 - private void test(Iterable iterable) {
234.31 - for (Iterator it = iterable.iterator(); it.hasNext();) {
234.32 - String s = (String) it.next();
234.33 - System.err.println(s);
234.34 - }
234.35 - }
234.36 -}
234.37 -%%=>
234.38 -package test;
234.39 -import java.util.Iterator;
234.40 -public class Test {
234.41 - private void test(Iterable iterable) {
234.42 - for (String s : iterable) {
234.43 - System.err.println(s);
234.44 - }
234.45 - }
234.46 -}
234.47 -%%TestCase generified-iterable
234.48 -package test;
234.49 -import java.util.Iterator;
234.50 -public class Test {
234.51 - private void test(Iterable<? extends String> iterable) {
234.52 - for (Iterator<? extends String> it = iterable.iterator(); it.hasNext();) {
234.53 - String s = it.next();
234.54 - System.err.println(s);
234.55 - }
234.56 - }
234.57 -}
234.58 -%%=>
234.59 -package test;
234.60 -import java.util.Iterator;
234.61 -public class Test {
234.62 - private void test(Iterable<? extends String> iterable) {
234.63 - for (String s : iterable) {
234.64 - System.err.println(s);
234.65 - }
234.66 - }
234.67 -}
235.1 --- a/hintsimpl/test/unit/src/org/netbeans/modules/jackpot30/hintsimpl/jdk7/java.util.Objects.test Fri Jan 27 13:35:56 2012 +0100
235.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
235.3 @@ -1,68 +0,0 @@
235.4 -%%TestCase positive-equals-1 DISABLED
235.5 -package test;
235.6 -public class Test {
235.7 - private boolean test(Object o1, Object o2) {
235.8 - return (o1 == null) ? (o2 != null) : !o1.equals(o2);
235.9 - }
235.10 -}
235.11 -%%=>
235.12 -package test;
235.13 -
235.14 -import java.util.Objects;
235.15 -
235.16 -public class Test {
235.17 - private boolean test(Object o1, Object o2) {
235.18 - return Objects.equals(o1, o2);
235.19 - }
235.20 -}
235.21 -%%TestCase positive-equals-2 DISABLED
235.22 -package test;
235.23 -public class Test {
235.24 - private boolean test(Object o1, Object o2) {
235.25 - return o1 != o2 && (o1 == null || !o1.equals(o2));
235.26 - }
235.27 -}
235.28 -%%=>
235.29 -package test;
235.30 -
235.31 -import java.util.Objects;
235.32 -
235.33 -public class Test {
235.34 - private boolean test(Object o1, Object o2) {
235.35 - return Objects.equals(o1, o2);
235.36 - }
235.37 -}
235.38 -%%TestCase positive-hashcode-1 DISABLED
235.39 -package test;
235.40 -public class Test {
235.41 - private boolean test(Object o1) {
235.42 - return (o1 != null ? o1.hashCode() : 0);
235.43 - }
235.44 -}
235.45 -%%=>
235.46 -package test;
235.47 -
235.48 -import java.util.Objects;
235.49 -
235.50 -public class Test {
235.51 - private boolean test(Object o1) {
235.52 - return Objects.hashCode(o1);
235.53 - }
235.54 -}
235.55 -%%TestCase positive-hashcode-2 DISABLED
235.56 -package test;
235.57 -public class Test {
235.58 - private boolean test(Object o1) {
235.59 - return o1 != null ? o1.hashCode() : 0;
235.60 - }
235.61 -}
235.62 -%%=>
235.63 -package test;
235.64 -
235.65 -import java.util.Objects;
235.66 -
235.67 -public class Test {
235.68 - private boolean test(Object o1) {
235.69 - return Objects.hashCode(o1);
235.70 - }
235.71 -}
236.1 --- a/hintsimpl/test/unit/src/org/netbeans/modules/jackpot30/hintsimpl/wrong-string-comparison.test Fri Jan 27 13:35:56 2012 +0100
236.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
236.3 @@ -1,56 +0,0 @@
236.4 -%%TestCase simple
236.5 -package test;
236.6 -public class Test {
236.7 - public static boolean get(String s1, String s2) {
236.8 - return s1 == s2;
236.9 - }
236.10 -}
236.11 -%%=>
236.12 -package test;
236.13 -public class Test {
236.14 - public static boolean get(String s1, String s2) {
236.15 - return s1 == null ? s2 == null : s1.equals(s2);
236.16 - }
236.17 -}
236.18 -%%=>
236.19 -package test;
236.20 -public class Test {
236.21 - public static boolean get(String s1, String s2) {
236.22 - return s1.equals(s2);
236.23 - }
236.24 -}
236.25 -%%TestCase neg
236.26 -package test;
236.27 -public class Test {
236.28 - public static boolean get(String s1, String s2) {
236.29 - return s1 != s2;
236.30 - }
236.31 -}
236.32 -%%=>
236.33 -package test;
236.34 -public class Test {
236.35 - public static boolean get(String s1, String s2) {
236.36 - return !(s1 == null ? s2 == null : s1.equals(s2));
236.37 - }
236.38 -}
236.39 -%%=>
236.40 -package test;
236.41 -public class Test {
236.42 - public static boolean get(String s1, String s2) {
236.43 - return !s1.equals(s2);
236.44 - }
236.45 -}
236.46 -%%TestCase neg-accept
236.47 -package test;
236.48 -public class Test {
236.49 - public static boolean get(String s1, String s2) {
236.50 - return s1 != s2 && (s1 == null || s1.equals(s2));
236.51 - }
236.52 -}
236.53 -%%TestCase null
236.54 -package test;
236.55 -public class Test {
236.56 - public static boolean get(String s1, String s2) {
236.57 - return s1 == null;
236.58 - }
236.59 -}
237.1 --- a/hudson/trunk Fri Jan 27 13:35:56 2012 +0100
237.2 +++ b/hudson/trunk Mon Mar 12 21:10:10 2012 +0100
237.3 @@ -1,4 +1,5 @@
237.4 #!/bin/bash -x
237.5 +prepare_platform() {
237.6 if [ "$TRUNK_URL" == "" ] ; then
237.7 TRUNK_URL="http://deadlock.netbeans.org/hudson/job/nbms-and-javadoc";
237.8 fi;
237.9 @@ -30,36 +31,26 @@
237.10 cd ../..
237.11
237.12 PLATFORM=$PWD/nbbuild/netbeans
237.13 -
237.14 -call_ant() {
237.15 - ant -Dnbplatform.default.harness.dir=$PLATFORM/harness -Dnbplatform.default.netbeans.dest.dir=$PLATFORM -Dnbplatform.active.dir=$PLATFORM "$@"
237.16 }
237.17
237.18 -(cd borrowedtests; call_ant clean && call_ant) || exit
237.19 -call_ant copy-from-platform
237.20 -(cd server; ant -f download.xml) || exit
237.21 -(cd remoting; ./build-indexing-backend -Dnbplatform.default.harness.dir=$PLATFORM/harness -Dnbplatform.default.netbeans.dest.dir=$PLATFORM -Dnbplatform.active.dir=$PLATFORM) || exit 1
237.22 -(cd remoting/server/tests; ./run-declarative-tests -Dnbplatform.default.harness.dir=$PLATFORM/harness -Dnbplatform.default.netbeans.dest.dir=$PLATFORM -Dnbplatform.active.dir=$PLATFORM) || exit 1
237.23 -call_ant clean || exit
237.24 -call_ant build || exit
237.25 -#call_ant coverage-report || exit
237.26 -call_ant test || exit
237.27 +if [ "$PLATFORM" == "" ] ; then
237.28 + prepare_platform
237.29 +fi;
237.30
237.31 -(cd cmdline; call_ant clean && call_ant build && call_ant test && (cd compiler; call_ant create-standalone-compiler && build/test/scripted/run ) && (cd tool; call_ant create-standalone-tool && build/test/scripted/run )) || exit
237.32 +ant -Dnbplatform.active.dir=$PLATFORM -f lib/download.xml download copy-from-platform
237.33 +
237.34 +SUBPROJECTS="remoting language duplicates cmdline";
237.35 +
237.36 +for subproject in $SUBPROJECTS; do
237.37 + (cd $subproject; ./build.sh -Dnbplatform.default.harness.dir=$PLATFORM/harness -Dnbplatform.default.netbeans.dest.dir=$PLATFORM -Dnbplatform.active.dir=$PLATFORM) || exit 1
237.38 +done
237.39
237.40 mkdir -p build/updates
237.41 -cp nbbuild/download/*.nbm build/updates
237.42
237.43 -call_ant -Ddist.base=$DIST_BASE nbms || exit
237.44 +NBMS_SUBPROJECTS="remoting language duplicates";
237.45 +
237.46 +cp `find $NBMS_SUBPROJECTS -type f -name "*.nbm"` build/updates
237.47 +ant -Dnbplatform.default.harness.dir=$PLATFORM/harness -Dnbplatform.default.netbeans.dest.dir=$PLATFORM -Dnbplatform.active.dir=$PLATFORM -Ddist.base=$DIST_BASE build-auc || exit 1
237.48 gzip <build/updates/updates.xml >build/updates/updates.xml.gz
237.49
237.50 -#(cd cmdline/compiler; call_ant copy-to-hudson) || exit
237.51 -#(cd server/indexer; call_ant copy-to-hudson) || exit
237.52 -(cd cmdline/tool; call_ant create-standalone-tool) || exit
237.53 -(cd cmdline/compiler; call_ant create-standalone-compiler) || exit
237.54 -
237.55 -call_ant -Ddist.base=$DIST_BASE findbugs || exit
237.56 -
237.57 -mkdir -p build/server
237.58 -(cp server/do-indexing server/indexer/dist; cd server/indexer/dist/; zip -r ../../../build/server/indexer.zip *)
237.59 -(cd server/web.api/dist/; zip -r ../../../build/server/web.api.zip *)
237.60 +exit 0
238.1 --- a/kit/build.xml Fri Jan 27 13:35:56 2012 +0100
238.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
238.3 @@ -1,13 +0,0 @@
238.4 -<?xml version="1.0" encoding="UTF-8"?>
238.5 -<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
238.6 -<!-- for some information on what you could do (e.g. targets to override). -->
238.7 -<!-- If you delete this file and reopen the project it will be recreated. -->
238.8 -<project name="org.netbeans.modules.jackpot30.kit" default="netbeans" basedir=".">
238.9 - <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.kit.</description>
238.10 - <import file="nbproject/build-impl.xml"/>
238.11 -
238.12 - <target name="test" />
238.13 - <target name="test-coverage" />
238.14 - <target name="coverage-report" />
238.15 - <target name="findbugs" />
238.16 -</project>
239.1 --- a/kit/manifest.mf Fri Jan 27 13:35:56 2012 +0100
239.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
239.3 @@ -1,5 +0,0 @@
239.4 -Manifest-Version: 1.0
239.5 -OpenIDE-Module: org.netbeans.modules.jackpot30.kit
239.6 -OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/kit/Bundle.properties
239.7 -OpenIDE-Module-Specification-Version: 1.16
239.8 -
240.1 --- a/kit/nbproject/build-impl.xml Fri Jan 27 13:35:56 2012 +0100
240.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
240.3 @@ -1,45 +0,0 @@
240.4 -<?xml version="1.0" encoding="UTF-8"?>
240.5 -<!--
240.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
240.7 -*** EDIT ../build.xml INSTEAD ***
240.8 --->
240.9 -<project name="org.netbeans.modules.jackpot30.kit-impl" basedir="..">
240.10 - <fail message="Please build using Ant 1.7.1 or higher.">
240.11 - <condition>
240.12 - <not>
240.13 - <antversion atleast="1.7.1"/>
240.14 - </not>
240.15 - </condition>
240.16 - </fail>
240.17 - <property file="nbproject/private/suite-private.properties"/>
240.18 - <property file="nbproject/suite.properties"/>
240.19 - <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
240.20 - <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
240.21 - <property file="${suite.dir}/nbproject/platform.properties"/>
240.22 - <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
240.23 - <attribute name="name"/>
240.24 - <attribute name="value"/>
240.25 - <sequential>
240.26 - <property name="@{name}" value="${@{value}}"/>
240.27 - </sequential>
240.28 - </macrodef>
240.29 - <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
240.30 - <attribute name="property"/>
240.31 - <attribute name="value"/>
240.32 - <sequential>
240.33 - <property name="@{property}" value="@{value}"/>
240.34 - </sequential>
240.35 - </macrodef>
240.36 - <property file="${user.properties.file}"/>
240.37 - <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
240.38 - <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
240.39 - <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
240.40 - <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
240.41 - <condition>
240.42 - <not>
240.43 - <contains string="${cluster.path.evaluated}" substring="platform"/>
240.44 - </not>
240.45 - </condition>
240.46 - </fail>
240.47 - <import file="${harness.dir}/build.xml"/>
240.48 -</project>
241.1 --- a/kit/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
241.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
241.3 @@ -1,8 +0,0 @@
241.4 -build.xml.data.CRC32=719584a7
241.5 -build.xml.script.CRC32=6c4da9a3
241.6 -build.xml.stylesheet.CRC32=79c3b980@1.28.0.7
241.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
241.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
241.9 -nbproject/build-impl.xml.data.CRC32=ff5fa2e9
241.10 -nbproject/build-impl.xml.script.CRC32=c129207c
241.11 -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.47
242.1 --- a/kit/nbproject/project.properties Fri Jan 27 13:35:56 2012 +0100
242.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
242.3 @@ -1,2 +0,0 @@
242.4 -javac.source=1.5
242.5 -javac.compilerargs=-Xlint -Xlint:-serial
243.1 --- a/kit/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
243.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
243.3 @@ -1,33 +0,0 @@
243.4 -<?xml version="1.0" encoding="UTF-8"?>
243.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
243.6 - <type>org.netbeans.modules.apisupport.project</type>
243.7 - <configuration>
243.8 - <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
243.9 - <code-name-base>org.netbeans.modules.jackpot30.kit</code-name-base>
243.10 - <suite-component/>
243.11 - <module-dependencies>
243.12 - <dependency>
243.13 - <code-name-base>org.netbeans.modules.jackpot30.api</code-name-base>
243.14 - <build-prerequisite/>
243.15 - <compile-dependency/>
243.16 - <run-dependency>
243.17 - <specification-version>1.16</specification-version>
243.18 - </run-dependency>
243.19 - </dependency>
243.20 - <dependency>
243.21 - <code-name-base>org.netbeans.modules.jackpot30.hintsimpl</code-name-base>
243.22 - <run-dependency>
243.23 - <specification-version>1.16</specification-version>
243.24 - </run-dependency>
243.25 - </dependency>
243.26 - <dependency>
243.27 - <code-name-base>org.netbeans.modules.jackpot30.transformers</code-name-base>
243.28 - <run-dependency>
243.29 - <specification-version>1.16</specification-version>
243.30 - </run-dependency>
243.31 - </dependency>
243.32 - </module-dependencies>
243.33 - <public-packages/>
243.34 - </data>
243.35 - </configuration>
243.36 -</project>
244.1 --- a/kit/nbproject/suite.properties Fri Jan 27 13:35:56 2012 +0100
244.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
244.3 @@ -1,1 +0,0 @@
244.4 -suite.dir=${basedir}/..
245.1 --- a/kit/src/org/netbeans/modules/jackpot30/kit/Bundle.properties Fri Jan 27 13:35:56 2012 +0100
245.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
245.3 @@ -1,38 +0,0 @@
245.4 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
245.5 -#
245.6 -# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
245.7 -#
245.8 -# The contents of this file are subject to the terms of either the GNU
245.9 -# General Public License Version 2 only ("GPL") or the Common
245.10 -# Development and Distribution License("CDDL") (collectively, the
245.11 -# "License"). You may not use this file except in compliance with the
245.12 -# License. You can obtain a copy of the License at
245.13 -# http://www.netbeans.org/cddl-gplv2.html
245.14 -# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
245.15 -# specific language governing permissions and limitations under the
245.16 -# License. When distributing the software, include this License Header
245.17 -# Notice in each file and include the License file at
245.18 -# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
245.19 -# particular file as subject to the "Classpath" exception as provided
245.20 -# by Sun in the GPL Version 2 section of the License file that
245.21 -# accompanied this code. If applicable, add the following below the
245.22 -# License Header, with the fields enclosed by brackets [] replaced by
245.23 -# your own identifying information:
245.24 -# "Portions Copyrighted [year] [name of copyright owner]"
245.25 -#
245.26 -# If you wish your version of this file to be governed by only the CDDL
245.27 -# or only the GPL Version 2, indicate your decision by adding
245.28 -# "[Contributor] elects to include this software in this distribution
245.29 -# under the [CDDL or GPL Version 2] license." If you do not indicate a
245.30 -# single choice of license, a recipient has the option to distribute
245.31 -# your version of this file under either the CDDL, the GPL Version 2 or
245.32 -# to extend the choice of license to its licensees as provided above.
245.33 -# However, if you add GPL Version 2 code and therefore, elected the GPL
245.34 -# Version 2 license, then the option applies only if the new code is
245.35 -# made subject to such option by the copyright holder.
245.36 -#
245.37 -# Contributor(s):
245.38 -#
245.39 -# Portions Copyrighted 2009 Sun Microsystems, Inc.
245.40 -
245.41 -OpenIDE-Module-Name=Jackpot 3.0
246.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
246.2 +++ b/language/build.sh Mon Mar 12 21:10:10 2012 +0100
246.3 @@ -0,0 +1,3 @@
246.4 +#!/bin/bash
246.5 +(cd ide; ant "$@" clean && ant "$@" nbms && ant "$@" test) || exit 1
246.6 +
247.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
247.2 +++ b/language/ide/bridges/apisupport/bridge/org/netbeans/modules/jackpot30/apisupport/bridgeimpl/ProjectDependencyUpgraderImpl.java Mon Mar 12 21:10:10 2012 +0100
247.3 @@ -0,0 +1,157 @@
247.4 +/*
247.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
247.6 + *
247.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
247.8 + *
247.9 + * The contents of this file are subject to the terms of either the GNU
247.10 + * General Public License Version 2 only ("GPL") or the Common
247.11 + * Development and Distribution License("CDDL") (collectively, the
247.12 + * "License"). You may not use this file except in compliance with the
247.13 + * License. You can obtain a copy of the License at
247.14 + * http://www.netbeans.org/cddl-gplv2.html
247.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
247.16 + * specific language governing permissions and limitations under the
247.17 + * License. When distributing the software, include this License Header
247.18 + * Notice in each file and include the License file at
247.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
247.20 + * particular file as subject to the "Classpath" exception as provided
247.21 + * by Sun in the GPL Version 2 section of the License file that
247.22 + * accompanied this code. If applicable, add the following below the
247.23 + * License Header, with the fields enclosed by brackets [] replaced by
247.24 + * your own identifying information:
247.25 + * "Portions Copyrighted [year] [name of copyright owner]"
247.26 + *
247.27 + * If you wish your version of this file to be governed by only the CDDL
247.28 + * or only the GPL Version 2, indicate your decision by adding
247.29 + * "[Contributor] elects to include this software in this distribution
247.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
247.31 + * single choice of license, a recipient has the option to distribute
247.32 + * your version of this file under either the CDDL, the GPL Version 2 or
247.33 + * to extend the choice of license to its licensees as provided above.
247.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
247.35 + * Version 2 license, then the option applies only if the new code is
247.36 + * made subject to such option by the copyright holder.
247.37 + *
247.38 + * Contributor(s):
247.39 + *
247.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
247.41 + */
247.42 +package org.netbeans.modules.jackpot30.apisupport.bridgeimpl;
247.43 +
247.44 +import java.io.IOException;
247.45 +import org.netbeans.api.project.FileOwnerQuery;
247.46 +import org.netbeans.api.project.Project;
247.47 +import org.netbeans.api.project.ProjectManager;
247.48 +import org.netbeans.api.project.ProjectUtils;
247.49 +import org.netbeans.modules.apisupport.project.ModuleDependency;
247.50 +import org.netbeans.modules.apisupport.project.NbModuleProject;
247.51 +import org.netbeans.modules.apisupport.project.ProjectXMLManager;
247.52 +import org.netbeans.modules.apisupport.project.ProjectXMLManager.CyclicDependencyException;
247.53 +import org.netbeans.modules.apisupport.project.spi.NbModuleProvider;
247.54 +import org.netbeans.modules.apisupport.project.universe.ModuleEntry;
247.55 +import org.netbeans.modules.jackpot30.apisupport.Utilities;
247.56 +import org.netbeans.modules.jackpot30.apisupport.Utilities.ParsedDependency;
247.57 +import org.netbeans.modules.java.hints.jackpot.spi.ProjectDependencyUpgrader;
247.58 +import org.openide.filesystems.FileObject;
247.59 +import org.openide.modules.SpecificationVersion;
247.60 +import org.openide.util.Exceptions;
247.61 +
247.62 +/**
247.63 + *
247.64 + * @author lahvac
247.65 + */
247.66 +public class ProjectDependencyUpgraderImpl extends ProjectDependencyUpgrader {
247.67 +
247.68 + public boolean ensureDependency(Project currentProject, FileObject depFO, SpecificationVersion spec, final boolean canShowUI) {
247.69 + NbModuleProvider currentNbModule = currentProject.getLookup().lookup(NbModuleProvider.class);
247.70 +
247.71 + if (currentNbModule == null) {
247.72 + return false;
247.73 + }
247.74 +
247.75 + Project referedProject = FileOwnerQuery.getOwner(depFO);
247.76 +
247.77 + if (referedProject == null) {
247.78 + return false;
247.79 + }
247.80 +
247.81 + NbModuleProject referedNbProject = referedProject.getLookup().lookup(NbModuleProject.class);
247.82 +
247.83 + if (referedNbProject == null) {
247.84 + return false;
247.85 + }
247.86 +
247.87 + return ensureDependency(currentProject, referedNbProject.getCodeNameBase(), ProjectUtils.getInformation(referedProject).getDisplayName(), null, spec, canShowUI);
247.88 + }
247.89 +
247.90 + private boolean ensureDependency(Project currentProject, String cnb, String displayName, String releaseVersion, SpecificationVersion spec, final boolean canShowUI) {
247.91 + NbModuleProvider currentNbModule = currentProject.getLookup().lookup(NbModuleProvider.class);
247.92 +
247.93 + if (currentNbModule == null) {
247.94 + return false;
247.95 + }
247.96 +
247.97 + try {
247.98 + NbModuleProject currentNbModuleProject = currentProject.getLookup().lookup(NbModuleProject.class);
247.99 +
247.100 + if (currentNbModuleProject == null) {
247.101 + return false;
247.102 + }
247.103 +
247.104 + ProjectXMLManager m = new ProjectXMLManager(currentNbModuleProject);
247.105 + ModuleDependency dep = m.getModuleDependency(cnb);
247.106 +
247.107 + if (dep == null) {
247.108 + if (showDependencyUpgradeDialog(currentProject, displayName, null, spec, false, canShowUI)) {
247.109 + ModuleEntry me = currentNbModuleProject.getModuleList().getEntry(cnb);
247.110 + ModuleDependency nue = new ModuleDependency(me,
247.111 + releaseVersion != null ? releaseVersion : me.getReleaseVersion(),
247.112 + spec != null ? spec.toString() : me.getSpecificationVersion(),
247.113 + true,
247.114 + false);
247.115 +
247.116 + m.addDependency(nue);
247.117 + ProjectManager.getDefault().saveProject(currentProject);
247.118 + }
247.119 +
247.120 + return true;
247.121 + }
247.122 +
247.123 + if (dep.getSpecificationVersion() == null) {
247.124 + //impl.dep?
247.125 + return false;
247.126 + }
247.127 +
247.128 + SpecificationVersion currentDep = new SpecificationVersion(dep.getSpecificationVersion());
247.129 +
247.130 + if (spec != null && (currentDep == null || currentDep.compareTo(spec) < 0)) {
247.131 + if (showDependencyUpgradeDialog(currentProject, displayName, new SpecificationVersion(dep.getSpecificationVersion()), spec, false, canShowUI)) {
247.132 + ModuleDependency nue = new ModuleDependency(dep.getModuleEntry(),
247.133 + releaseVersion != null ? releaseVersion : dep.getReleaseVersion(),
247.134 + spec.toString(),
247.135 + dep.hasCompileDependency(),
247.136 + dep.hasImplementationDependency());
247.137 +
247.138 + m.editDependency(dep, nue);
247.139 + ProjectManager.getDefault().saveProject(currentProject);
247.140 + }
247.141 +
247.142 + return true;
247.143 + }
247.144 + } catch (CyclicDependencyException ex) {
247.145 + Exceptions.printStackTrace(ex);
247.146 + } catch (IOException ex) {
247.147 + Exceptions.printStackTrace(ex);
247.148 + }
247.149 +
247.150 + return false;
247.151 + }
247.152 +
247.153 + @Override
247.154 + public boolean ensureDependency(Project p, String specification, boolean canShowUI) {
247.155 + ParsedDependency dep = Utilities.parseDependency(specification);
247.156 +
247.157 + return ensureDependency(p, dep.cnb, /*TODO: may null and that could put display name their*/specification, dep.releaseVersion, dep.specVersion, canShowUI);
247.158 + }
247.159 +
247.160 +}
248.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
248.2 +++ b/language/ide/bridges/apisupport/build.xml Mon Mar 12 21:10:10 2012 +0100
248.3 @@ -0,0 +1,25 @@
248.4 +<?xml version="1.0" encoding="UTF-8"?>
248.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
248.6 +<!-- for some information on what you could do (e.g. targets to override). -->
248.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
248.8 +<project name="org.netbeans.modules.jackpot30.apisupport" default="netbeans" basedir=".">
248.9 + <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.apisupport.</description>
248.10 + <import file="nbproject/build-impl.xml"/>
248.11 + <import file="${suite.dir}/../../findbugs-import.xml"/>
248.12 + <target name="netbeans-extra" depends="init">
248.13 + <mkdir dir="build/bridgeclasses"/>
248.14 + <javac srcdir="bridge" destdir="build/bridgeclasses" source="1.6" target="1.6" debug="true" deprecation="true">
248.15 + <classpath>
248.16 + <path refid="cp"/>
248.17 + <pathelement location="${cluster}/modules/${code.name.base.dashes}.jar"/>
248.18 + </classpath>
248.19 + </javac>
248.20 + <copy todir="build/bridgeclasses">
248.21 + <fileset dir="bridge" excludes="${jar-excludes}"/>
248.22 + </copy>
248.23 + <mkdir dir="${cluster}/modules/ext"/>
248.24 + <jar jarfile="${cluster}/modules/ext/${code.name.base.dashes}.jar" compress="false">
248.25 + <fileset dir="build/bridgeclasses"/>
248.26 + </jar>
248.27 + </target>
248.28 +</project>
249.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
249.2 +++ b/language/ide/bridges/apisupport/manifest.mf Mon Mar 12 21:10:10 2012 +0100
249.3 @@ -0,0 +1,6 @@
249.4 +Manifest-Version: 1.0
249.5 +OpenIDE-Module: org.netbeans.modules.jackpot30.apisupport
249.6 +OpenIDE-Module-Implementation-Version: 1
249.7 +OpenIDE-Module-Install: org/netbeans/modules/jackpot30/apisupport/Installer.class
249.8 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/apisupport/Bundle.properties
249.9 +
250.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
250.2 +++ b/language/ide/bridges/apisupport/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
250.3 @@ -0,0 +1,45 @@
250.4 +<?xml version="1.0" encoding="UTF-8"?>
250.5 +<!--
250.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
250.7 +*** EDIT ../build.xml INSTEAD ***
250.8 +-->
250.9 +<project name="org.netbeans.modules.jackpot30.apisupport-impl" basedir="..">
250.10 + <fail message="Please build using Ant 1.7.1 or higher.">
250.11 + <condition>
250.12 + <not>
250.13 + <antversion atleast="1.7.1"/>
250.14 + </not>
250.15 + </condition>
250.16 + </fail>
250.17 + <property file="nbproject/private/suite-private.properties"/>
250.18 + <property file="nbproject/suite.properties"/>
250.19 + <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
250.20 + <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
250.21 + <property file="${suite.dir}/nbproject/platform.properties"/>
250.22 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
250.23 + <attribute name="name"/>
250.24 + <attribute name="value"/>
250.25 + <sequential>
250.26 + <property name="@{name}" value="${@{value}}"/>
250.27 + </sequential>
250.28 + </macrodef>
250.29 + <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
250.30 + <attribute name="property"/>
250.31 + <attribute name="value"/>
250.32 + <sequential>
250.33 + <property name="@{property}" value="@{value}"/>
250.34 + </sequential>
250.35 + </macrodef>
250.36 + <property file="${user.properties.file}"/>
250.37 + <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
250.38 + <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
250.39 + <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
250.40 + <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
250.41 + <condition>
250.42 + <not>
250.43 + <contains string="${cluster.path.evaluated}" substring="platform"/>
250.44 + </not>
250.45 + </condition>
250.46 + </fail>
250.47 + <import file="${harness.dir}/build.xml"/>
250.48 +</project>
251.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
251.2 +++ b/language/ide/bridges/apisupport/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
251.3 @@ -0,0 +1,8 @@
251.4 +build.xml.data.CRC32=c45369e1
251.5 +build.xml.script.CRC32=a2cc69eb
251.6 +build.xml.stylesheet.CRC32=79c3b980@1.40
251.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
251.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
251.9 +nbproject/build-impl.xml.data.CRC32=e186a96e
251.10 +nbproject/build-impl.xml.script.CRC32=83dd2c27
251.11 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.49
252.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
252.2 +++ b/language/ide/bridges/apisupport/nbproject/platform.properties Mon Mar 12 21:10:10 2012 +0100
252.3 @@ -0,0 +1,16 @@
252.4 +cluster.path=\
252.5 + ${nbplatform.active.dir}/apisupport:\
252.6 + ${nbplatform.active.dir}/harness:\
252.7 + ${nbplatform.active.dir}/ide:\
252.8 + ${nbplatform.active.dir}/java:\
252.9 + ${nbplatform.active.dir}/nb:\
252.10 + ${nbplatform.active.dir}/platform:\
252.11 + ${nbplatform.active.dir}/profiler:\
252.12 + ${nbplatform.active.dir}/websvccommon:\
252.13 + ../../remoting/common/build/cluster:\
252.14 + ../../remoting/ide/build/cluster
252.15 +extcluster.../../remoting/ide/build/cluster.javadoc=
252.16 +extcluster.../../remoting/ide/build/cluster.sources=../../remoting/ide
252.17 +extcluster.../remoting/common/build/cluster.javadoc=
252.18 +extcluster.../remoting/common/build/cluster.sources=../../remoting/common
252.19 +nbplatform.active=default
253.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
253.2 +++ b/language/ide/bridges/apisupport/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
253.3 @@ -0,0 +1,5 @@
253.4 +is.eager=true
253.5 +javac.source=1.5
253.6 +javac.compilerargs=-Xlint -Xlint:-serial
253.7 +extra.module.files=modules/ext/org-netbeans-modules-jackpot30-apisupport.jar
253.8 +spec.version.base=1.16
254.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
254.2 +++ b/language/ide/bridges/apisupport/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
254.3 @@ -0,0 +1,85 @@
254.4 +<?xml version="1.0" encoding="UTF-8"?>
254.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
254.6 + <type>org.netbeans.modules.apisupport.project</type>
254.7 + <configuration>
254.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
254.9 + <code-name-base>org.netbeans.modules.jackpot30.apisupport</code-name-base>
254.10 + <suite-component/>
254.11 + <module-dependencies>
254.12 + <dependency>
254.13 + <code-name-base>org.netbeans.modules.apisupport.ant</code-name-base>
254.14 + <build-prerequisite/>
254.15 + <compile-dependency/>
254.16 + </dependency>
254.17 + <dependency>
254.18 + <code-name-base>org.netbeans.modules.apisupport.project</code-name-base>
254.19 + <build-prerequisite/>
254.20 + <compile-dependency/>
254.21 + </dependency>
254.22 + <dependency>
254.23 + <code-name-base>org.netbeans.modules.apisupport.project</code-name-base>
254.24 + <run-dependency>
254.25 + <release-version>1</release-version>
254.26 + </run-dependency>
254.27 + </dependency>
254.28 + <dependency>
254.29 + <code-name-base>org.netbeans.modules.java.hints</code-name-base>
254.30 + <build-prerequisite/>
254.31 + <compile-dependency/>
254.32 + <run-dependency>
254.33 + <release-version>1</release-version>
254.34 + <implementation-version/>
254.35 + </run-dependency>
254.36 + </dependency>
254.37 + <dependency>
254.38 + <code-name-base>org.netbeans.modules.projectapi</code-name-base>
254.39 + <build-prerequisite/>
254.40 + <compile-dependency/>
254.41 + <run-dependency>
254.42 + <release-version>1</release-version>
254.43 + <specification-version>1.29</specification-version>
254.44 + </run-dependency>
254.45 + </dependency>
254.46 + <dependency>
254.47 + <code-name-base>org.openide.filesystems</code-name-base>
254.48 + <build-prerequisite/>
254.49 + <compile-dependency/>
254.50 + <run-dependency>
254.51 + <specification-version>7.33.0.1.1</specification-version>
254.52 + </run-dependency>
254.53 + </dependency>
254.54 + <dependency>
254.55 + <code-name-base>org.openide.modules</code-name-base>
254.56 + <build-prerequisite/>
254.57 + <compile-dependency/>
254.58 + <run-dependency>
254.59 + <specification-version>7.14</specification-version>
254.60 + </run-dependency>
254.61 + </dependency>
254.62 + <dependency>
254.63 + <code-name-base>org.openide.util</code-name-base>
254.64 + <build-prerequisite/>
254.65 + <compile-dependency/>
254.66 + <run-dependency>
254.67 + <specification-version>7.32.0.1</specification-version>
254.68 + </run-dependency>
254.69 + </dependency>
254.70 + <dependency>
254.71 + <code-name-base>org.openide.util.lookup</code-name-base>
254.72 + <build-prerequisite/>
254.73 + <compile-dependency/>
254.74 + <run-dependency>
254.75 + <specification-version>8.2</specification-version>
254.76 + </run-dependency>
254.77 + </dependency>
254.78 + </module-dependencies>
254.79 + <public-packages/>
254.80 + <extra-compilation-unit>
254.81 + <package-root>bridge</package-root>
254.82 + <classpath>${module.classpath}:${cluster}/modules/${code.name.base.dashes}.jar</classpath>
254.83 + <built-to>build/bridgeclasses</built-to>
254.84 + <built-to>${cluster}/modules/ext/${code.name.base.dashes}.jar</built-to>
254.85 + </extra-compilation-unit>
254.86 + </data>
254.87 + </configuration>
254.88 +</project>
255.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
255.2 +++ b/language/ide/bridges/apisupport/nbproject/suite.properties Mon Mar 12 21:10:10 2012 +0100
255.3 @@ -0,0 +1,1 @@
255.4 +suite.dir=${basedir}/../..
256.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
256.2 +++ b/language/ide/bridges/apisupport/src/org/netbeans/modules/jackpot30/apisupport/APIProjectDependencyUpgraderImpl.java Mon Mar 12 21:10:10 2012 +0100
256.3 @@ -0,0 +1,127 @@
256.4 +/*
256.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
256.6 + *
256.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
256.8 + *
256.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
256.10 + * Other names may be trademarks of their respective owners.
256.11 + *
256.12 + * The contents of this file are subject to the terms of either the GNU General
256.13 + * Public License Version 2 only ("GPL") or the Common Development and
256.14 + * Distribution License("CDDL") (collectively, the "License"). You may not use
256.15 + * this file except in compliance with the License. You can obtain a copy of the
256.16 + * License at http://www.netbeans.org/cddl-gplv2.html or
256.17 + * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
256.18 + * governing permissions and limitations under the License. When distributing
256.19 + * the software, include this License Header Notice in each file and include the
256.20 + * License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
256.21 + * particular file as subject to the "Classpath" exception as provided by Oracle
256.22 + * in the GPL Version 2 section of the License file that accompanied this code.
256.23 + * If applicable, add the following below the License Header, with the fields
256.24 + * enclosed by brackets [] replaced by your own identifying information:
256.25 + * "Portions Copyrighted [year] [name of copyright owner]"
256.26 + *
256.27 + * If you wish your version of this file to be governed by only the CDDL or only
256.28 + * the GPL Version 2, indicate your decision by adding "[Contributor] elects to
256.29 + * include this software in this distribution under the [CDDL or GPL Version 2]
256.30 + * license." If you do not indicate a single choice of license, a recipient has
256.31 + * the option to distribute your version of this file under either the CDDL, the
256.32 + * GPL Version 2 or to extend the choice of license to its licensees as provided
256.33 + * above. However, if you add GPL Version 2 code and therefore, elected the GPL
256.34 + * Version 2 license, then the option applies only if the new code is made
256.35 + * subject to such option by the copyright holder.
256.36 + *
256.37 + * Contributor(s):
256.38 + *
256.39 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
256.40 + */
256.41 +package org.netbeans.modules.jackpot30.apisupport;
256.42 +
256.43 +import java.io.IOException;
256.44 +import org.netbeans.api.project.FileOwnerQuery;
256.45 +import org.netbeans.api.project.Project;
256.46 +import org.netbeans.api.project.ProjectManager;
256.47 +import org.netbeans.api.project.ProjectUtils;
256.48 +import org.netbeans.modules.apisupport.project.spi.NbModuleProvider;
256.49 +import org.netbeans.modules.jackpot30.apisupport.Utilities.ParsedDependency;
256.50 +import org.netbeans.modules.java.hints.jackpot.spi.ProjectDependencyUpgrader;
256.51 +import org.openide.filesystems.FileObject;
256.52 +import org.openide.modules.SpecificationVersion;
256.53 +import org.openide.util.Exceptions;
256.54 +import org.openide.util.lookup.ServiceProvider;
256.55 +
256.56 +/**
256.57 + *
256.58 + * @author lahvac
256.59 + */
256.60 +public class APIProjectDependencyUpgraderImpl extends ProjectDependencyUpgrader {
256.61 +
256.62 + public boolean ensureDependency(Project currentProject, FileObject depFO, SpecificationVersion spec, final boolean canShowUI) {
256.63 + NbModuleProvider currentNbModule = currentProject.getLookup().lookup(NbModuleProvider.class);
256.64 +
256.65 + if (currentNbModule == null) {
256.66 + return false;
256.67 + }
256.68 +
256.69 + Project referedProject = FileOwnerQuery.getOwner(depFO);
256.70 +
256.71 + if (referedProject == null) {
256.72 + return false;
256.73 + }
256.74 +
256.75 + NbModuleProvider referedNbProject = referedProject.getLookup().lookup(NbModuleProvider.class);
256.76 +
256.77 + if (referedNbProject == null) {
256.78 + return false;
256.79 + }
256.80 +
256.81 + return ensureDependency(currentProject, referedNbProject.getCodeNameBase(), ProjectUtils.getInformation(referedProject).getDisplayName(), null, spec, canShowUI);
256.82 + }
256.83 +
256.84 + private boolean ensureDependency(Project currentProject, String cnb, String displayName, String releaseVersion, SpecificationVersion spec, final boolean canShowUI) {
256.85 + NbModuleProvider currentNbModule = currentProject.getLookup().lookup(NbModuleProvider.class);
256.86 +
256.87 + if (currentNbModule == null) {
256.88 + return false;
256.89 + }
256.90 +
256.91 + try {
256.92 + if (!currentNbModule.hasDependency(cnb)) {
256.93 + if (showDependencyUpgradeDialog(currentProject, displayName, null, spec, false, canShowUI)) {
256.94 + currentNbModule.addDependency(cnb, releaseVersion, spec, true);
256.95 + ProjectManager.getDefault().saveProject(currentProject);
256.96 + }
256.97 +
256.98 + return true;
256.99 + }
256.100 +
256.101 + SpecificationVersion currentDep = currentNbModule.getDependencyVersion(cnb);
256.102 +
256.103 + if (currentDep == null) {
256.104 + //impl.dep?
256.105 + return false;
256.106 + }
256.107 +
256.108 + if (spec != null && (currentDep == null || currentDep.compareTo(spec) < 0)) {
256.109 + if (showDependencyUpgradeDialog(currentProject, displayName, currentDep, spec, false, canShowUI)) {
256.110 + currentNbModule.addDependency(cnb, releaseVersion, spec, true);
256.111 + ProjectManager.getDefault().saveProject(currentProject);
256.112 + }
256.113 +
256.114 + return true;
256.115 + }
256.116 + } catch (IOException ex) {
256.117 + Exceptions.printStackTrace(ex);
256.118 + }
256.119 +
256.120 + return false;
256.121 + }
256.122 +
256.123 + @Override
256.124 + public boolean ensureDependency(Project p, String specification, boolean canShowUI) {
256.125 + ParsedDependency dep = Utilities.parseDependency(specification);
256.126 +
256.127 + return ensureDependency(p, dep.cnb, /*TODO: may null and that could put display name their*/specification, dep.releaseVersion, dep.specVersion, canShowUI);
256.128 + }
256.129 +
256.130 +}
257.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
257.2 +++ b/language/ide/bridges/apisupport/src/org/netbeans/modules/jackpot30/apisupport/Bundle.properties Mon Mar 12 21:10:10 2012 +0100
257.3 @@ -0,0 +1,1 @@
257.4 +OpenIDE-Module-Name=Jackpot 3.0 APISupport Bridge
258.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
258.2 +++ b/language/ide/bridges/apisupport/src/org/netbeans/modules/jackpot30/apisupport/HackyProjectDependencyUpgraderImpl.java Mon Mar 12 21:10:10 2012 +0100
258.3 @@ -0,0 +1,107 @@
258.4 +/*
258.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
258.6 + *
258.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
258.8 + *
258.9 + * The contents of this file are subject to the terms of either the GNU
258.10 + * General Public License Version 2 only ("GPL") or the Common
258.11 + * Development and Distribution License("CDDL") (collectively, the
258.12 + * "License"). You may not use this file except in compliance with the
258.13 + * License. You can obtain a copy of the License at
258.14 + * http://www.netbeans.org/cddl-gplv2.html
258.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
258.16 + * specific language governing permissions and limitations under the
258.17 + * License. When distributing the software, include this License Header
258.18 + * Notice in each file and include the License file at
258.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
258.20 + * particular file as subject to the "Classpath" exception as provided
258.21 + * by Sun in the GPL Version 2 section of the License file that
258.22 + * accompanied this code. If applicable, add the following below the
258.23 + * License Header, with the fields enclosed by brackets [] replaced by
258.24 + * your own identifying information:
258.25 + * "Portions Copyrighted [year] [name of copyright owner]"
258.26 + *
258.27 + * If you wish your version of this file to be governed by only the CDDL
258.28 + * or only the GPL Version 2, indicate your decision by adding
258.29 + * "[Contributor] elects to include this software in this distribution
258.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
258.31 + * single choice of license, a recipient has the option to distribute
258.32 + * your version of this file under either the CDDL, the GPL Version 2 or
258.33 + * to extend the choice of license to its licensees as provided above.
258.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
258.35 + * Version 2 license, then the option applies only if the new code is
258.36 + * made subject to such option by the copyright holder.
258.37 + *
258.38 + * Contributor(s):
258.39 + *
258.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
258.41 + */
258.42 +
258.43 +package org.netbeans.modules.jackpot30.apisupport;
258.44 +
258.45 +import java.io.File;
258.46 +import java.net.MalformedURLException;
258.47 +import java.net.URL;
258.48 +import java.net.URLClassLoader;
258.49 +import org.netbeans.api.project.Project;
258.50 +//import org.netbeans.modules.apisupport.project.api.DependencyUpdater;
258.51 +import org.netbeans.modules.java.hints.jackpot.spi.ProjectDependencyUpgrader;
258.52 +import org.openide.filesystems.FileObject;
258.53 +import org.openide.modules.InstalledFileLocator;
258.54 +import org.openide.modules.SpecificationVersion;
258.55 +import org.openide.util.Exceptions;
258.56 +import org.openide.util.Lookup;
258.57 +import org.openide.util.lookup.ServiceProvider;
258.58 +
258.59 +/**
258.60 + *
258.61 + * @author lahvac
258.62 + */
258.63 +public class HackyProjectDependencyUpgraderImpl extends ProjectDependencyUpgrader {
258.64 +
258.65 + public boolean ensureDependency(Project currentProject, FileObject depFO, SpecificationVersion spec, final boolean canShowUI) {
258.66 + File lib = InstalledFileLocator.getDefault().locate("modules/ext/org-netbeans-modules-jackpot30-apisupport.jar", null, false);
258.67 +
258.68 + ClassLoader scl = Lookup.getDefault().lookup(ClassLoader.class);
258.69 + try {
258.70 + URLClassLoader l = new URLClassLoader(new URL[]{lib.toURI().toURL()}, scl);
258.71 + Class<?> u = Class.forName("org.netbeans.modules.jackpot30.apisupport.bridgeimpl.ProjectDependencyUpgraderImpl", false, l);
258.72 +
258.73 + return ((ProjectDependencyUpgrader) u.newInstance()).ensureDependency(currentProject, depFO, spec, canShowUI);
258.74 + } catch (InstantiationException ex) {
258.75 + Exceptions.printStackTrace(ex);
258.76 + } catch (IllegalAccessException ex) {
258.77 + Exceptions.printStackTrace(ex);
258.78 + } catch (ClassNotFoundException ex) {
258.79 + Exceptions.printStackTrace(ex);
258.80 + } catch (MalformedURLException ex) {
258.81 + Exceptions.printStackTrace(ex);
258.82 + }
258.83 +
258.84 + return false;
258.85 + }
258.86 +
258.87 + @Override
258.88 + public boolean ensureDependency(Project p, String specification, boolean b) {
258.89 + File lib = InstalledFileLocator.getDefault().locate("modules/ext/org-netbeans-modules-jackpot30-apisupport.jar", null, false);
258.90 +
258.91 + ClassLoader scl = Lookup.getDefault().lookup(ClassLoader.class);
258.92 + try {
258.93 + URLClassLoader l = new URLClassLoader(new URL[]{lib.toURI().toURL()}, scl);
258.94 + Class<?> u = Class.forName("org.netbeans.modules.jackpot30.apisupport.bridgeimpl.ProjectDependencyUpgraderImpl", false, l);
258.95 +
258.96 + return ((ProjectDependencyUpgrader) u.newInstance()).ensureDependency(p, specification, b);
258.97 + } catch (InstantiationException ex) {
258.98 + Exceptions.printStackTrace(ex);
258.99 + } catch (IllegalAccessException ex) {
258.100 + Exceptions.printStackTrace(ex);
258.101 + } catch (ClassNotFoundException ex) {
258.102 + Exceptions.printStackTrace(ex);
258.103 + } catch (MalformedURLException ex) {
258.104 + Exceptions.printStackTrace(ex);
258.105 + }
258.106 +
258.107 + return false;
258.108 + }
258.109 +
258.110 +}
259.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
259.2 +++ b/language/ide/bridges/apisupport/src/org/netbeans/modules/jackpot30/apisupport/Installer.java Mon Mar 12 21:10:10 2012 +0100
259.3 @@ -0,0 +1,70 @@
259.4 +/*
259.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
259.6 + *
259.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
259.8 + *
259.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
259.10 + * Other names may be trademarks of their respective owners.
259.11 + *
259.12 + * The contents of this file are subject to the terms of either the GNU General
259.13 + * Public License Version 2 only ("GPL") or the Common Development and
259.14 + * Distribution License("CDDL") (collectively, the "License"). You may not use
259.15 + * this file except in compliance with the License. You can obtain a copy of the
259.16 + * License at http://www.netbeans.org/cddl-gplv2.html or
259.17 + * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
259.18 + * governing permissions and limitations under the License. When distributing
259.19 + * the software, include this License Header Notice in each file and include the
259.20 + * License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
259.21 + * particular file as subject to the "Classpath" exception as provided by Oracle
259.22 + * in the GPL Version 2 section of the License file that accompanied this code.
259.23 + * If applicable, add the following below the License Header, with the fields
259.24 + * enclosed by brackets [] replaced by your own identifying information:
259.25 + * "Portions Copyrighted [year] [name of copyright owner]"
259.26 + *
259.27 + * If you wish your version of this file to be governed by only the CDDL or only
259.28 + * the GPL Version 2, indicate your decision by adding "[Contributor] elects to
259.29 + * include this software in this distribution under the [CDDL or GPL Version 2]
259.30 + * license." If you do not indicate a single choice of license, a recipient has
259.31 + * the option to distribute your version of this file under either the CDDL, the
259.32 + * GPL Version 2 or to extend the choice of license to its licensees as provided
259.33 + * above. However, if you add GPL Version 2 code and therefore, elected the GPL
259.34 + * Version 2 license, then the option applies only if the new code is made
259.35 + * subject to such option by the copyright holder.
259.36 + *
259.37 + * Contributor(s):
259.38 + *
259.39 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
259.40 + */
259.41 +package org.netbeans.modules.jackpot30.apisupport;
259.42 +
259.43 +import java.lang.reflect.Field;
259.44 +import java.lang.reflect.Method;
259.45 +import java.util.Set;
259.46 +import org.openide.modules.ModuleInstall;
259.47 +
259.48 +public class Installer extends ModuleInstall {
259.49 +
259.50 + @Override
259.51 + @SuppressWarnings("unchecked")
259.52 + public void validate() throws IllegalStateException {
259.53 + try {
259.54 + java.lang.Class main = java.lang.Class.forName("org.netbeans.core.startup.Main", false, //NOI18N
259.55 + Thread.currentThread().getContextClassLoader());
259.56 + Method getModuleSystem = main.getMethod("getModuleSystem", new Class[0]); //NOI18N
259.57 + Object moduleSystem = getModuleSystem.invoke(null, new Object[0]);
259.58 + Method getManager = moduleSystem.getClass().getMethod("getManager", new Class[0]); //NOI18N
259.59 + Object moduleManager = getManager.invoke(moduleSystem, new Object[0]);
259.60 + Method moduleMeth = moduleManager.getClass().getMethod("get", new Class[] {String.class}); //NOI18N
259.61 + Object persistence = moduleMeth.invoke(moduleManager, "org.netbeans.modules.apisupport.project"); //NOI18N
259.62 + if (persistence != null) {
259.63 + Field frField = persistence.getClass().getSuperclass().getDeclaredField("friendNames"); //NOI18N
259.64 + frField.setAccessible(true);
259.65 + Set friends = (Set)frField.get(persistence);
259.66 + friends.add("org.netbeans.modules.jackpot30.apisupport"); //NOI18N
259.67 + }
259.68 + } catch (Exception ex) {
259.69 + new IllegalStateException("Cannot fix dependencies for org.netbeans.modules.jackpot30.apisupport.", ex); //NOI18N
259.70 + }
259.71 + super.validate();
259.72 + }
259.73 +}
260.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
260.2 +++ b/language/ide/bridges/apisupport/src/org/netbeans/modules/jackpot30/apisupport/ProjectDependencyUpgraderMultiplexor.java Mon Mar 12 21:10:10 2012 +0100
260.3 @@ -0,0 +1,63 @@
260.4 +/*
260.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
260.6 + *
260.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
260.8 + *
260.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
260.10 + * Other names may be trademarks of their respective owners.
260.11 + *
260.12 + * The contents of this file are subject to the terms of either the GNU General
260.13 + * Public License Version 2 only ("GPL") or the Common Development and
260.14 + * Distribution License("CDDL") (collectively, the "License"). You may not use
260.15 + * this file except in compliance with the License. You can obtain a copy of the
260.16 + * License at http://www.netbeans.org/cddl-gplv2.html or
260.17 + * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
260.18 + * governing permissions and limitations under the License. When distributing
260.19 + * the software, include this License Header Notice in each file and include the
260.20 + * License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
260.21 + * particular file as subject to the "Classpath" exception as provided by Oracle
260.22 + * in the GPL Version 2 section of the License file that accompanied this code.
260.23 + * If applicable, add the following below the License Header, with the fields
260.24 + * enclosed by brackets [] replaced by your own identifying information:
260.25 + * "Portions Copyrighted [year] [name of copyright owner]"
260.26 + *
260.27 + * If you wish your version of this file to be governed by only the CDDL or only
260.28 + * the GPL Version 2, indicate your decision by adding "[Contributor] elects to
260.29 + * include this software in this distribution under the [CDDL or GPL Version 2]
260.30 + * license." If you do not indicate a single choice of license, a recipient has
260.31 + * the option to distribute your version of this file under either the CDDL, the
260.32 + * GPL Version 2 or to extend the choice of license to its licensees as provided
260.33 + * above. However, if you add GPL Version 2 code and therefore, elected the GPL
260.34 + * Version 2 license, then the option applies only if the new code is made
260.35 + * subject to such option by the copyright holder.
260.36 + *
260.37 + * Contributor(s):
260.38 + *
260.39 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
260.40 + */
260.41 +package org.netbeans.modules.jackpot30.apisupport;
260.42 +
260.43 +import org.netbeans.api.project.Project;
260.44 +import org.netbeans.modules.java.hints.jackpot.spi.ProjectDependencyUpgrader;
260.45 +import org.openide.filesystems.FileObject;
260.46 +import org.openide.modules.SpecificationVersion;
260.47 +import org.openide.util.lookup.ServiceProvider;
260.48 +
260.49 +/**
260.50 + *
260.51 + * @author lahvac
260.52 + */
260.53 +@ServiceProvider(service=ProjectDependencyUpgrader.class)
260.54 +public class ProjectDependencyUpgraderMultiplexor extends ProjectDependencyUpgrader {
260.55 +
260.56 + @Override
260.57 + public boolean ensureDependency(Project p, FileObject dep, SpecificationVersion spec, boolean canShowUI) {
260.58 + return Utilities.UPGRADER.ensureDependency(p, dep, spec, canShowUI);
260.59 + }
260.60 +
260.61 + @Override
260.62 + public boolean ensureDependency(Project p, String specification, boolean b) {
260.63 + return Utilities.UPGRADER.ensureDependency(p, specification, b);
260.64 + }
260.65 +
260.66 +}
261.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
261.2 +++ b/language/ide/bridges/apisupport/src/org/netbeans/modules/jackpot30/apisupport/Utilities.java Mon Mar 12 21:10:10 2012 +0100
261.3 @@ -0,0 +1,88 @@
261.4 +/*
261.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
261.6 + *
261.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
261.8 + *
261.9 + * The contents of this file are subject to the terms of either the GNU
261.10 + * General Public License Version 2 only ("GPL") or the Common
261.11 + * Development and Distribution License("CDDL") (collectively, the
261.12 + * "License"). You may not use this file except in compliance with the
261.13 + * License. You can obtain a copy of the License at
261.14 + * http://www.netbeans.org/cddl-gplv2.html
261.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
261.16 + * specific language governing permissions and limitations under the
261.17 + * License. When distributing the software, include this License Header
261.18 + * Notice in each file and include the License file at
261.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
261.20 + * particular file as subject to the "Classpath" exception as provided
261.21 + * by Sun in the GPL Version 2 section of the License file that
261.22 + * accompanied this code. If applicable, add the following below the
261.23 + * License Header, with the fields enclosed by brackets [] replaced by
261.24 + * your own identifying information:
261.25 + * "Portions Copyrighted [year] [name of copyright owner]"
261.26 + *
261.27 + * If you wish your version of this file to be governed by only the CDDL
261.28 + * or only the GPL Version 2, indicate your decision by adding
261.29 + * "[Contributor] elects to include this software in this distribution
261.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
261.31 + * single choice of license, a recipient has the option to distribute
261.32 + * your version of this file under either the CDDL, the GPL Version 2 or
261.33 + * to extend the choice of license to its licensees as provided above.
261.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
261.35 + * Version 2 license, then the option applies only if the new code is
261.36 + * made subject to such option by the copyright holder.
261.37 + *
261.38 + * Contributor(s):
261.39 + *
261.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
261.41 + */
261.42 +
261.43 +package org.netbeans.modules.jackpot30.apisupport;
261.44 +
261.45 +import org.netbeans.modules.java.hints.jackpot.spi.ProjectDependencyUpgrader;
261.46 +import org.openide.modules.SpecificationVersion;
261.47 +
261.48 +/**
261.49 + *
261.50 + * @author lahvac
261.51 + */
261.52 +public class Utilities {
261.53 +
261.54 + public static final ProjectDependencyUpgrader UPGRADER = Boolean.getBoolean("jackpot.upgrade.apisupport.use.api") ? new APIProjectDependencyUpgraderImpl() : new HackyProjectDependencyUpgraderImpl();
261.55 +
261.56 + public static ParsedDependency parseDependency(String spec) {
261.57 + String cnb;
261.58 + String releaseVersion;
261.59 + SpecificationVersion specVersion;
261.60 +
261.61 + String[] spaceSplit = spec.split(" ");
261.62 + String[] slashSplit = spaceSplit[0].split(" ");
261.63 +
261.64 + cnb = slashSplit[0];
261.65 +
261.66 + if (slashSplit.length > 1) {
261.67 + releaseVersion = slashSplit[1];
261.68 + } else {
261.69 + releaseVersion = null;
261.70 + }
261.71 +
261.72 + if (spaceSplit.length > 1) {
261.73 + specVersion = new SpecificationVersion(spaceSplit[1]);//XXX verify correct format
261.74 + } else {
261.75 + specVersion = null;
261.76 + }
261.77 +
261.78 + return new ParsedDependency(cnb, releaseVersion, specVersion);
261.79 + }
261.80 +
261.81 + public static class ParsedDependency {
261.82 + public final String cnb;
261.83 + public final String releaseVersion;
261.84 + public final SpecificationVersion specVersion;
261.85 + public ParsedDependency(String cnb, String releaseVersion, SpecificationVersion specVersion) {
261.86 + this.cnb = cnb;
261.87 + this.releaseVersion = releaseVersion;
261.88 + this.specVersion = specVersion;
261.89 + }
261.90 + }
261.91 +}
262.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
262.2 +++ b/language/ide/build.xml Mon Mar 12 21:10:10 2012 +0100
262.3 @@ -0,0 +1,8 @@
262.4 +<?xml version="1.0" encoding="UTF-8"?>
262.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
262.6 +<!-- for some information on what you could do (e.g. targets to override). -->
262.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
262.8 +<project name="language-ide" basedir=".">
262.9 + <description>Builds the module suite language.</description>
262.10 + <import file="nbproject/build-impl.xml"/>
262.11 +</project>
263.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
263.2 +++ b/language/ide/indexing/build.xml Mon Mar 12 21:10:10 2012 +0100
263.3 @@ -0,0 +1,9 @@
263.4 +<?xml version="1.0" encoding="UTF-8"?>
263.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
263.6 +<!-- for some information on what you could do (e.g. targets to override). -->
263.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
263.8 +<project name="org.netbeans.modules.jackpot30.indexing" default="netbeans" basedir=".">
263.9 + <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.indexing.</description>
263.10 + <import file="nbproject/build-impl.xml"/>
263.11 + <import file="../../../findbugs-import.xml" />
263.12 +</project>
264.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
264.2 +++ b/language/ide/indexing/manifest.mf Mon Mar 12 21:10:10 2012 +0100
264.3 @@ -0,0 +1,5 @@
264.4 +Manifest-Version: 1.0
264.5 +OpenIDE-Module: org.netbeans.modules.jackpot30.indexing
264.6 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/indexing/Bundle.properties
264.7 +OpenIDE-Module-Specification-Version: 1.0
264.8 +
265.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
265.2 +++ b/language/ide/indexing/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
265.3 @@ -0,0 +1,45 @@
265.4 +<?xml version="1.0" encoding="UTF-8"?>
265.5 +<!--
265.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
265.7 +*** EDIT ../build.xml INSTEAD ***
265.8 +-->
265.9 +<project name="org.netbeans.modules.jackpot30.indexing-impl" basedir="..">
265.10 + <fail message="Please build using Ant 1.7.1 or higher.">
265.11 + <condition>
265.12 + <not>
265.13 + <antversion atleast="1.7.1"/>
265.14 + </not>
265.15 + </condition>
265.16 + </fail>
265.17 + <property file="nbproject/private/suite-private.properties"/>
265.18 + <property file="nbproject/suite.properties"/>
265.19 + <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
265.20 + <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
265.21 + <property file="${suite.dir}/nbproject/platform.properties"/>
265.22 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
265.23 + <attribute name="name"/>
265.24 + <attribute name="value"/>
265.25 + <sequential>
265.26 + <property name="@{name}" value="${@{value}}"/>
265.27 + </sequential>
265.28 + </macrodef>
265.29 + <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
265.30 + <attribute name="property"/>
265.31 + <attribute name="value"/>
265.32 + <sequential>
265.33 + <property name="@{property}" value="@{value}"/>
265.34 + </sequential>
265.35 + </macrodef>
265.36 + <property file="${user.properties.file}"/>
265.37 + <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
265.38 + <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
265.39 + <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
265.40 + <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
265.41 + <condition>
265.42 + <not>
265.43 + <contains string="${cluster.path.evaluated}" substring="platform"/>
265.44 + </not>
265.45 + </condition>
265.46 + </fail>
265.47 + <import file="${harness.dir}/build.xml"/>
265.48 +</project>
266.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
266.2 +++ b/language/ide/indexing/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
266.3 @@ -0,0 +1,8 @@
266.4 +build.xml.data.CRC32=68c5618a
266.5 +build.xml.script.CRC32=f0946049
266.6 +build.xml.stylesheet.CRC32=a56c6a5b@2.49
266.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
266.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
266.9 +nbproject/build-impl.xml.data.CRC32=e26fc52c
266.10 +nbproject/build-impl.xml.script.CRC32=d49586b3
266.11 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.49
267.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
267.2 +++ b/language/ide/indexing/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
267.3 @@ -0,0 +1,2 @@
267.4 +javac.source=1.6
267.5 +javac.compilerargs=-Xlint -Xlint:-serial
268.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
268.2 +++ b/language/ide/indexing/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
268.3 @@ -0,0 +1,389 @@
268.4 +<?xml version="1.0" encoding="UTF-8"?>
268.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
268.6 + <type>org.netbeans.modules.apisupport.project</type>
268.7 + <configuration>
268.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
268.9 + <code-name-base>org.netbeans.modules.jackpot30.indexing</code-name-base>
268.10 + <suite-component/>
268.11 + <module-dependencies>
268.12 + <dependency>
268.13 + <code-name-base>org.jdesktop.layout</code-name-base>
268.14 + <build-prerequisite/>
268.15 + <compile-dependency/>
268.16 + <run-dependency>
268.17 + <release-version>1</release-version>
268.18 + <specification-version>1.7.0.103</specification-version>
268.19 + </run-dependency>
268.20 + </dependency>
268.21 + <dependency>
268.22 + <code-name-base>org.netbeans.api.annotations.common</code-name-base>
268.23 + <build-prerequisite/>
268.24 + <compile-dependency/>
268.25 + <run-dependency>
268.26 + <release-version>1</release-version>
268.27 + <specification-version>1.0</specification-version>
268.28 + </run-dependency>
268.29 + </dependency>
268.30 + <dependency>
268.31 + <code-name-base>org.netbeans.api.java.classpath</code-name-base>
268.32 + <build-prerequisite/>
268.33 + <compile-dependency/>
268.34 + <run-dependency>
268.35 + <release-version>1</release-version>
268.36 + <specification-version>1.19</specification-version>
268.37 + </run-dependency>
268.38 + </dependency>
268.39 + <dependency>
268.40 + <code-name-base>org.netbeans.api.progress</code-name-base>
268.41 + <build-prerequisite/>
268.42 + <compile-dependency/>
268.43 + <run-dependency>
268.44 + <release-version>1</release-version>
268.45 + <specification-version>1.13.0.1</specification-version>
268.46 + </run-dependency>
268.47 + </dependency>
268.48 + <dependency>
268.49 + <code-name-base>org.netbeans.libs.javacapi</code-name-base>
268.50 + <build-prerequisite/>
268.51 + <compile-dependency/>
268.52 + <run-dependency>
268.53 + <specification-version>7.5.0.3</specification-version>
268.54 + </run-dependency>
268.55 + </dependency>
268.56 + <dependency>
268.57 + <code-name-base>org.netbeans.libs.javacimpl</code-name-base>
268.58 + <build-prerequisite/>
268.59 + <compile-dependency/>
268.60 + <run-dependency>
268.61 + <release-version>1</release-version>
268.62 + <implementation-version/>
268.63 + </run-dependency>
268.64 + </dependency>
268.65 + <dependency>
268.66 + <code-name-base>org.netbeans.libs.lucene</code-name-base>
268.67 + <build-prerequisite/>
268.68 + <compile-dependency/>
268.69 + <run-dependency>
268.70 + <release-version>1-3</release-version>
268.71 + <specification-version>2.13</specification-version>
268.72 + </run-dependency>
268.73 + </dependency>
268.74 + <dependency>
268.75 + <code-name-base>org.netbeans.modules.diff</code-name-base>
268.76 + <build-prerequisite/>
268.77 + <compile-dependency/>
268.78 + <run-dependency>
268.79 + <release-version>1</release-version>
268.80 + <implementation-version/>
268.81 + </run-dependency>
268.82 + </dependency>
268.83 + <dependency>
268.84 + <code-name-base>org.netbeans.modules.editor</code-name-base>
268.85 + <build-prerequisite/>
268.86 + <compile-dependency/>
268.87 + <run-dependency>
268.88 + <release-version>3</release-version>
268.89 + <specification-version>1.56.0.5.13.6</specification-version>
268.90 + </run-dependency>
268.91 + </dependency>
268.92 + <dependency>
268.93 + <code-name-base>org.netbeans.modules.editor.lib</code-name-base>
268.94 + <build-prerequisite/>
268.95 + <compile-dependency/>
268.96 + <run-dependency>
268.97 + <release-version>1-3</release-version>
268.98 + <specification-version>1.38.0.9.2</specification-version>
268.99 + </run-dependency>
268.100 + </dependency>
268.101 + <dependency>
268.102 + <code-name-base>org.netbeans.modules.editor.lib2</code-name-base>
268.103 + <build-prerequisite/>
268.104 + <compile-dependency/>
268.105 + <run-dependency>
268.106 + <release-version>1</release-version>
268.107 + <specification-version>1.13.0.2</specification-version>
268.108 + </run-dependency>
268.109 + </dependency>
268.110 + <dependency>
268.111 + <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
268.112 + <build-prerequisite/>
268.113 + <compile-dependency/>
268.114 + <run-dependency>
268.115 + <release-version>1</release-version>
268.116 + <specification-version>1.12</specification-version>
268.117 + </run-dependency>
268.118 + </dependency>
268.119 + <dependency>
268.120 + <code-name-base>org.netbeans.modules.editor.settings</code-name-base>
268.121 + <build-prerequisite/>
268.122 + <compile-dependency/>
268.123 + <run-dependency>
268.124 + <release-version>1</release-version>
268.125 + <specification-version>1.25</specification-version>
268.126 + </run-dependency>
268.127 + </dependency>
268.128 + <dependency>
268.129 + <code-name-base>org.netbeans.modules.jackpot30.common</code-name-base>
268.130 + <build-prerequisite/>
268.131 + <compile-dependency/>
268.132 + <run-dependency>
268.133 + <specification-version>1.0</specification-version>
268.134 + </run-dependency>
268.135 + </dependency>
268.136 + <dependency>
268.137 + <code-name-base>org.netbeans.modules.jackpot30.remoting.api</code-name-base>
268.138 + <build-prerequisite/>
268.139 + <compile-dependency/>
268.140 + <run-dependency>
268.141 + <specification-version>1.8</specification-version>
268.142 + </run-dependency>
268.143 + </dependency>
268.144 + <dependency>
268.145 + <code-name-base>org.netbeans.modules.java.editor</code-name-base>
268.146 + <build-prerequisite/>
268.147 + <compile-dependency/>
268.148 + <run-dependency>
268.149 + <release-version>1</release-version>
268.150 + <implementation-version/>
268.151 + </run-dependency>
268.152 + </dependency>
268.153 + <dependency>
268.154 + <code-name-base>org.netbeans.modules.java.lexer</code-name-base>
268.155 + <build-prerequisite/>
268.156 + <compile-dependency/>
268.157 + <run-dependency>
268.158 + <release-version>1</release-version>
268.159 + <specification-version>1.9</specification-version>
268.160 + </run-dependency>
268.161 + </dependency>
268.162 + <dependency>
268.163 + <code-name-base>org.netbeans.modules.java.platform</code-name-base>
268.164 + <build-prerequisite/>
268.165 + <compile-dependency/>
268.166 + <run-dependency>
268.167 + <release-version>1</release-version>
268.168 + <specification-version>1.12</specification-version>
268.169 + </run-dependency>
268.170 + </dependency>
268.171 + <dependency>
268.172 + <code-name-base>org.netbeans.modules.java.preprocessorbridge</code-name-base>
268.173 + <build-prerequisite/>
268.174 + <compile-dependency/>
268.175 + <run-dependency>
268.176 + <implementation-version/>
268.177 + </run-dependency>
268.178 + </dependency>
268.179 + <dependency>
268.180 + <code-name-base>org.netbeans.modules.java.source</code-name-base>
268.181 + <build-prerequisite/>
268.182 + <compile-dependency/>
268.183 + <run-dependency>
268.184 + <implementation-version/>
268.185 + </run-dependency>
268.186 + </dependency>
268.187 + <dependency>
268.188 + <code-name-base>org.netbeans.modules.lexer</code-name-base>
268.189 + <build-prerequisite/>
268.190 + <compile-dependency/>
268.191 + <run-dependency>
268.192 + <release-version>2</release-version>
268.193 + <specification-version>1.34</specification-version>
268.194 + </run-dependency>
268.195 + </dependency>
268.196 + <dependency>
268.197 + <code-name-base>org.netbeans.modules.options.api</code-name-base>
268.198 + <build-prerequisite/>
268.199 + <compile-dependency/>
268.200 + <run-dependency>
268.201 + <release-version>1</release-version>
268.202 + <specification-version>1.20</specification-version>
268.203 + </run-dependency>
268.204 + </dependency>
268.205 + <dependency>
268.206 + <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
268.207 + <build-prerequisite/>
268.208 + <compile-dependency/>
268.209 + <run-dependency>
268.210 + <release-version>1</release-version>
268.211 + <implementation-version/>
268.212 + </run-dependency>
268.213 + </dependency>
268.214 + <dependency>
268.215 + <code-name-base>org.netbeans.modules.projectapi</code-name-base>
268.216 + <build-prerequisite/>
268.217 + <compile-dependency/>
268.218 + <run-dependency>
268.219 + <release-version>1</release-version>
268.220 + <specification-version>1.24</specification-version>
268.221 + </run-dependency>
268.222 + </dependency>
268.223 + <dependency>
268.224 + <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
268.225 + <build-prerequisite/>
268.226 + <compile-dependency/>
268.227 + <run-dependency>
268.228 + <release-version>1</release-version>
268.229 + <specification-version>1.35.0.6</specification-version>
268.230 + </run-dependency>
268.231 + </dependency>
268.232 + <dependency>
268.233 + <code-name-base>org.netbeans.modules.queries</code-name-base>
268.234 + <build-prerequisite/>
268.235 + <compile-dependency/>
268.236 + <run-dependency>
268.237 + <release-version>1</release-version>
268.238 + <specification-version>1.15</specification-version>
268.239 + </run-dependency>
268.240 + </dependency>
268.241 + <dependency>
268.242 + <code-name-base>org.netbeans.modules.refactoring.api</code-name-base>
268.243 + <build-prerequisite/>
268.244 + <compile-dependency/>
268.245 + <run-dependency>
268.246 + <specification-version>1.6</specification-version>
268.247 + </run-dependency>
268.248 + </dependency>
268.249 + <dependency>
268.250 + <code-name-base>org.netbeans.modules.refactoring.java</code-name-base>
268.251 + <build-prerequisite/>
268.252 + <compile-dependency/>
268.253 + <run-dependency>
268.254 + <release-version>1</release-version>
268.255 + <specification-version>1.6</specification-version>
268.256 + </run-dependency>
268.257 + </dependency>
268.258 + <dependency>
268.259 + <code-name-base>org.netbeans.modules.sendopts</code-name-base>
268.260 + <build-prerequisite/>
268.261 + <compile-dependency/>
268.262 + <run-dependency>
268.263 + <release-version>2</release-version>
268.264 + <specification-version>2.4</specification-version>
268.265 + </run-dependency>
268.266 + </dependency>
268.267 + <dependency>
268.268 + <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
268.269 + <build-prerequisite/>
268.270 + <compile-dependency/>
268.271 + <run-dependency>
268.272 + <release-version>0-1</release-version>
268.273 + <specification-version>1.7.0.7.2</specification-version>
268.274 + </run-dependency>
268.275 + </dependency>
268.276 + <dependency>
268.277 + <code-name-base>org.netbeans.spi.java.hints</code-name-base>
268.278 + <build-prerequisite/>
268.279 + <compile-dependency/>
268.280 + <run-dependency>
268.281 + <implementation-version/>
268.282 + </run-dependency>
268.283 + </dependency>
268.284 + <dependency>
268.285 + <code-name-base>org.openide.awt</code-name-base>
268.286 + <build-prerequisite/>
268.287 + <compile-dependency/>
268.288 + <run-dependency>
268.289 + <specification-version>7.7.0.1</specification-version>
268.290 + </run-dependency>
268.291 + </dependency>
268.292 + <dependency>
268.293 + <code-name-base>org.openide.dialogs</code-name-base>
268.294 + <build-prerequisite/>
268.295 + <compile-dependency/>
268.296 + <run-dependency>
268.297 + <specification-version>7.10</specification-version>
268.298 + </run-dependency>
268.299 + </dependency>
268.300 + <dependency>
268.301 + <code-name-base>org.openide.filesystems</code-name-base>
268.302 + <build-prerequisite/>
268.303 + <compile-dependency/>
268.304 + <run-dependency>
268.305 + <specification-version>7.21.0.1.1</specification-version>
268.306 + </run-dependency>
268.307 + </dependency>
268.308 + <dependency>
268.309 + <code-name-base>org.openide.loaders</code-name-base>
268.310 + <build-prerequisite/>
268.311 + <compile-dependency/>
268.312 + <run-dependency>
268.313 + <specification-version>7.5</specification-version>
268.314 + </run-dependency>
268.315 + </dependency>
268.316 + <dependency>
268.317 + <code-name-base>org.openide.modules</code-name-base>
268.318 + <build-prerequisite/>
268.319 + <compile-dependency/>
268.320 + <run-dependency>
268.321 + <specification-version>7.10</specification-version>
268.322 + </run-dependency>
268.323 + </dependency>
268.324 + <dependency>
268.325 + <code-name-base>org.openide.nodes</code-name-base>
268.326 + <build-prerequisite/>
268.327 + <compile-dependency/>
268.328 + <run-dependency>
268.329 + <specification-version>7.9.0.1</specification-version>
268.330 + </run-dependency>
268.331 + </dependency>
268.332 + <dependency>
268.333 + <code-name-base>org.openide.text</code-name-base>
268.334 + <build-prerequisite/>
268.335 + <compile-dependency/>
268.336 + <run-dependency>
268.337 + <specification-version>6.22</specification-version>
268.338 + </run-dependency>
268.339 + </dependency>
268.340 + <dependency>
268.341 + <code-name-base>org.openide.util</code-name-base>
268.342 + <build-prerequisite/>
268.343 + <compile-dependency/>
268.344 + <run-dependency>
268.345 + <specification-version>8.0</specification-version>
268.346 + </run-dependency>
268.347 + </dependency>
268.348 + <dependency>
268.349 + <code-name-base>org.openide.util.lookup</code-name-base>
268.350 + <build-prerequisite/>
268.351 + <compile-dependency/>
268.352 + <run-dependency>
268.353 + <specification-version>8.0.0.1</specification-version>
268.354 + </run-dependency>
268.355 + </dependency>
268.356 + <dependency>
268.357 + <code-name-base>org.openide.windows</code-name-base>
268.358 + <build-prerequisite/>
268.359 + <compile-dependency/>
268.360 + <run-dependency>
268.361 + <specification-version>6.27</specification-version>
268.362 + </run-dependency>
268.363 + </dependency>
268.364 + </module-dependencies>
268.365 + <test-dependencies>
268.366 + <test-type>
268.367 + <name>unit</name>
268.368 + <test-dependency>
268.369 + <code-name-base>org.netbeans.libs.junit4</code-name-base>
268.370 + <compile-dependency/>
268.371 + </test-dependency>
268.372 + <test-dependency>
268.373 + <code-name-base>org.netbeans.modules.jackpot30.common.test</code-name-base>
268.374 + <recursive/>
268.375 + <compile-dependency/>
268.376 + </test-dependency>
268.377 + <test-dependency>
268.378 + <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
268.379 + <recursive/>
268.380 + <compile-dependency/>
268.381 + </test-dependency>
268.382 + <test-dependency>
268.383 + <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
268.384 + <recursive/>
268.385 + <compile-dependency/>
268.386 + </test-dependency>
268.387 + </test-type>
268.388 + </test-dependencies>
268.389 + <public-packages/>
268.390 + </data>
268.391 + </configuration>
268.392 +</project>
269.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
269.2 +++ b/language/ide/indexing/nbproject/suite.properties Mon Mar 12 21:10:10 2012 +0100
269.3 @@ -0,0 +1,1 @@
269.4 +suite.dir=${basedir}/..
270.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
270.2 +++ b/language/ide/indexing/src/org/netbeans/modules/jackpot30/indexing/Bundle.properties Mon Mar 12 21:10:10 2012 +0100
270.3 @@ -0,0 +1,1 @@
270.4 +OpenIDE-Module-Name=Jackpot 3.0 Indexing
271.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
271.2 +++ b/language/ide/indexing/src/org/netbeans/modules/jackpot30/indexing/batch/BatchUtilities.java Mon Mar 12 21:10:10 2012 +0100
271.3 @@ -0,0 +1,121 @@
271.4 +/*
271.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
271.6 + *
271.7 + * Copyright 2008-2010 Sun Microsystems, Inc. All rights reserved.
271.8 + *
271.9 + * The contents of this file are subject to the terms of either the GNU
271.10 + * General Public License Version 2 only ("GPL") or the Common
271.11 + * Development and Distribution License("CDDL") (collectively, the
271.12 + * "License"). You may not use this file except in compliance with the
271.13 + * License. You can obtain a copy of the License at
271.14 + * http://www.netbeans.org/cddl-gplv2.html
271.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
271.16 + * specific language governing permissions and limitations under the
271.17 + * License. When distributing the software, include this License Header
271.18 + * Notice in each file and include the License file at
271.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
271.20 + * particular file as subject to the "Classpath" exception as provided
271.21 + * by Sun in the GPL Version 2 section of the License file that
271.22 + * accompanied this code. If applicable, add the following below the
271.23 + * License Header, with the fields enclosed by brackets [] replaced by
271.24 + * your own identifying information:
271.25 + * "Portions Copyrighted [year] [name of copyright owner]"
271.26 + *
271.27 + * If you wish your version of this file to be governed by only the CDDL
271.28 + * or only the GPL Version 2, indicate your decision by adding
271.29 + * "[Contributor] elects to include this software in this distribution
271.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
271.31 + * single choice of license, a recipient has the option to distribute
271.32 + * your version of this file under either the CDDL, the GPL Version 2 or
271.33 + * to extend the choice of license to its licensees as provided above.
271.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
271.35 + * Version 2 license, then the option applies only if the new code is
271.36 + * made subject to such option by the copyright holder.
271.37 + *
271.38 + * Contributor(s):
271.39 + *
271.40 + * Portions Copyrighted 2008-2010 Sun Microsystems, Inc.
271.41 + */
271.42 +
271.43 +package org.netbeans.modules.jackpot30.indexing.batch;
271.44 +
271.45 +import java.io.IOException;
271.46 +import java.io.Reader;
271.47 +import java.io.StringReader;
271.48 +import java.io.Writer;
271.49 +import java.nio.charset.Charset;
271.50 +import org.netbeans.api.annotations.common.NullAllowed;
271.51 +import org.netbeans.api.java.source.ModificationResult;
271.52 +import org.netbeans.api.queries.FileEncodingQuery;
271.53 +import org.netbeans.modules.diff.builtin.provider.BuiltInDiffProvider;
271.54 +import org.netbeans.modules.diff.builtin.visualizer.TextDiffVisualizer;
271.55 +import org.netbeans.spi.diff.DiffProvider;
271.56 +import org.openide.filesystems.FileObject;
271.57 +import org.openide.filesystems.FileUtil;
271.58 +
271.59 +/**
271.60 + *
271.61 + * @author Jan Lahoda
271.62 + */
271.63 +public class BatchUtilities {
271.64 +
271.65 + public static void exportDiff(ModificationResult result, @NullAllowed FileObject relativeTo, Writer out) throws IOException {
271.66 + for (FileObject f : result.getModifiedFileObjects()) {
271.67 + Charset c = FileEncodingQuery.getEncoding(f);
271.68 + String orig = new String(f.asBytes(), c);
271.69 + String nue = result.getResultingSource(f);
271.70 +
271.71 + if (orig.equals(nue)) {
271.72 + continue;
271.73 + }
271.74 +
271.75 + String name = relativeTo != null ? FileUtil.getRelativePath(relativeTo, f) : FileUtil.toFile(f).getAbsolutePath();
271.76 +
271.77 + doExportDiff(name, orig, nue, out);
271.78 + }
271.79 + }
271.80 +
271.81 + //copied from the diff module:
271.82 + private static void doExportDiff(String name, String original, String modified, Writer out) throws IOException {
271.83 + DiffProvider diff = new BuiltInDiffProvider();//(DiffProvider) Lookup.getDefault().lookup(DiffProvider.class);
271.84 +
271.85 + Reader r1 = null;
271.86 + Reader r2 = null;
271.87 + org.netbeans.api.diff.Difference[] differences;
271.88 +
271.89 + try {
271.90 + r1 = new StringReader(original);
271.91 + r2 = new StringReader(modified);
271.92 + differences = diff.computeDiff(r1, r2);
271.93 + } finally {
271.94 + if (r1 != null) try { r1.close(); } catch (Exception e) {}
271.95 + if (r2 != null) try { r2.close(); } catch (Exception e) {}
271.96 + }
271.97 +
271.98 + try {
271.99 + r1 = new StringReader(original);
271.100 + r2 = new StringReader(modified);
271.101 + TextDiffVisualizer.TextDiffInfo info = new TextDiffVisualizer.TextDiffInfo(
271.102 + name, // NOI18N
271.103 + name, // NOI18N
271.104 + null,
271.105 + null,
271.106 + r1,
271.107 + r2,
271.108 + differences
271.109 + );
271.110 + info.setContextMode(true, 3);
271.111 + String diffText;
271.112 +// if (format == unifiedFilter) {
271.113 + diffText = TextDiffVisualizer.differenceToUnifiedDiffText(info);
271.114 +// } else {
271.115 +// diffText = TextDiffVisualizer.differenceToNormalDiffText(info);
271.116 +// }
271.117 + out.write(diffText);
271.118 + } finally {
271.119 + if (r1 != null) try { r1.close(); } catch (Exception e) {}
271.120 + if (r2 != null) try { r2.close(); } catch (Exception e) {}
271.121 + }
271.122 + }
271.123 +
271.124 +}
272.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
272.2 +++ b/language/ide/indexing/src/org/netbeans/modules/jackpot30/indexing/batch/Bundle.properties Mon Mar 12 21:10:10 2012 +0100
272.3 @@ -0,0 +1,49 @@
272.4 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
272.5 +#
272.6 +# Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
272.7 +#
272.8 +# The contents of this file are subject to the terms of either the GNU
272.9 +# General Public License Version 2 only ("GPL") or the Common
272.10 +# Development and Distribution License("CDDL") (collectively, the
272.11 +# "License"). You may not use this file except in compliance with the
272.12 +# License. You can obtain a copy of the License at
272.13 +# http://www.netbeans.org/cddl-gplv2.html
272.14 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
272.15 +# specific language governing permissions and limitations under the
272.16 +# License. When distributing the software, include this License Header
272.17 +# Notice in each file and include the License file at
272.18 +# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
272.19 +# particular file as subject to the "Classpath" exception as provided
272.20 +# by Sun in the GPL Version 2 section of the License file that
272.21 +# accompanied this code. If applicable, add the following below the
272.22 +# License Header, with the fields enclosed by brackets [] replaced by
272.23 +# your own identifying information:
272.24 +# "Portions Copyrighted [year] [name of copyright owner]"
272.25 +#
272.26 +# Contributor(s):
272.27 +#
272.28 +#The Original Software is NetBeans. The Initial Developer of the Original
272.29 +# Software is Sun Microsystems, Inc. Portions Copyright 2008-2009 Sun
272.30 +#Microsystems, Inc. All Rights Reserved.
272.31 +#
272.32 +# If you wish your version of this file to be governed by only the CDDL
272.33 +# or only the GPL Version 2, indicate your decision by adding
272.34 +# "[Contributor] elects to include this software in this distribution
272.35 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
272.36 +# single choice of license, a recipient has the option to distribute
272.37 +# your version of this file under either the CDDL, the GPL Version 2 or
272.38 +# to extend the choice of license to its licensees as provided above.
272.39 +# However, if you add GPL Version 2 code and therefore, elected the GPL
272.40 +# Version 2 license, then the option applies only if the new code is
272.41 +# made subject to such option by the copyright holder.
272.42 +
272.43 +CTL_BatchApplyAction=Batch Apply Hint
272.44 +SD_ApplyTransformations=applies specified transformation(s) on specified project or all opened projects
272.45 +SD_ApplyTransformationsProject=projects on which the transformations should be applied
272.46 +SelectHint.jLabel1.text=Select Hint:
272.47 +SelectHint.addHint.text=>>
272.48 +SelectHint.addAllHints.text=>>>
272.49 +SelectHint.removeHint.text=<<
272.50 +SelectHint.removeAllHints.text=<<<
272.51 +SelectHint.selectedHintsLabel.text=Selected Hints
272.52 +SelectHint.allHintsLabel.text_1=All Hints:
273.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
273.2 +++ b/language/ide/indexing/src/org/netbeans/modules/jackpot30/indexing/batch/EnhancedScopes.java Mon Mar 12 21:10:10 2012 +0100
273.3 @@ -0,0 +1,497 @@
273.4 +/*
273.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
273.6 + *
273.7 + * Copyright 2009-2011 Sun Microsystems, Inc. All rights reserved.
273.8 + *
273.9 + * The contents of this file are subject to the terms of either the GNU
273.10 + * General Public License Version 2 only ("GPL") or the Common
273.11 + * Development and Distribution License("CDDL") (collectively, the
273.12 + * "License"). You may not use this file except in compliance with the
273.13 + * License. You can obtain a copy of the License at
273.14 + * http://www.netbeans.org/cddl-gplv2.html
273.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
273.16 + * specific language governing permissions and limitations under the
273.17 + * License. When distributing the software, include this License Header
273.18 + * Notice in each file and include the License file at
273.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
273.20 + * particular file as subject to the "Classpath" exception as provided
273.21 + * by Sun in the GPL Version 2 section of the License file that
273.22 + * accompanied this code. If applicable, add the following below the
273.23 + * License Header, with the fields enclosed by brackets [] replaced by
273.24 + * your own identifying information:
273.25 + * "Portions Copyrighted [year] [name of copyright owner]"
273.26 + *
273.27 + * If you wish your version of this file to be governed by only the CDDL
273.28 + * or only the GPL Version 2, indicate your decision by adding
273.29 + * "[Contributor] elects to include this software in this distribution
273.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
273.31 + * single choice of license, a recipient has the option to distribute
273.32 + * your version of this file under either the CDDL, the GPL Version 2 or
273.33 + * to extend the choice of license to its licensees as provided above.
273.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
273.35 + * Version 2 license, then the option applies only if the new code is
273.36 + * made subject to such option by the copyright holder.
273.37 + *
273.38 + * Contributor(s):
273.39 + *
273.40 + * Portions Copyrighted 2009-2011 Sun Microsystems, Inc.
273.41 + */
273.42 +
273.43 +package org.netbeans.modules.jackpot30.indexing.batch;
273.44 +
273.45 +import java.io.BufferedInputStream;
273.46 +import java.io.BufferedOutputStream;
273.47 +import java.io.File;
273.48 +import java.io.FileInputStream;
273.49 +import java.io.FileOutputStream;
273.50 +import java.io.IOException;
273.51 +import java.io.InputStream;
273.52 +import java.io.OutputStream;
273.53 +import java.net.MalformedURLException;
273.54 +import java.net.URI;
273.55 +import java.net.URISyntaxException;
273.56 +import java.net.URL;
273.57 +import java.util.ArrayList;
273.58 +import java.util.Collection;
273.59 +import java.util.Collections;
273.60 +import java.util.HashMap;
273.61 +import java.util.HashSet;
273.62 +import java.util.Iterator;
273.63 +import java.util.LinkedList;
273.64 +import java.util.List;
273.65 +import java.util.Map;
273.66 +import java.util.Map.Entry;
273.67 +import java.util.Properties;
273.68 +import java.util.Set;
273.69 +import java.util.concurrent.Callable;
273.70 +import java.util.concurrent.atomic.AtomicBoolean;
273.71 +import java.util.logging.Level;
273.72 +import java.util.logging.Logger;
273.73 +import org.codeviation.pojson.Pojson;
273.74 +import org.netbeans.api.java.classpath.ClassPath;
273.75 +import org.netbeans.api.java.source.ClasspathInfo;
273.76 +import org.netbeans.api.java.source.CompilationController;
273.77 +import org.netbeans.api.java.source.JavaSource;
273.78 +import org.netbeans.api.java.source.Task;
273.79 +import org.netbeans.modules.jackpot30.indexing.index.IndexQuery;
273.80 +import org.netbeans.modules.jackpot30.indexing.index.Indexer;
273.81 +import org.netbeans.modules.jackpot30.remoting.api.RemoteIndex;
273.82 +import org.netbeans.modules.jackpot30.remoting.api.WebUtilities;
273.83 +import static org.netbeans.modules.jackpot30.remoting.api.WebUtilities.escapeForQuery;
273.84 +import org.netbeans.modules.java.hints.providers.spi.HintDescription;
273.85 +import org.netbeans.modules.java.hints.providers.spi.Trigger.PatternDescription;
273.86 +import org.netbeans.modules.java.hints.spiimpl.MessageImpl;
273.87 +import org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch.Folder;
273.88 +import org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch.IndexEnquirer;
273.89 +import org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch.LocalIndexEnquirer;
273.90 +import org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch.MapIndices;
273.91 +import org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch.Resource;
273.92 +import org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch.Scope;
273.93 +import org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch.VerifiedSpansCallBack;
273.94 +import org.netbeans.modules.java.hints.spiimpl.batch.ProgressHandleWrapper;
273.95 +import org.netbeans.modules.java.hints.spiimpl.batch.Scopes;
273.96 +import org.netbeans.modules.java.hints.spiimpl.pm.BulkSearch.BulkPattern;
273.97 +import org.netbeans.modules.java.preprocessorbridge.spi.JavaIndexerPlugin;
273.98 +import org.netbeans.modules.parsing.impl.indexing.FileObjectIndexable;
273.99 +import org.netbeans.modules.parsing.impl.indexing.IndexableImpl;
273.100 +import org.netbeans.modules.parsing.impl.indexing.SPIAccessor;
273.101 +import org.netbeans.spi.editor.hints.ErrorDescription;
273.102 +import org.netbeans.spi.editor.hints.ErrorDescriptionFactory;
273.103 +import org.netbeans.spi.editor.hints.Severity;
273.104 +import org.openide.filesystems.FileObject;
273.105 +import org.openide.filesystems.FileUtil;
273.106 +import org.openide.filesystems.URLMapper;
273.107 +import org.openide.util.Exceptions;
273.108 +
273.109 +/**
273.110 + *
273.111 + * @author lahvac
273.112 + */
273.113 +public class EnhancedScopes {
273.114 +
273.115 + private static final Logger LOG = Logger.getLogger(EnhancedScopes.class.getName());
273.116 +
273.117 + public static Scope allRemote() {
273.118 + return new RemoteIndexScope();
273.119 + }
273.120 +
273.121 + public static final class GivenFolderScope extends Scope {
273.122 +
273.123 + public final String folder;
273.124 + public final String indexURL;
273.125 + public final String subIndex;
273.126 + public final boolean update;
273.127 +
273.128 + public GivenFolderScope(String folder, String indexURL, String subIndex, boolean update) {
273.129 + this.folder = folder;
273.130 + this.indexURL = indexURL;
273.131 + this.subIndex = subIndex;
273.132 + this.update = update;
273.133 + }
273.134 +
273.135 + @Override
273.136 + public String getDisplayName() {
273.137 + return folder;
273.138 + }
273.139 +
273.140 + @Override
273.141 + public Collection<? extends Folder> getTodo() {
273.142 + return Collections.singletonList(new Folder(FileUtil.toFileObject(new File(folder))));
273.143 + }
273.144 +
273.145 + @Override
273.146 + public MapIndices getIndexMapper(Iterable<? extends HintDescription> patterns) {
273.147 + MapIndices mapper;
273.148 +
273.149 + if (indexURL != null) {
273.150 + if (subIndex == null) {
273.151 + mapper = new MapIndices() {
273.152 + public IndexEnquirer findIndex(FileObject root, ProgressHandleWrapper progress, boolean recursive) {
273.153 + try {
273.154 + return new SimpleIndexIndexEnquirer(root, createOrUpdateIndex(root, new File(indexURL), update, progress, recursive));
273.155 + } catch (IOException ex) {
273.156 + Exceptions.printStackTrace(ex);
273.157 + return null;
273.158 + }
273.159 + }
273.160 + };
273.161 + } else {
273.162 + mapper = new MapIndices() {
273.163 + public IndexEnquirer findIndex(FileObject root, ProgressHandleWrapper progress, boolean recursive) {
273.164 + progress.startNextPart(1);
273.165 + try {
273.166 + return new SimpleIndexIndexEnquirer(root, IndexQuery.remote(RemoteIndex.create(root.toURL(), new URL(indexURL), subIndex)));
273.167 + } catch (MalformedURLException ex) {
273.168 + Exceptions.printStackTrace(ex);
273.169 + return null;
273.170 + }
273.171 + }
273.172 + };
273.173 + }
273.174 + } else {
273.175 + mapper = Scopes.getDefaultIndicesMapper();
273.176 + }
273.177 +
273.178 + return mapper;
273.179 + }
273.180 +
273.181 + }
273.182 +
273.183 + private static final class RemoteIndexScope extends Scope {
273.184 + @Override
273.185 + public String getDisplayName() {
273.186 + return "All Remote Indices";
273.187 + }
273.188 +
273.189 + @Override
273.190 + public Collection<? extends Folder> getTodo() {
273.191 + Collection<Folder> todo = new HashSet<Folder>();
273.192 +
273.193 + for (RemoteIndex remoteIndex : RemoteIndex.loadIndices()) {
273.194 + FileObject localFolder = URLMapper.findFileObject(remoteIndex.getLocalFolder());
273.195 +
273.196 + if (localFolder == null) continue;
273.197 + todo.add(new Folder(localFolder));
273.198 + }
273.199 +
273.200 + return todo;
273.201 + }
273.202 +
273.203 + @Override
273.204 + public MapIndices getIndexMapper(final Iterable<? extends HintDescription> patterns) {
273.205 + return new MapIndices() {
273.206 + public IndexEnquirer findIndex(FileObject root, ProgressHandleWrapper progress, boolean recursive) {
273.207 + for (RemoteIndex remoteIndex : RemoteIndex.loadIndices()) {
273.208 + FileObject localFolder = URLMapper.findFileObject(remoteIndex.getLocalFolder());
273.209 +
273.210 + if (localFolder == null) continue;
273.211 + if (localFolder == root) {
273.212 + return enquirerForRemoteIndex(root, remoteIndex, patterns);
273.213 + }
273.214 + }
273.215 + throw new IllegalStateException();
273.216 + }
273.217 + };
273.218 + }
273.219 + }
273.220 +
273.221 + private static IndexQuery createOrUpdateIndex(final FileObject src, File indexRoot, boolean update, ProgressHandleWrapper progress, boolean recursive) throws IOException {
273.222 + final JavaIndexerPlugin index = new Indexer.FactoryImpl().create(src.toURL(), FileUtil.toFileObject(indexRoot));
273.223 +
273.224 + File timeStampsFile = new File(indexRoot, "timestamps.properties");
273.225 + Properties timeStamps = new Properties();
273.226 +
273.227 + if (timeStampsFile.exists()) {
273.228 + if (!update) {
273.229 + progress.startNextPart(1);
273.230 + return IndexQuery.open(src.toURL());
273.231 + }
273.232 +
273.233 + InputStream in = null;
273.234 +
273.235 + try {
273.236 + in = new BufferedInputStream(new FileInputStream(timeStampsFile));
273.237 + timeStamps.load(in);
273.238 + } catch (IOException ex) {
273.239 + Exceptions.printStackTrace(ex);
273.240 + } finally {
273.241 + try {
273.242 + if (in != null)
273.243 + in.close();
273.244 + } catch (IOException ex) {
273.245 + Exceptions.printStackTrace(ex);
273.246 + }
273.247 + }
273.248 + }
273.249 +
273.250 + Collection<FileObject> collected = new LinkedList<FileObject>();
273.251 + Set<String> removed = new HashSet<String>(timeStamps.stringPropertyNames());
273.252 +
273.253 + org.netbeans.modules.java.hints.spiimpl.batch.BatchUtilities.recursive(src, src, collected, progress, 0, timeStamps, removed, recursive);
273.254 +
273.255 + for (String r : removed) {
273.256 + index.delete(SPIAccessor.getInstance().create(new FakeIndexableImpl(r)));
273.257 + }
273.258 +
273.259 + JavaSource js = JavaSource.create(ClasspathInfo.create(ClassPath.EMPTY, ClassPath.EMPTY, ClassPath.EMPTY), collected);
273.260 +
273.261 + js.runUserActionTask(new Task<CompilationController>() {
273.262 + @Override public void run(CompilationController parameter) throws Exception {
273.263 + if (parameter.toPhase(JavaSource.Phase.PARSED).compareTo(JavaSource.Phase.PARSED) < 0) return;
273.264 +
273.265 + index.process(parameter.getCompilationUnit(), SPIAccessor.getInstance().create(new FileObjectIndexable(src, parameter.getFileObject())), null);
273.266 + }
273.267 + }, true);
273.268 +
273.269 + OutputStream out = null;
273.270 +
273.271 + try {
273.272 + out = new BufferedOutputStream(new FileOutputStream(timeStampsFile));
273.273 + timeStamps.store(out, null);
273.274 + } finally {
273.275 + try {
273.276 + if (out != null) {
273.277 + out.close();
273.278 + }
273.279 + } catch (IOException ex) {
273.280 + Exceptions.printStackTrace(ex);
273.281 + }
273.282 + }
273.283 +
273.284 + return IndexQuery.open(src.toURL());
273.285 + }
273.286 +
273.287 + private static final class FakeIndexableImpl implements IndexableImpl {
273.288 +
273.289 + private final String path;
273.290 +
273.291 + public FakeIndexableImpl(String path) {
273.292 + this.path = path;
273.293 + }
273.294 +
273.295 + @Override public String getRelativePath() {
273.296 + return path;
273.297 + }
273.298 +
273.299 + @Override public URL getURL() {
273.300 + throw new UnsupportedOperationException("Not supported yet.");
273.301 + }
273.302 +
273.303 + @Override public String getMimeType() {
273.304 + throw new UnsupportedOperationException("Not supported yet.");
273.305 + }
273.306 +
273.307 + @Override public boolean isTypeOf(String mimeType) {
273.308 + throw new UnsupportedOperationException("Not supported yet.");
273.309 + }
273.310 +
273.311 + }
273.312 +
273.313 + private static boolean isAttributedIndexWithSpans(RemoteIndex remoteIndex) {
273.314 + try {
273.315 + URI capabilitiesURI = new URI(remoteIndex.remote.toExternalForm() + "/capabilities");
273.316 + String capabilitiesString = WebUtilities.requestStringResponse(capabilitiesURI);
273.317 +
273.318 + if (capabilitiesURI == null) return false;
273.319 +
273.320 + @SuppressWarnings("unchecked")
273.321 + Map<String, Object> capabilities = Pojson.load(HashMap.class, capabilitiesString);
273.322 +
273.323 + return capabilities.get("attributed") == Boolean.TRUE; //TODO: should also check "methods contains findWithSpans"
273.324 + } catch (URISyntaxException ex) {
273.325 + LOG.log(Level.FINE, null, ex);
273.326 + return false;
273.327 + }
273.328 + }
273.329 +
273.330 + private static IndexEnquirer enquirerForRemoteIndex(FileObject src, RemoteIndex remoteIndex, Iterable<? extends HintDescription> hints) {
273.331 + boolean fullySupported = isAttributedIndexWithSpans(remoteIndex);
273.332 + StringBuilder textualRepresentation = new StringBuilder();
273.333 +
273.334 + for (HintDescription hd : hints) {
273.335 + if (!(hd.getTrigger() instanceof PatternDescription)) {
273.336 + fullySupported = false;
273.337 + break;
273.338 + }
273.339 +
273.340 + if (((PatternDescription) hd.getTrigger()).getImports().iterator().hasNext()) {
273.341 + fullySupported = false;
273.342 + }
273.343 +
273.344 + if (!fullySupported) break;
273.345 +
273.346 + String hintText = hd.getHintText();
273.347 +
273.348 + if (hintText != null) {
273.349 + textualRepresentation.append(hintText);
273.350 + } else {
273.351 + textualRepresentation.append(defaultHintText(hd));
273.352 + fullySupported = false;
273.353 + }
273.354 +
273.355 + textualRepresentation.append("\n");
273.356 + }
273.357 +
273.358 + if (fullySupported) {
273.359 + return new RemoteFullyAttributedIndexEnquirer(src, remoteIndex, textualRepresentation.toString());
273.360 + } else {
273.361 + return new SimpleIndexIndexEnquirer(src, IndexQuery.remote(remoteIndex));
273.362 + }
273.363 + }
273.364 +
273.365 + private static final class SimpleIndexIndexEnquirer extends LocalIndexEnquirer {
273.366 + private final IndexQuery idx;
273.367 + public SimpleIndexIndexEnquirer(FileObject src, IndexQuery idx) {
273.368 + super(src);
273.369 + this.idx = idx;
273.370 + }
273.371 + public Collection<? extends Resource> findResources(final Iterable<? extends HintDescription> hints, ProgressHandleWrapper progress, final Callable<BulkPattern> bulkPattern, final Collection<? super MessageImpl> problems) {
273.372 + final Collection<Resource> result = new ArrayList<Resource>();
273.373 +
273.374 + progress.startNextPart(1);
273.375 +
273.376 + try {
273.377 + BulkPattern bp = bulkPattern.call();
273.378 +
273.379 + for (String candidate : idx.findCandidates(bp)) {
273.380 + result.add(new Resource(this, candidate, hints, bp));
273.381 + }
273.382 + } catch (Exception ex) {
273.383 + Exceptions.printStackTrace(ex);
273.384 + }
273.385 +
273.386 + return result;
273.387 + }
273.388 +
273.389 + }
273.390 +
273.391 + private static final class RemoteFullyAttributedIndexEnquirer extends IndexEnquirer {
273.392 + private final RemoteIndex remoteIndex;
273.393 + private final String textualHintRepresentation;
273.394 + public RemoteFullyAttributedIndexEnquirer(FileObject src, RemoteIndex remoteIndex, String textualHintRepresentation) {
273.395 + super(src);
273.396 + assert isAttributedIndexWithSpans(remoteIndex);
273.397 + this.remoteIndex = remoteIndex;
273.398 + this.textualHintRepresentation = textualHintRepresentation;
273.399 + }
273.400 + public Collection<? extends Resource> findResources(final Iterable<? extends HintDescription> hints, ProgressHandleWrapper progress, final Callable<BulkPattern> bulkPattern, final Collection<? super MessageImpl> problems) {
273.401 + final Collection<Resource> result = new ArrayList<Resource>();
273.402 +
273.403 + progress.startNextPart(1);
273.404 +
273.405 + try {
273.406 + URI u = new URI(remoteIndex.remote.toExternalForm() + "/find?path=" + escapeForQuery(remoteIndex.remoteSegment) + "&pattern=" + escapeForQuery(textualHintRepresentation));
273.407 +
273.408 + for (String occurrence : new ArrayList<String>(WebUtilities.requestStringArrayResponse(u))) {
273.409 + try {
273.410 + BulkPattern bp = bulkPattern.call();
273.411 + result.add(new Resource(this, occurrence, hints, bp));
273.412 + } catch (Exception ex) {
273.413 + //from bulkPattern.call()? should not happen.
273.414 + Exceptions.printStackTrace(ex);
273.415 + }
273.416 + }
273.417 +
273.418 + } catch (URISyntaxException ex) {
273.419 + Exceptions.printStackTrace(ex);
273.420 + }
273.421 +
273.422 + return result;
273.423 + }
273.424 +
273.425 + @Override
273.426 + public void validateResource(Collection<? extends Resource> resources, ProgressHandleWrapper progress, VerifiedSpansCallBack callback, boolean doNotRegisterClassPath, Collection<? super MessageImpl> problems, AtomicBoolean cancel) {
273.427 + for (Resource r : resources) {
273.428 + try {
273.429 + URI spanURI = new URI(remoteIndex.remote.toExternalForm() + "/findSpans?path=" + escapeForQuery(remoteIndex.remoteSegment) + "&relativePath=" + escapeForQuery(r.getRelativePath()) + "&pattern=" + escapeForQuery(textualHintRepresentation));
273.430 + FileObject fo = r.getResolvedFile();
273.431 +
273.432 + if (fo == null) {
273.433 + callback.cannotVerifySpan(r);
273.434 + } else {
273.435 + List<ErrorDescription> result = new ArrayList<ErrorDescription>();
273.436 +
273.437 + for (int[] span : parseSpans(WebUtilities.requestStringResponse(spanURI))) {
273.438 + result.add(ErrorDescriptionFactory.createErrorDescription(Severity.WARNING, "Occurrence", fo, span[0], span[1]));
273.439 + }
273.440 +
273.441 + callback.spansVerified(null, r, result);
273.442 + }
273.443 + } catch (Exception ex) {
273.444 + Exceptions.printStackTrace(ex);
273.445 + }
273.446 + }
273.447 + }
273.448 +
273.449 + }
273.450 +
273.451 + private static Iterable<int[]> parseSpans(String from) {
273.452 + if (from.isEmpty()) {
273.453 + return Collections.emptyList();
273.454 + }
273.455 + String[] split = from.split(":");
273.456 + List<int[]> result = new LinkedList<int[]>();
273.457 +
273.458 + for (int i = 0; i < split.length; i += 2) {
273.459 + result.add(new int[] {
273.460 + Integer.parseInt(split[i + 0].trim()),
273.461 + Integer.parseInt(split[i + 1].trim())
273.462 + });
273.463 + }
273.464 +
273.465 + return result;
273.466 + }
273.467 +
273.468 + private static String defaultHintText(HintDescription hd) {
273.469 + StringBuilder result = new StringBuilder();
273.470 +
273.471 + PatternDescription pd = (PatternDescription) hd.getTrigger();
273.472 +
273.473 + if (pd == null) return null;
273.474 +
273.475 + if (pd.getImports().iterator().hasNext()) {
273.476 + //cannot currently handle patterns with imports:
273.477 + return null;
273.478 + }
273.479 +
273.480 + result.append(pd.getPattern());
273.481 +
273.482 + if (!pd.getConstraints().isEmpty()) {
273.483 + result.append(" :: ");
273.484 +
273.485 + for (Iterator<Entry<String, String>> it = pd.getConstraints().entrySet().iterator(); it.hasNext(); ) {
273.486 + Entry<String, String> e = it.next();
273.487 +
273.488 + result.append(e.getKey()).append(" instanceof ").append(e.getValue());
273.489 +
273.490 + if (it.hasNext()) {
273.491 + result.append(" && ");
273.492 + }
273.493 + }
273.494 + }
273.495 +
273.496 + result.append(";;\n");
273.497 +
273.498 + return result.toString();
273.499 + }
273.500 +}
274.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
274.2 +++ b/language/ide/indexing/src/org/netbeans/modules/jackpot30/indexing/batch/OptionProcessorImpl.java Mon Mar 12 21:10:10 2012 +0100
274.3 @@ -0,0 +1,276 @@
274.4 +/*
274.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
274.6 + *
274.7 + * Copyright 2008-2010 Sun Microsystems, Inc. All rights reserved.
274.8 + *
274.9 + * The contents of this file are subject to the terms of either the GNU
274.10 + * General Public License Version 2 only ("GPL") or the Common
274.11 + * Development and Distribution License("CDDL") (collectively, the
274.12 + * "License"). You may not use this file except in compliance with the
274.13 + * License. You can obtain a copy of the License at
274.14 + * http://www.netbeans.org/cddl-gplv2.html
274.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
274.16 + * specific language governing permissions and limitations under the
274.17 + * License. When distributing the software, include this License Header
274.18 + * Notice in each file and include the License file at
274.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
274.20 + * particular file as subject to the "Classpath" exception as provided
274.21 + * by Sun in the GPL Version 2 section of the License file that
274.22 + * accompanied this code. If applicable, add the following below the
274.23 + * License Header, with the fields enclosed by brackets [] replaced by
274.24 + * your own identifying information:
274.25 + * "Portions Copyrighted [year] [name of copyright owner]"
274.26 + *
274.27 + * If you wish your version of this file to be governed by only the CDDL
274.28 + * or only the GPL Version 2, indicate your decision by adding
274.29 + * "[Contributor] elects to include this software in this distribution
274.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
274.31 + * single choice of license, a recipient has the option to distribute
274.32 + * your version of this file under either the CDDL, the GPL Version 2 or
274.33 + * to extend the choice of license to its licensees as provided above.
274.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
274.35 + * Version 2 license, then the option applies only if the new code is
274.36 + * made subject to such option by the copyright holder.
274.37 + *
274.38 + * Contributor(s):
274.39 + *
274.40 + * Portions Copyrighted 2008-2010 Sun Microsystems, Inc.
274.41 + */
274.42 +
274.43 +package org.netbeans.modules.jackpot30.indexing.batch;
274.44 +
274.45 +import java.io.File;
274.46 +import java.io.IOException;
274.47 +import java.util.ArrayList;
274.48 +import java.util.Arrays;
274.49 +import java.util.Collection;
274.50 +import java.util.HashMap;
274.51 +import java.util.HashSet;
274.52 +import java.util.LinkedList;
274.53 +import java.util.List;
274.54 +import java.util.Map;
274.55 +import java.util.Set;
274.56 +import java.util.TreeMap;
274.57 +import java.util.logging.Logger;
274.58 +import org.netbeans.api.java.classpath.ClassPath;
274.59 +import org.netbeans.api.java.source.ModificationResult;
274.60 +import org.netbeans.api.project.Project;
274.61 +import org.netbeans.api.project.ProjectManager;
274.62 +import org.netbeans.api.project.ProjectUtils;
274.63 +import org.netbeans.api.project.SourceGroup;
274.64 +import org.netbeans.api.project.ui.OpenProjects;
274.65 +import org.netbeans.api.sendopts.CommandException;
274.66 +import org.netbeans.modules.java.hints.providers.spi.HintDescription;
274.67 +import org.netbeans.modules.java.hints.spiimpl.MessageImpl;
274.68 +import org.netbeans.modules.java.hints.spiimpl.Utilities;
274.69 +import org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch;
274.70 +import org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch.BatchResult;
274.71 +import org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch.Folder;
274.72 +import org.netbeans.modules.java.hints.spiimpl.batch.BatchUtilities;
274.73 +import org.netbeans.modules.java.hints.spiimpl.batch.ProgressHandleWrapper;
274.74 +import org.netbeans.modules.java.hints.spiimpl.batch.Scopes;
274.75 +import org.netbeans.spi.java.classpath.support.ClassPathSupport;
274.76 +import org.netbeans.spi.java.hints.HintContext.MessageKind;
274.77 +import org.netbeans.spi.sendopts.Env;
274.78 +import org.netbeans.spi.sendopts.Option;
274.79 +import org.netbeans.spi.sendopts.OptionProcessor;
274.80 +import org.openide.filesystems.FileObject;
274.81 +import org.openide.filesystems.FileUtil;
274.82 +import org.openide.util.lookup.ServiceProvider;
274.83 +
274.84 +/**
274.85 + *
274.86 + * @author Jan Lahoda
274.87 + */
274.88 +@ServiceProvider(service=OptionProcessor.class)
274.89 +public class OptionProcessorImpl extends OptionProcessor {
274.90 +
274.91 + private static final Logger LOG = Logger.getLogger(OptionProcessorImpl.class.getName());
274.92 +
274.93 + private static final String APPLY_TRANSFORMATIONS_PROJECT_OPTION = "apply-transformations-project";
274.94 +
274.95 + private static final Option LIST = Option.withoutArgument(Option.NO_SHORT_NAME, "list-hints-transformation");
274.96 + private static final Option APPLY_TRANSFORMATIONS = Option.shortDescription(
274.97 + Option.requiredArgument(Option.NO_SHORT_NAME, "apply-transformations"),
274.98 + "org.netbeans.modules.jackpot30.impl.batch.Bundle",
274.99 + "SD_ApplyTransformations");
274.100 + private static final Option APPLY_TRANSFORMATIONS_PROJECT = Option.shortDescription(
274.101 + Option.additionalArguments(Option.NO_SHORT_NAME, APPLY_TRANSFORMATIONS_PROJECT_OPTION),
274.102 + "org.netbeans.modules.jackpot30.impl.batch.Bundle",
274.103 + "SD_ApplyTransformationsProject");
274.104 +
274.105 + private static final Set<Option> OPTIONS = new HashSet<Option>(Arrays.asList(LIST, APPLY_TRANSFORMATIONS, APPLY_TRANSFORMATIONS_PROJECT));
274.106 +
274.107 + @Override
274.108 + protected Set<Option> getOptions() {
274.109 + return OPTIONS;
274.110 + }
274.111 +
274.112 + @Override
274.113 + protected void process(Env env, Map<Option, String[]> optionValues) throws CommandException {
274.114 + List<Project> projects = new LinkedList<Project>();
274.115 + Map<String, List<ClassPath>> classPaths = new HashMap<String, List<ClassPath>>();
274.116 +
274.117 + if (optionValues.containsKey(APPLY_TRANSFORMATIONS_PROJECT)) {
274.118 + String[] projectNames = optionValues.get(APPLY_TRANSFORMATIONS_PROJECT);
274.119 +
274.120 + if (projectNames.length == 0) {
274.121 + env.getErrorStream().println("At least one parameter needed for " + APPLY_TRANSFORMATIONS_PROJECT_OPTION);
274.122 + throw new CommandException(1);
274.123 + }
274.124 +
274.125 + FileObject currentDirectory = FileUtil.toFileObject(env.getCurrentDirectory());
274.126 +
274.127 + OUTER: for (String p : projectNames) {
274.128 + FileObject projectFile = currentDirectory.getFileObject(p);
274.129 +
274.130 + if (projectFile == null) {
274.131 + projectFile = FileUtil.toFileObject(new File(p));
274.132 + }
274.133 +
274.134 + if (projectFile == null) {
274.135 + env.getErrorStream().println("Ignoring file " + p + " - cannot be found.");
274.136 + continue;
274.137 + }
274.138 +
274.139 + if (!projectFile.isFolder()) {
274.140 + env.getErrorStream().println("Ignoring file " + p + " - not a folder.");
274.141 + continue;
274.142 + }
274.143 +
274.144 + Project project = null;
274.145 + String error = null;
274.146 +
274.147 + try {
274.148 + project = ProjectManager.getDefault().findProject(projectFile);
274.149 + } catch (IOException ex) {
274.150 + error = ex.getLocalizedMessage();
274.151 + } catch (IllegalArgumentException ex) {
274.152 + error = ex.getLocalizedMessage();
274.153 + }
274.154 +
274.155 + if (project == null) {
274.156 + if (error == null) {
274.157 + env.getErrorStream().println("Ignoring file " + p + " - not a project.");
274.158 + } else {
274.159 + env.getErrorStream().println("Ignoring file " + p + " - not a project (" + error + ").");
274.160 + }
274.161 +
274.162 + continue;
274.163 + }
274.164 +
274.165 + for (SourceGroup sg : ProjectUtils.getSources(project).getSourceGroups("java")) {
274.166 + FileObject root = sg.getRootFolder();
274.167 +
274.168 + for (String type : Arrays.asList(ClassPath.BOOT, ClassPath.COMPILE, ClassPath.SOURCE)) {
274.169 + if (!handleClassPath(root, type, env, p, classPaths)) {
274.170 + continue OUTER;
274.171 + }
274.172 + }
274.173 + }
274.174 +
274.175 + projects.add(project);
274.176 + }
274.177 + } else {
274.178 + projects.addAll(Arrays.asList(OpenProjects.getDefault().getOpenProjects()));
274.179 + }
274.180 +
274.181 + if (optionValues.containsKey(LIST)) {
274.182 + env.getOutputStream().println("Supported Hints:");
274.183 +
274.184 + Set<ClassPath> cps = new HashSet<ClassPath>();
274.185 +
274.186 + for (List<ClassPath> c : classPaths.values()) {
274.187 + cps.addAll(c);
274.188 + }
274.189 +
274.190 + Set<String> displayNames = Utilities.sortOutHints(Utilities.listAllHints(cps), new TreeMap<String, Collection<HintDescription>>()).keySet();
274.191 +
274.192 + for (String displayName : displayNames) {
274.193 + env.getOutputStream().println(displayName);
274.194 + }
274.195 + }
274.196 +
274.197 + if (optionValues.containsKey(APPLY_TRANSFORMATIONS)) {
274.198 + String hintsArg = optionValues.get(APPLY_TRANSFORMATIONS)[0];
274.199 + List<HintDescription> hintDescriptions = new LinkedList<HintDescription>();
274.200 + Set<ClassPath> cps = new HashSet<ClassPath>();
274.201 +
274.202 + for (List<ClassPath> c : classPaths.values()) {
274.203 + cps.addAll(c);
274.204 + }
274.205 +
274.206 + Map<String, Collection<HintDescription>> sorted = Utilities.sortOutHints(Utilities.listAllHints(cps), new TreeMap<String, Collection<HintDescription>>());
274.207 +
274.208 + for (String hint : hintsArg.split(":")) {
274.209 + Collection<HintDescription> descs = sorted.get(hint);
274.210 +
274.211 + if (descs == null) {
274.212 + env.getErrorStream().println("Unknown hint: " + hint);
274.213 + continue;
274.214 + }
274.215 +
274.216 + hintDescriptions.addAll(descs);
274.217 + }
274.218 +
274.219 + Collection<Folder> roots = new ArrayList<Folder>();
274.220 +
274.221 + for (FileObject f : BatchUtilities.getSourceGroups(projects)) {
274.222 + roots.add(new Folder(f));
274.223 + }
274.224 +
274.225 + BatchResult candidates = BatchSearch.findOccurrences(hintDescriptions, Scopes.specifiedFoldersScope(roots.toArray(new Folder[0])));
274.226 + List<MessageImpl> problems = new LinkedList<MessageImpl>(candidates.problems);
274.227 + Collection<? extends ModificationResult> res = BatchUtilities.applyFixes(candidates, new ProgressHandleWrapper(100), null, problems);
274.228 + Set<FileObject> modified = new HashSet<FileObject>();
274.229 +
274.230 + for (ModificationResult mr : res) {
274.231 + try {
274.232 + mr.commit();
274.233 + } catch (IOException ex) {
274.234 + ex.printStackTrace(env.getErrorStream());
274.235 + problems.add(new MessageImpl(MessageKind.ERROR, "Cannot apply changes: " + ex.getLocalizedMessage()));
274.236 + }
274.237 + modified.addAll(mr.getModifiedFileObjects());
274.238 + }
274.239 +
274.240 + try {
274.241 + BatchUtilities.removeUnusedImports(modified);
274.242 + } catch (IOException ex) {
274.243 + ex.printStackTrace(env.getErrorStream());
274.244 + problems.add(new MessageImpl(MessageKind.ERROR, "Cannot remove unused imports: " + ex.getLocalizedMessage()));
274.245 + }
274.246 +
274.247 + if (!problems.isEmpty()) {
274.248 + env.getErrorStream().println("Problem encountered while applying the transformations:");
274.249 +
274.250 + for (MessageImpl problem : problems) {
274.251 + env.getErrorStream().println(problem.text);
274.252 + }
274.253 + }
274.254 + }
274.255 +
274.256 + }
274.257 +
274.258 + private boolean handleClassPath(FileObject root, String type, Env env, String p, Map<String, List<ClassPath>> classPaths) {
274.259 + ClassPath cp = ClassPath.getClassPath(root, type);
274.260 +
274.261 + if (cp == null) {
274.262 + env.getErrorStream().println("Ignoring file " + p + " - no " + type + " classpath for source group: " + FileUtil.getFileDisplayName(root));
274.263 + return false;
274.264 + }
274.265 +
274.266 + List<ClassPath> cps = classPaths.get(type);
274.267 +
274.268 + if (cps == null) {
274.269 + classPaths.put(type, cps = new LinkedList<ClassPath>());
274.270 + }
274.271 +
274.272 + cp = ClassPathSupport.createProxyClassPath(cp);
274.273 +
274.274 + cps.add(cp);
274.275 +
274.276 + return true;
274.277 + }
274.278 +
274.279 +}
275.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
275.2 +++ b/language/ide/indexing/src/org/netbeans/modules/jackpot30/indexing/index/IndexQuery.java Mon Mar 12 21:10:10 2012 +0100
275.3 @@ -0,0 +1,254 @@
275.4 +/*
275.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
275.6 + *
275.7 + * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
275.8 + *
275.9 + * The contents of this file are subject to the terms of either the GNU
275.10 + * General Public License Version 2 only ("GPL") or the Common
275.11 + * Development and Distribution License("CDDL") (collectively, the
275.12 + * "License"). You may not use this file except in compliance with the
275.13 + * License. You can obtain a copy of the License at
275.14 + * http://www.netbeans.org/cddl-gplv2.html
275.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
275.16 + * specific language governing permissions and limitations under the
275.17 + * License. When distributing the software, include this License Header
275.18 + * Notice in each file and include the License file at
275.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
275.20 + * particular file as subject to the "Classpath" exception as provided
275.21 + * by Sun in the GPL Version 2 section of the License file that
275.22 + * accompanied this code. If applicable, add the following below the
275.23 + * License Header, with the fields enclosed by brackets [] replaced by
275.24 + * your own identifying information:
275.25 + * "Portions Copyrighted [year] [name of copyright owner]"
275.26 + *
275.27 + * If you wish your version of this file to be governed by only the CDDL
275.28 + * or only the GPL Version 2, indicate your decision by adding
275.29 + * "[Contributor] elects to include this software in this distribution
275.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
275.31 + * single choice of license, a recipient has the option to distribute
275.32 + * your version of this file under either the CDDL, the GPL Version 2 or
275.33 + * to extend the choice of license to its licensees as provided above.
275.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
275.35 + * Version 2 license, then the option applies only if the new code is
275.36 + * made subject to such option by the copyright holder.
275.37 + *
275.38 + * Contributor(s):
275.39 + *
275.40 + * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
275.41 + */
275.42 +
275.43 +package org.netbeans.modules.jackpot30.indexing.index;
275.44 +
275.45 +import java.io.ByteArrayInputStream;
275.46 +import java.io.File;
275.47 +import java.io.IOException;
275.48 +import java.net.URI;
275.49 +import java.net.URISyntaxException;
275.50 +import java.net.URL;
275.51 +import java.util.ArrayList;
275.52 +import java.util.BitSet;
275.53 +import java.util.Collection;
275.54 +import java.util.Collections;
275.55 +import java.util.HashMap;
275.56 +import java.util.List;
275.57 +import java.util.Map;
275.58 +import java.util.zip.DataFormatException;
275.59 +import org.apache.lucene.document.CompressionTools;
275.60 +import org.apache.lucene.document.Document;
275.61 +import org.apache.lucene.document.FieldSelector;
275.62 +import org.apache.lucene.document.FieldSelectorResult;
275.63 +import org.apache.lucene.index.IndexReader;
275.64 +import org.apache.lucene.index.Term;
275.65 +import org.apache.lucene.queryParser.ParseException;
275.66 +import org.apache.lucene.search.BooleanClause;
275.67 +import org.apache.lucene.search.BooleanQuery;
275.68 +import org.apache.lucene.search.Collector;
275.69 +import org.apache.lucene.search.IndexSearcher;
275.70 +import org.apache.lucene.search.PhraseQuery;
275.71 +import org.apache.lucene.search.Query;
275.72 +import org.apache.lucene.search.Searcher;
275.73 +import org.apache.lucene.search.TermQuery;
275.74 +import org.apache.lucene.store.FSDirectory;
275.75 +import org.netbeans.api.annotations.common.NullAllowed;
275.76 +import org.netbeans.modules.jackpot30.common.api.LuceneHelpers.BitSetCollector;
275.77 +import org.netbeans.modules.jackpot30.remoting.api.RemoteIndex;
275.78 +import org.netbeans.modules.jackpot30.remoting.api.WebUtilities;
275.79 +import org.netbeans.modules.java.hints.providers.spi.HintDescription.AdditionalQueryConstraints;
275.80 +import org.netbeans.modules.java.hints.spiimpl.pm.BulkSearch;
275.81 +import org.netbeans.modules.java.hints.spiimpl.pm.BulkSearch.BulkPattern;
275.82 +import org.openide.filesystems.FileObject;
275.83 +import org.openide.filesystems.FileUtil;
275.84 +import org.openide.util.Exceptions;
275.85 +
275.86 +/**
275.87 + *
275.88 + * @author lahvac
275.89 + */
275.90 +public abstract class IndexQuery {
275.91 +
275.92 + public abstract Collection<? extends String> findCandidates(BulkPattern pattern) throws IOException;
275.93 +
275.94 + public abstract Map<String, Map<String, Integer>> findCandidatesWithFrequencies(BulkPattern pattern) throws IOException;
275.95 +
275.96 + private static final class LocalIndexQuery extends IndexQuery {
275.97 + private final @NullAllowed File cacheDir;
275.98 +
275.99 + public LocalIndexQuery(@NullAllowed File cacheDir) {
275.100 + this.cacheDir = cacheDir;
275.101 + }
275.102 +
275.103 + public Collection<? extends String> findCandidates(BulkPattern pattern) throws IOException {
275.104 + return findCandidates(pattern, false).keySet();
275.105 + }
275.106 +
275.107 + public Map<String, Map<String, Integer>> findCandidatesWithFrequencies(BulkPattern pattern) throws IOException {
275.108 + return findCandidates(pattern, true);
275.109 + }
275.110 +
275.111 + private Map<String, Map<String, Integer>> findCandidates(BulkPattern pattern, boolean withFrequencies) throws IOException {
275.112 + IndexReader reader = cacheDir != null ? IndexReader.open(FSDirectory.open(cacheDir)) : null;
275.113 +
275.114 + if (reader == null) {
275.115 + return Collections.emptyMap();
275.116 + }
275.117 +
275.118 + try {
275.119 + Searcher s = new IndexSearcher(reader);
275.120 + BitSet matchingDocuments = new BitSet(reader.maxDoc());
275.121 + Collector c = new BitSetCollector(matchingDocuments);
275.122 +
275.123 + try {
275.124 + s.search(query(pattern), c);
275.125 + } catch (ParseException ex) {
275.126 + throw new IOException(ex);
275.127 + }
275.128 +
275.129 + Map<String, Map<String, Integer>> result = new HashMap<String, Map<String, Integer>>();
275.130 +
275.131 + for (int docNum = matchingDocuments.nextSetBit(0); docNum >= 0; docNum = matchingDocuments.nextSetBit(docNum+1)) {
275.132 + try {
275.133 + final Document doc = reader.document(docNum, new FieldSelector() {
275.134 + public FieldSelectorResult accept(String string) {
275.135 + return "encoded".equals(string) || "path".equals(string) ? FieldSelectorResult.LOAD : FieldSelectorResult.NO_LOAD;
275.136 + }
275.137 + });
275.138 +
275.139 + ByteArrayInputStream in = new ByteArrayInputStream(CompressionTools.decompress(doc.getField("encoded").getBinaryValue()));
275.140 +
275.141 + try {
275.142 + Map<String, Integer> freqs;
275.143 + boolean matches;
275.144 +
275.145 + if (withFrequencies) {
275.146 + freqs = BulkSearch.getDefault().matchesWithFrequencies(in, pattern);
275.147 + matches = !freqs.isEmpty();
275.148 + } else {
275.149 + freqs = null;
275.150 + matches = BulkSearch.getDefault().matches(in, pattern);
275.151 + }
275.152 +
275.153 + if (matches) {
275.154 + result.put(doc.getField("path").stringValue(), freqs);
275.155 + continue;
275.156 + }
275.157 + } finally {
275.158 + in.close();
275.159 + }
275.160 + } catch (DataFormatException ex) {
275.161 + throw new IOException(ex);
275.162 + }
275.163 + }
275.164 +
275.165 + return result;
275.166 + } finally {
275.167 + reader.close();
275.168 + }
275.169 + }
275.170 +
275.171 + private Query query(BulkPattern pattern) throws ParseException {
275.172 + BooleanQuery result = new BooleanQuery();
275.173 +
275.174 + for (int cntr = 0; cntr < pattern.getIdentifiers().size(); cntr++) {
275.175 + assert !pattern.getRequiredContent().get(cntr).isEmpty();
275.176 +
275.177 + BooleanQuery emb = new BooleanQuery();
275.178 +
275.179 + for (List<String> c : pattern.getRequiredContent().get(cntr)) {
275.180 + if (c.isEmpty()) continue;
275.181 +
275.182 + PhraseQuery pq = new PhraseQuery();
275.183 +
275.184 + for (String s : c) {
275.185 + pq.add(new Term("content", s));
275.186 + }
275.187 +
275.188 + emb.add(pq, BooleanClause.Occur.MUST);
275.189 + }
275.190 +
275.191 + AdditionalQueryConstraints additionalConstraints = pattern.getAdditionalConstraints().get(cntr);
275.192 +
275.193 + if (additionalConstraints != null && !additionalConstraints.requiredErasedTypes.isEmpty()) {
275.194 + BooleanQuery constraintsQuery = new BooleanQuery();
275.195 +
275.196 + constraintsQuery.add(new TermQuery(new Term("attributed", "false")), BooleanClause.Occur.SHOULD);
275.197 +
275.198 + BooleanQuery constr = new BooleanQuery();
275.199 +
275.200 + for (String tc : additionalConstraints.requiredErasedTypes) {
275.201 + constr.add(new TermQuery(new Term("erasedTypes", tc)), BooleanClause.Occur.MUST);
275.202 + }
275.203 +
275.204 + constraintsQuery.add(constr, BooleanClause.Occur.SHOULD);
275.205 + emb.add(constraintsQuery, BooleanClause.Occur.MUST);
275.206 + }
275.207 +
275.208 + result.add(emb, BooleanClause.Occur.SHOULD);
275.209 + }
275.210 +
275.211 + return result;
275.212 + }
275.213 + }
275.214 +
275.215 + private static final class RemoteIndexQuery extends IndexQuery {
275.216 + private final RemoteIndex idx;
275.217 +
275.218 + public RemoteIndexQuery(RemoteIndex idx) {
275.219 + this.idx = idx;
275.220 + }
275.221 +
275.222 + @Override
275.223 + public Collection<? extends String> findCandidates(BulkPattern pattern) throws IOException {
275.224 + try {
275.225 + StringBuilder patterns = new StringBuilder();
275.226 +
275.227 + for (String p : pattern.getPatterns()) {
275.228 + patterns.append(p);
275.229 + patterns.append(";;");
275.230 + }
275.231 +
275.232 + URI u = new URI(idx.remote.toExternalForm() + "?path=" + WebUtilities.escapeForQuery(idx.remoteSegment) + "&pattern=" + WebUtilities.escapeForQuery(patterns.toString()));
275.233 +
275.234 + return new ArrayList<String>(WebUtilities.requestStringArrayResponse(u));
275.235 + } catch (URISyntaxException ex) {
275.236 + //XXX: better handling?
275.237 + Exceptions.printStackTrace(ex);
275.238 + return Collections.emptyList();
275.239 + }
275.240 + }
275.241 + @Override
275.242 + public Map<String, Map<String, Integer>> findCandidatesWithFrequencies(BulkPattern pattern) throws IOException {
275.243 + throw new UnsupportedOperationException("Not supported yet.");
275.244 + }
275.245 + }
275.246 +
275.247 + public static IndexQuery open(URL sourceRoot) throws IOException {
275.248 + FileObject cacheFO = Indexer.resolveCacheFolder(sourceRoot).getFileObject(Indexer.INDEX_NAME);
275.249 + File cache = cacheFO != null ? FileUtil.toFile(cacheFO) : null;
275.250 +
275.251 + return new LocalIndexQuery(cache);
275.252 + }
275.253 +
275.254 + public static IndexQuery remote(RemoteIndex idx) {
275.255 + return new RemoteIndexQuery(idx);
275.256 + }
275.257 +}
276.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
276.2 +++ b/language/ide/indexing/src/org/netbeans/modules/jackpot30/indexing/index/Indexer.java Mon Mar 12 21:10:10 2012 +0100
276.3 @@ -0,0 +1,240 @@
276.4 +/*
276.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
276.6 + *
276.7 + * Copyright 2009-2012 Sun Microsystems, Inc. All rights reserved.
276.8 + *
276.9 + * The contents of this file are subject to the terms of either the GNU
276.10 + * General Public License Version 2 only ("GPL") or the Common
276.11 + * Development and Distribution License("CDDL") (collectively, the
276.12 + * "License"). You may not use this file except in compliance with the
276.13 + * License. You can obtain a copy of the License at
276.14 + * http://www.netbeans.org/cddl-gplv2.html
276.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
276.16 + * specific language governing permissions and limitations under the
276.17 + * License. When distributing the software, include this License Header
276.18 + * Notice in each file and include the License file at
276.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
276.20 + * particular file as subject to the "Classpath" exception as provided
276.21 + * by Sun in the GPL Version 2 section of the License file that
276.22 + * accompanied this code. If applicable, add the following below the
276.23 + * License Header, with the fields enclosed by brackets [] replaced by
276.24 + * your own identifying information:
276.25 + * "Portions Copyrighted [year] [name of copyright owner]"
276.26 + *
276.27 + * If you wish your version of this file to be governed by only the CDDL
276.28 + * or only the GPL Version 2, indicate your decision by adding
276.29 + * "[Contributor] elects to include this software in this distribution
276.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
276.31 + * single choice of license, a recipient has the option to distribute
276.32 + * your version of this file under either the CDDL, the GPL Version 2 or
276.33 + * to extend the choice of license to its licensees as provided above.
276.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
276.35 + * Version 2 license, then the option applies only if the new code is
276.36 + * made subject to such option by the copyright holder.
276.37 + *
276.38 + * Contributor(s):
276.39 + *
276.40 + * Portions Copyrighted 2009-2012 Sun Microsystems, Inc.
276.41 + */
276.42 +
276.43 +package org.netbeans.modules.jackpot30.indexing.index;
276.44 +
276.45 +import org.netbeans.modules.jackpot30.common.api.IndexAccess;
276.46 +import com.sun.source.tree.CompilationUnitTree;
276.47 +import com.sun.source.tree.Tree;
276.48 +import com.sun.source.util.TreePath;
276.49 +import com.sun.source.util.TreePathScanner;
276.50 +import com.sun.source.util.Trees;
276.51 +import java.io.ByteArrayOutputStream;
276.52 +import java.io.IOException;
276.53 +import java.net.URL;
276.54 +import java.util.Collections;
276.55 +import java.util.HashSet;
276.56 +import java.util.Iterator;
276.57 +import java.util.Set;
276.58 +import java.util.logging.Level;
276.59 +import java.util.logging.Logger;
276.60 +import javax.lang.model.type.ArrayType;
276.61 +import javax.lang.model.type.TypeKind;
276.62 +import javax.lang.model.type.TypeMirror;
276.63 +import javax.lang.model.util.Types;
276.64 +import org.apache.lucene.analysis.TokenStream;
276.65 +import org.apache.lucene.analysis.tokenattributes.TermAttribute;
276.66 +import org.apache.lucene.document.CompressionTools;
276.67 +import org.apache.lucene.document.Document;
276.68 +import org.apache.lucene.document.Field;
276.69 +import org.apache.lucene.index.CorruptIndexException;
276.70 +import org.apache.lucene.index.IndexWriter;
276.71 +import org.apache.lucene.index.Term;
276.72 +import org.netbeans.api.annotations.common.NonNull;
276.73 +import org.netbeans.api.editor.mimelookup.MimeRegistration;
276.74 +import org.netbeans.modules.java.hints.spiimpl.pm.BulkSearch;
276.75 +import org.netbeans.modules.java.hints.spiimpl.pm.BulkSearch.EncodingContext;
276.76 +import org.netbeans.modules.java.preprocessorbridge.spi.JavaIndexerPlugin;
276.77 +import org.netbeans.modules.java.source.indexing.JavaIndex;
276.78 +import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
276.79 +import org.netbeans.modules.parsing.spi.indexing.Indexable;
276.80 +import org.openide.filesystems.FileObject;
276.81 +import org.openide.filesystems.FileUtil;
276.82 +import org.openide.util.Exceptions;
276.83 +import org.openide.util.Lookup;
276.84 +
276.85 +/**
276.86 + *
276.87 + * @author lahvac
276.88 + */
276.89 +public final class Indexer implements JavaIndexerPlugin {
276.90 +
276.91 + public static final String INDEX_NAME = "jackpot30";
276.92 + private final @NonNull URL root;
276.93 + private final @NonNull FileObject cacheRoot;
276.94 + private final @NonNull IndexAccess access;
276.95 +
276.96 + private Indexer(URL root, FileObject cacheRoot) {
276.97 + this.root = root;
276.98 + this.cacheRoot = cacheRoot;
276.99 + this.access = Lookup.getDefault().lookup(IndexAccess.class);
276.100 + }
276.101 +
276.102 + @Override
276.103 + public void process (@NonNull CompilationUnitTree toProcess, @NonNull Indexable indexable, @NonNull Lookup services) {
276.104 + IndexWriter luceneWriter = access.getIndexWriter(root, cacheRoot, INDEX_NAME);
276.105 + String relative = access.getRelativePath(indexable);
276.106 + ByteArrayOutputStream out = null;
276.107 + EncodingContext ec;
276.108 +
276.109 + try {
276.110 + out = new ByteArrayOutputStream();
276.111 +
276.112 + ec = new EncodingContext(out, false);
276.113 +
276.114 + BulkSearch.getDefault().encode(toProcess, ec);
276.115 +
276.116 + luceneWriter.deleteDocuments(new Term("path", relative));
276.117 +
276.118 + Document doc = new Document();
276.119 +
276.120 + doc.add(new Field("content", new TokenStreamImpl(ec.getContent())));
276.121 + out.close();
276.122 + doc.add(new Field("encoded", CompressionTools.compress(out.toByteArray()), Field.Store.YES));
276.123 + doc.add(new Field("path", relative, Field.Store.YES, Field.Index.NOT_ANALYZED));
276.124 +
276.125 + if (services != null) {
276.126 + final Set<String> erased = new HashSet<String>();
276.127 + final Trees trees = services.lookup(Trees.class);
276.128 + final Types types = services.lookup(Types.class);
276.129 +
276.130 + new TreePathScanner<Void, Void>() {
276.131 + @Override
276.132 + public Void scan(Tree tree, Void p) {
276.133 + if (tree != null) {
276.134 + TreePath tp = new TreePath(getCurrentPath(), tree);
276.135 + TypeMirror type = trees.getTypeMirror(tp);
276.136 +
276.137 + if (type != null) {
276.138 + if (type.getKind() == TypeKind.ARRAY) {
276.139 + erased.add(types.erasure(type).toString());
276.140 + type = ((ArrayType) type).getComponentType();
276.141 + }
276.142 +
276.143 + if (type.getKind().isPrimitive() || type.getKind() == TypeKind.DECLARED) {
276.144 + addErasedTypeAndSuperTypes(types, erased, type);
276.145 + }
276.146 + }
276.147 +
276.148 + //bounds for type variables!!!
276.149 + }
276.150 + return super.scan(tree, p);
276.151 + }
276.152 + }.scan(toProcess, null);
276.153 +
276.154 + doc.add(new Field("erasedTypes", new TokenStreamImpl(erased)));
276.155 + }
276.156 +
276.157 + luceneWriter.addDocument(doc);
276.158 + } catch (ThreadDeath td) {
276.159 + throw td;
276.160 + } catch (Throwable t) {
276.161 + Logger.getLogger(Indexer.class.getName()).log(Level.WARNING, null, t);
276.162 + } finally {
276.163 + if (out != null) {
276.164 + try {
276.165 + out.close();
276.166 + } catch (IOException ex) {
276.167 + Exceptions.printStackTrace(ex);
276.168 + }
276.169 + }
276.170 + }
276.171 + }
276.172 +
276.173 +
276.174 + @Override
276.175 + public void delete (@NonNull Indexable indexable) {
276.176 + IndexWriter luceneWriter = access.getIndexWriter(root, cacheRoot, INDEX_NAME);
276.177 + String relative = access.getRelativePath(indexable);
276.178 +
276.179 + try {
276.180 + luceneWriter.deleteDocuments(new Term("path", relative));
276.181 + } catch (CorruptIndexException ex) {
276.182 + Logger.getLogger(Indexer.class.getName()).log(Level.WARNING, null, ex);
276.183 + } catch (IOException ex) {
276.184 + Logger.getLogger(Indexer.class.getName()).log(Level.WARNING, null, ex);
276.185 + }
276.186 + }
276.187 +
276.188 + @Override
276.189 + public void finish () {
276.190 + access.finish();
276.191 + }
276.192 +
276.193 + private static void addErasedTypeAndSuperTypes(Types javacTypes, Set<String> types, TypeMirror type) {
276.194 + if (type.getKind() == TypeKind.DECLARED) {
276.195 + if (types.add(javacTypes.erasure(type).toString())) {
276.196 + for (TypeMirror sup : javacTypes.directSupertypes(type)) {
276.197 + addErasedTypeAndSuperTypes(javacTypes, types, sup);
276.198 + }
276.199 + }
276.200 + } else if (type.getKind().isPrimitive()) {
276.201 + types.add(type.toString());
276.202 + }
276.203 + }
276.204 +
276.205 + public static final class TokenStreamImpl extends TokenStream {
276.206 +
276.207 + private final Iterator<? extends String> tokens;
276.208 + private final TermAttribute termAtt;
276.209 +
276.210 + public TokenStreamImpl(Iterable<? extends String> tokens) {
276.211 + this.tokens = tokens != null ? tokens.iterator() : /*???*/Collections.<String>emptyList().iterator();
276.212 + this.termAtt = addAttribute(TermAttribute.class);
276.213 + }
276.214 +
276.215 + @Override
276.216 + public boolean incrementToken() throws IOException {
276.217 + if (!tokens.hasNext())
276.218 + return false;
276.219 +
276.220 + String t = tokens.next();
276.221 +
276.222 + termAtt.setTermBuffer(t);
276.223 +
276.224 + return true;
276.225 + }
276.226 + }
276.227 +
276.228 + public static @NonNull FileObject resolveCacheFolder(@NonNull URL sourceRoot) throws IOException {
276.229 + FileObject dataFolder = CacheFolder.getDataFolder(sourceRoot);
276.230 +
276.231 + return FileUtil.createFolder(dataFolder, JavaIndex.NAME + "/" + JavaIndex.VERSION);
276.232 + }
276.233 +
276.234 + @MimeRegistration(mimeType="text/x-java", service=Factory.class)
276.235 + public static final class FactoryImpl implements Factory {
276.236 +
276.237 + @Override
276.238 + public JavaIndexerPlugin create(URL root, FileObject cacheFolder) {
276.239 + return new Indexer(root, cacheFolder);
276.240 + }
276.241 +
276.242 + }
276.243 +}
277.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
277.2 +++ b/language/ide/indexing/test/unit/src/org/netbeans/modules/jackpot30/indexing/index/IndexerTest.java Mon Mar 12 21:10:10 2012 +0100
277.3 @@ -0,0 +1,302 @@
277.4 +/*
277.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
277.6 + *
277.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
277.8 + *
277.9 + * The contents of this file are subject to the terms of either the GNU
277.10 + * General Public License Version 2 only ("GPL") or the Common
277.11 + * Development and Distribution License("CDDL") (collectively, the
277.12 + * "License"). You may not use this file except in compliance with the
277.13 + * License. You can obtain a copy of the License at
277.14 + * http://www.netbeans.org/cddl-gplv2.html
277.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
277.16 + * specific language governing permissions and limitations under the
277.17 + * License. When distributing the software, include this License Header
277.18 + * Notice in each file and include the License file at
277.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
277.20 + * particular file as subject to the "Classpath" exception as provided
277.21 + * by Sun in the GPL Version 2 section of the License file that
277.22 + * accompanied this code. If applicable, add the following below the
277.23 + * License Header, with the fields enclosed by brackets [] replaced by
277.24 + * your own identifying information:
277.25 + * "Portions Copyrighted [year] [name of copyright owner]"
277.26 + *
277.27 + * If you wish your version of this file to be governed by only the CDDL
277.28 + * or only the GPL Version 2, indicate your decision by adding
277.29 + * "[Contributor] elects to include this software in this distribution
277.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
277.31 + * single choice of license, a recipient has the option to distribute
277.32 + * your version of this file under either the CDDL, the GPL Version 2 or
277.33 + * to extend the choice of license to its licensees as provided above.
277.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
277.35 + * Version 2 license, then the option applies only if the new code is
277.36 + * made subject to such option by the copyright holder.
277.37 + *
277.38 + * Contributor(s):
277.39 + *
277.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
277.41 + */
277.42 +
277.43 +package org.netbeans.modules.jackpot30.indexing.index;
277.44 +
277.45 +import java.net.URL;
277.46 +import java.util.Arrays;
277.47 +import java.util.Collections;
277.48 +import java.util.HashMap;
277.49 +import java.util.HashSet;
277.50 +import java.util.Map;
277.51 +import java.util.Set;
277.52 +import org.netbeans.api.editor.mimelookup.MimePath;
277.53 +import org.netbeans.api.java.classpath.ClassPath;
277.54 +import org.netbeans.api.java.source.ClasspathInfo;
277.55 +import org.netbeans.api.java.source.CompilationController;
277.56 +import org.netbeans.api.java.source.JavaSource;
277.57 +import org.netbeans.api.java.source.SourceUtilsTestUtil;
277.58 +import org.netbeans.api.java.source.Task;
277.59 +import org.netbeans.api.java.source.TestUtilities;
277.60 +import org.netbeans.modules.jackpot30.common.test.IndexTestBase;
277.61 +import org.netbeans.modules.java.hints.providers.spi.HintDescription.AdditionalQueryConstraints;
277.62 +import org.netbeans.modules.java.hints.spiimpl.Utilities;
277.63 +import org.netbeans.modules.java.hints.spiimpl.pm.BulkSearch;
277.64 +import org.netbeans.modules.java.hints.spiimpl.pm.BulkSearch.BulkPattern;
277.65 +import org.netbeans.modules.parsing.api.indexing.IndexingManager;
277.66 +import org.netbeans.spi.editor.mimelookup.MimeDataProvider;
277.67 +import org.netbeans.spi.java.classpath.support.ClassPathSupport;
277.68 +import org.openide.filesystems.FileObject;
277.69 +import org.openide.filesystems.FileUtil;
277.70 +import org.openide.util.Lookup;
277.71 +import org.openide.util.lookup.Lookups;
277.72 +import org.openide.util.lookup.ServiceProvider;
277.73 +
277.74 +
277.75 +/**
277.76 + *
277.77 + * @author lahvac
277.78 + */
277.79 +public class IndexerTest extends IndexTestBase {
277.80 +
277.81 + public IndexerTest(String name) {
277.82 + super(name);
277.83 + }
277.84 +
277.85 + public void testMultiplePatternsIndexing() throws Exception {
277.86 + writeFilesAndWaitForScan(src,
277.87 + new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }"),
277.88 + new File("test/Test2.java", "package test; public class Test2 { private void test() { new javax.swing.ImageIcon(null); } }"));
277.89 +
277.90 + String[] patterns = new String[] {
277.91 + "$1.isDirectory()",
277.92 + "new ImageIcon($1)"
277.93 + };
277.94 +
277.95 + verifyIndex(patterns, "test/Test1.java", "test/Test2.java");
277.96 + }
277.97 +
277.98 + public void testLambdaPattern() throws Exception {
277.99 + writeFilesAndWaitForScan(src,
277.100 + new File("test/Test1.java", "package test; public class Test1 { private void test() { Runnable r = new Runnable() { public void run() { System.err.println(); } } } }"));
277.101 +
277.102 + String[] patterns = new String[] {
277.103 + "new $type() {\n $mods$ $resultType $methodName($args$) {\n $statements$;\n }\n }\n",
277.104 + };
277.105 +
277.106 + verifyIndex(patterns, "test/Test1.java");
277.107 + }
277.108 +
277.109 + public void testUpdates() throws Exception {
277.110 + String[] patterns = new String[] {
277.111 + "$1.isDirectory()",
277.112 + "new ImageIcon($1)"
277.113 + };
277.114 +
277.115 + writeFilesAndWaitForScan(src,
277.116 + new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }"),
277.117 + new File("test/Test2.java", "package test; public class Test2 { private void test() { new javax.swing.ImageIcon(null); } }"));
277.118 +
277.119 + verifyIndex(patterns, "test/Test1.java", "test/Test2.java");
277.120 +// assertEquals(2, FileBasedIndex.get(src.getURL()).getIndexInfo().totalFiles);
277.121 +
277.122 + src.getFileObject("test/Test1.java").delete();
277.123 +
277.124 + assertNull(src.getFileObject("test/Test1.java"));
277.125 +
277.126 + IndexingManager.getDefault().refreshIndexAndWait(src.toURL(), null, true);
277.127 +
277.128 + verifyIndex(patterns, "test/Test2.java");
277.129 +// assertEquals(1, FileBasedIndex.get(src.getURL()).getIndexInfo().totalFiles);
277.130 +
277.131 + FileObject test3 = FileUtil.createData(src, "test/Test3.java");
277.132 + TestUtilities.copyStringToFile(test3, "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }");
277.133 +
277.134 + IndexingManager.getDefault().refreshIndexAndWait(src.toURL(), null, true);
277.135 +
277.136 + verifyIndex(patterns, "test/Test2.java", "test/Test3.java");
277.137 +// assertEquals(2, FileBasedIndex.get(src.getURL()).getIndexInfo().totalFiles);
277.138 + }
277.139 +
277.140 + public void testPartiallyAttributed1() throws Exception {
277.141 + writeFilesAndWaitForScan(src,
277.142 + new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }"),
277.143 + new File("test/Test2.java", "package test; public class Test2 { private void isDirectory() { this.isDirectory(); } }"),
277.144 + new File("test/Test3.java", "package test; public class Test3 { private void isDirectory() { this.isDirectory(); } }"));
277.145 +
277.146 + verifyIndex("$1.isDirectory()", new AdditionalQueryConstraints(Collections.singleton("java.io.File")), "test/Test1.java");
277.147 + }
277.148 +
277.149 + public void testPartiallyAttributed2() throws Exception {
277.150 + writeFilesAndWaitForScan(src,
277.151 + new File("test/Test1.java", "package test; public class Test1 { private void test() { String str = null; int l = str.length(); } }"));
277.152 +
277.153 + verifyIndex("$1.length()", new AdditionalQueryConstraints(Collections.singleton("java.lang.CharSequence")), "test/Test1.java");
277.154 + }
277.155 +
277.156 + public void testFrequencies() throws Exception {
277.157 + writeFilesAndWaitForScan(src,
277.158 + new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); f.isDirectory(); } }"),
277.159 + new File("test/Test2.java", "package test; public class Test2 { private void test() { new javax.swing.ImageIcon(null); java.io.File f = null; f.isDirectory(); } }"),
277.160 + new File("test/Test3.java", "package test; public class Test3 { private void test() { new javax.swing.ImageIcon(null); new javax.swing.ImageIcon(null); } }")
277.161 + );
277.162 +
277.163 + String[] patterns = new String[] {
277.164 + "$1.isDirectory()",
277.165 + "new ImageIcon($1)"
277.166 + };
277.167 +
277.168 + Map<String, Map<String, Integer>> golden = new HashMap<String, Map<String, Integer>>();
277.169 +
277.170 + golden.put("test/Test3.java", Collections.singletonMap("new ImageIcon($1)", 2));
277.171 + golden.put("test/Test1.java", Collections.singletonMap("$1.isDirectory()", 2));
277.172 +
277.173 + Map<String, Integer> freqsTest2 = new HashMap<String, Integer>();
277.174 +
277.175 + freqsTest2.put("$1.isDirectory()", 1);
277.176 + freqsTest2.put("new ImageIcon($1)", 1);
277.177 +
277.178 + golden.put("test/Test2.java", freqsTest2);
277.179 +
277.180 + verifyIndexWithFrequencies(patterns, golden);
277.181 + }
277.182 +
277.183 + public void testInnerClass() throws Exception {
277.184 + writeFilesAndWaitForScan(src,
277.185 + new File("test/Test1.java", "package test; public class Test1 { private static final class O implements Iterable<String> { private String next; private String computeNext() { return null; } public String hasNext() { next = computeNext(); return next != null; } } }"));
277.186 +
277.187 + verifyIndex("$this.computeNext()", new AdditionalQueryConstraints(Collections.singleton("test.Test1.O")), "test/Test1.java");
277.188 + }
277.189 +
277.190 + public void testIndexing() throws Exception {
277.191 + writeFilesAndWaitForScan(src,
277.192 + new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }"),
277.193 + new File("test/Test2.java", "package test; public class Test2 { private void test() { new javax.swing.ImageIcon(null); } }"));
277.194 +
277.195 + verifyIndex("$1.isDirectory()", "test/Test1.java");
277.196 + verifyIndex("new ImageIcon($1)", "test/Test2.java");
277.197 +
277.198 + writeFilesAndWaitForScan(src,
277.199 + new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); new javax.swing.ImageIcon(null); } }"),
277.200 + new File("test/Test2.java", "package test; public class Test2 { private void test() { new javax.swing.ImageIcon(null); } }"));
277.201 +
277.202 + verifyIndex("$1.isDirectory()", "test/Test1.java");
277.203 + verifyIndex("new ImageIcon($1)", "test/Test1.java", "test/Test2.java");
277.204 +
277.205 + writeFilesAndWaitForScan(src,
277.206 + new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); new javax.swing.ImageIcon(null); } }"),
277.207 + new File("test/Test2.java", "package test; public class Test2 { }"));
277.208 +
277.209 + verifyIndex("$1.isDirectory()", "test/Test1.java");
277.210 + verifyIndex("new ImageIcon($1)", "test/Test1.java");
277.211 + }
277.212 +
277.213 + private void verifyIndex(final String[] patterns, String... containedIn) throws Exception {
277.214 + ClassPath EMPTY = ClassPathSupport.createClassPath(new FileObject[0]);
277.215 + ClasspathInfo cpInfo = ClasspathInfo.create(ClassPathSupport.createClassPath(SourceUtilsTestUtil.getBootClassPath().toArray(new URL[0])),
277.216 + EMPTY,
277.217 + EMPTY);
277.218 +
277.219 + final Set<String> real = new HashSet<String>();
277.220 +
277.221 + JavaSource.create(cpInfo).runUserActionTask(new Task<CompilationController>() {
277.222 + public void run(CompilationController parameter) throws Exception {
277.223 + real.addAll(IndexQuery.open(src.toURL()).findCandidates(BulkSearch.getDefault().create(parameter, patterns)));
277.224 + }
277.225 + }, true);
277.226 +
277.227 + Set<String> golden = new HashSet<String>(Arrays.asList(containedIn));
277.228 +
277.229 + assertEquals(golden, real);
277.230 + }
277.231 +
277.232 + private void verifyIndex(final String pattern, final AdditionalQueryConstraints additionalConstraints, String... containedIn) throws Exception {
277.233 + ClassPath EMPTY = ClassPathSupport.createClassPath(new FileObject[0]);
277.234 + ClasspathInfo cpInfo = ClasspathInfo.create(ClassPathSupport.createClassPath(SourceUtilsTestUtil.getBootClassPath().toArray(new URL[0])),
277.235 + EMPTY,
277.236 + EMPTY);
277.237 +
277.238 + final Set<String> real = new HashSet<String>();
277.239 +
277.240 + JavaSource.create(cpInfo).runUserActionTask(new Task<CompilationController>() {
277.241 + public void run(CompilationController parameter) throws Exception {
277.242 + BulkPattern bulkPattern = BulkSearch.getDefault().create(Collections.singletonList(pattern),
277.243 + Collections.singletonList(Utilities.parseAndAttribute(parameter, pattern, null)),
277.244 + Collections.singletonList(additionalConstraints));
277.245 +
277.246 + real.addAll(IndexQuery.open(src.toURL()).findCandidates(bulkPattern));
277.247 + }
277.248 + }, true);
277.249 +
277.250 + Set<String> golden = new HashSet<String>(Arrays.asList(containedIn));
277.251 +
277.252 + assertEquals(golden, real);
277.253 + }
277.254 +
277.255 + private void verifyIndexWithFrequencies(final String[] patterns, Map<String, Map<String, Integer>> golden) throws Exception {
277.256 + ClassPath EMPTY = ClassPathSupport.createClassPath(new FileObject[0]);
277.257 + ClasspathInfo cpInfo = ClasspathInfo.create(ClassPathSupport.createClassPath(SourceUtilsTestUtil.getBootClassPath().toArray(new URL[0])),
277.258 + EMPTY,
277.259 + EMPTY);
277.260 +
277.261 + final Map<String, Map<String, Integer>> real = new HashMap<String, Map<String, Integer>>();
277.262 +
277.263 + JavaSource.create(cpInfo).runUserActionTask(new Task<CompilationController>() {
277.264 + public void run(CompilationController parameter) throws Exception {
277.265 + real.putAll(IndexQuery.open(src.toURL()).findCandidatesWithFrequencies(BulkSearch.getDefault().create(parameter, patterns)));
277.266 + }
277.267 + }, true);
277.268 +
277.269 + assertEquals(golden, real);
277.270 + }
277.271 +
277.272 + private void verifyIndex(final String pattern, String... containedIn) throws Exception {
277.273 + ClassPath EMPTY = ClassPathSupport.createClassPath(new FileObject[0]);
277.274 + ClasspathInfo cpInfo = ClasspathInfo.create(ClassPathSupport.createClassPath(SourceUtilsTestUtil.getBootClassPath().toArray(new URL[0])),
277.275 + EMPTY,
277.276 + EMPTY);
277.277 +
277.278 + final Set<String> real = new HashSet<String>();
277.279 +
277.280 + JavaSource.create(cpInfo).runUserActionTask(new Task<CompilationController>() {
277.281 + public void run(CompilationController parameter) throws Exception {
277.282 + real.addAll(IndexQuery.open(src.toURL()).findCandidates(BulkSearch.getDefault().create(parameter, pattern)));
277.283 + }
277.284 + }, true);
277.285 +
277.286 + Set<String> golden = new HashSet<String>(Arrays.asList(containedIn));
277.287 +
277.288 + assertEquals(golden, real);
277.289 + }
277.290 +
277.291 + @ServiceProvider(service=MimeDataProvider.class)
277.292 + public static final class MimeDataProviderImpl implements MimeDataProvider {
277.293 +
277.294 + private static final Lookup L = Lookups.fixed(new Indexer.FactoryImpl());
277.295 +
277.296 + @Override
277.297 + public Lookup getLookup(MimePath mp) {
277.298 + if ("text/x-java".equals(mp.getPath())) {
277.299 + return L;
277.300 + }
277.301 + return Lookup.EMPTY;
277.302 + }
277.303 +
277.304 + }
277.305 +}
277.306 \ No newline at end of file
278.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
278.2 +++ b/language/ide/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
278.3 @@ -0,0 +1,50 @@
278.4 +<?xml version="1.0" encoding="UTF-8"?>
278.5 +<!--
278.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
278.7 +*** EDIT ../build.xml INSTEAD ***
278.8 +-->
278.9 +<project name="language-ide-impl" basedir=".." xmlns:sproject="http://www.netbeans.org/ns/nb-module-suite-project/1">
278.10 + <fail message="Please build using Ant 1.7.1 or higher.">
278.11 + <condition>
278.12 + <not>
278.13 + <antversion atleast="1.7.1"/>
278.14 + </not>
278.15 + </condition>
278.16 + </fail>
278.17 + <property file="nbproject/private/platform-private.properties"/>
278.18 + <property file="nbproject/platform.properties"/>
278.19 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-suite-project/1">
278.20 + <attribute name="name"/>
278.21 + <attribute name="value"/>
278.22 + <sequential>
278.23 + <property name="@{name}" value="${@{value}}"/>
278.24 + </sequential>
278.25 + </macrodef>
278.26 + <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-suite-project/1">
278.27 + <attribute name="property"/>
278.28 + <attribute name="value"/>
278.29 + <sequential>
278.30 + <property name="@{property}" value="@{value}"/>
278.31 + </sequential>
278.32 + </macrodef>
278.33 + <property file="${user.properties.file}"/>
278.34 + <sproject:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir"/>
278.35 + <sproject:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir"/>
278.36 + <sproject:evalprops property="cluster.path.evaluated" value="${cluster.path}"/>
278.37 + <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
278.38 + <condition>
278.39 + <not>
278.40 + <contains string="${cluster.path.evaluated}" substring="platform"/>
278.41 + </not>
278.42 + </condition>
278.43 + </fail>
278.44 + <ant antfile="nbproject/platform.xml"/>
278.45 + <fail message="Cannot find NetBeans build harness. ${line.separator}Check that nbplatform.${nbplatform.active}.netbeans.dest.dir and nbplatform.${nbplatform.active}.harness.dir are defined. ${line.separator}On a developer machine these are normally defined in ${user.properties.file}=${netbeans.user}/build.properties ${line.separator}but for automated builds you should pass these properties to Ant explicitly. ${line.separator}You may instead download the harness and platform: -Dbootstrap.url=.../tasks.jar -Dautoupdate.catalog.url=.../updates.xml">
278.46 + <condition>
278.47 + <not>
278.48 + <available file="${harness.dir}/suite.xml"/>
278.49 + </not>
278.50 + </condition>
278.51 + </fail>
278.52 + <import file="${harness.dir}/suite.xml"/>
278.53 +</project>
279.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
279.2 +++ b/language/ide/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
279.3 @@ -0,0 +1,11 @@
279.4 +build.xml.data.CRC32=d27fe1de
279.5 +build.xml.script.CRC32=466d9285
279.6 +build.xml.stylesheet.CRC32=eaf9f76a@2.49
279.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
279.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
279.9 +nbproject/build-impl.xml.data.CRC32=c11ee7c3
279.10 +nbproject/build-impl.xml.script.CRC32=74ef45bc
279.11 +nbproject/build-impl.xml.stylesheet.CRC32=0f381476@2.49
279.12 +nbproject/platform.xml.data.CRC32=c11ee7c3
279.13 +nbproject/platform.xml.script.CRC32=db9e1f43
279.14 +nbproject/platform.xml.stylesheet.CRC32=df8ac4dd@2.49
280.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
280.2 +++ b/language/ide/nbproject/platform.properties Mon Mar 12 21:10:10 2012 +0100
280.3 @@ -0,0 +1,16 @@
280.4 +cluster.path=\
280.5 + ${nbplatform.active.dir}/apisupport:\
280.6 + ${nbplatform.active.dir}/harness:\
280.7 + ${nbplatform.active.dir}/ide:\
280.8 + ${nbplatform.active.dir}/java:\
280.9 + ${nbplatform.active.dir}/nb:\
280.10 + ${nbplatform.active.dir}/platform:\
280.11 + ${nbplatform.active.dir}/profiler:\
280.12 + ${nbplatform.active.dir}/websvccommon:\
280.13 + ../../remoting/common/build/cluster:\
280.14 + ../../remoting/ide/build/cluster
280.15 +extcluster.../../remoting/ide/build/cluster.javadoc=
280.16 +extcluster.../../remoting/ide/build/cluster.sources=../../remoting/ide
280.17 +extcluster.../remoting/common/build/cluster.javadoc=
280.18 +extcluster.../remoting/common/build/cluster.sources=../../remoting/common
280.19 +nbplatform.active=default
281.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
281.2 +++ b/language/ide/nbproject/platform.xml Mon Mar 12 21:10:10 2012 +0100
281.3 @@ -0,0 +1,34 @@
281.4 +<?xml version="1.0" encoding="UTF-8"?>
281.5 +<project name="platform" default="download" basedir="..">
281.6 + <condition property="download.required">
281.7 + <and>
281.8 + <not>
281.9 + <available file="${harness.dir}/suite.xml"/>
281.10 + </not>
281.11 + <isset property="bootstrap.url"/>
281.12 + <isset property="autoupdate.catalog.url"/>
281.13 + </and>
281.14 + </condition>
281.15 + <target name="download" if="download.required">
281.16 + <mkdir dir="${harness.dir}"/>
281.17 + <pathconvert pathsep="|" property="download.clusters">
281.18 + <mapper type="flatten"/>
281.19 + <path path="${cluster.path}"/>
281.20 + </pathconvert>
281.21 + <property name="disabled.modules" value=""/>
281.22 + <pathconvert property="module.includes" pathsep="">
281.23 + <mapper type="glob" from="${basedir}${file.separator}*" to="(?!\Q*\E)"/>
281.24 + <path>
281.25 + <filelist files="${disabled.modules}" dir="."/>
281.26 + </path>
281.27 + </pathconvert>
281.28 + <echo message="Downloading clusters ${download.clusters}"/>
281.29 + <property name="tasks.jar" location="${java.io.tmpdir}/tasks.jar"/>
281.30 + <get src="${bootstrap.url}" dest="${tasks.jar}" usetimestamp="true" verbose="true"/>
281.31 + <taskdef name="autoupdate" classname="org.netbeans.nbbuild.AutoUpdate" classpath="${tasks.jar}"/>
281.32 + <autoupdate installdir="${nbplatform.active.dir}" updatecenter="${autoupdate.catalog.url}">
281.33 + <modules includes="${module.includes}.*" clusters="${download.clusters}"/>
281.34 + <modules includes="org[.]netbeans[.]modules[.]apisupport[.]harness" clusters="harness"/>
281.35 + </autoupdate>
281.36 + </target>
281.37 +</project>
282.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
282.2 +++ b/language/ide/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
282.3 @@ -0,0 +1,7 @@
282.4 +modules=\
282.5 + ${project.org.netbeans.modules.jackpot30.indexing}:\
282.6 + ${project.org.netbeans.modules.jackpot30.ui}:\
282.7 + ${project.org.netbeans.modules.jackpot30.apisupport}
282.8 +project.org.netbeans.modules.jackpot30.apisupport=bridges/apisupport
282.9 +project.org.netbeans.modules.jackpot30.indexing=indexing
282.10 +project.org.netbeans.modules.jackpot30.ui=ui
283.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
283.2 +++ b/language/ide/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
283.3 @@ -0,0 +1,9 @@
283.4 +<?xml version="1.0" encoding="UTF-8"?>
283.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
283.6 + <type>org.netbeans.modules.apisupport.project.suite</type>
283.7 + <configuration>
283.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-suite-project/1">
283.9 + <name>language-ide</name>
283.10 + </data>
283.11 + </configuration>
283.12 +</project>
284.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
284.2 +++ b/language/ide/ui/build.xml Mon Mar 12 21:10:10 2012 +0100
284.3 @@ -0,0 +1,8 @@
284.4 +<?xml version="1.0" encoding="UTF-8"?>
284.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
284.6 +<!-- for some information on what you could do (e.g. targets to override). -->
284.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
284.8 +<project name="org.netbeans.modules.jackpot30.ui" default="netbeans" basedir=".">
284.9 + <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.ui.</description>
284.10 + <import file="nbproject/build-impl.xml"/>
284.11 +</project>
285.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
285.2 +++ b/language/ide/ui/manifest.mf Mon Mar 12 21:10:10 2012 +0100
285.3 @@ -0,0 +1,6 @@
285.4 +Manifest-Version: 1.0
285.5 +OpenIDE-Module: org.netbeans.modules.jackpot30.ui
285.6 +OpenIDE-Module-Layer: org/netbeans/modules/jackpot30/ui/layer.xml
285.7 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/ui/Bundle.properties
285.8 +OpenIDE-Module-Specification-Version: 1.0
285.9 +
286.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
286.2 +++ b/language/ide/ui/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
286.3 @@ -0,0 +1,45 @@
286.4 +<?xml version="1.0" encoding="UTF-8"?>
286.5 +<!--
286.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
286.7 +*** EDIT ../build.xml INSTEAD ***
286.8 +-->
286.9 +<project name="org.netbeans.modules.jackpot30.ui-impl" basedir="..">
286.10 + <fail message="Please build using Ant 1.7.1 or higher.">
286.11 + <condition>
286.12 + <not>
286.13 + <antversion atleast="1.7.1"/>
286.14 + </not>
286.15 + </condition>
286.16 + </fail>
286.17 + <property file="nbproject/private/suite-private.properties"/>
286.18 + <property file="nbproject/suite.properties"/>
286.19 + <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
286.20 + <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
286.21 + <property file="${suite.dir}/nbproject/platform.properties"/>
286.22 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
286.23 + <attribute name="name"/>
286.24 + <attribute name="value"/>
286.25 + <sequential>
286.26 + <property name="@{name}" value="${@{value}}"/>
286.27 + </sequential>
286.28 + </macrodef>
286.29 + <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
286.30 + <attribute name="property"/>
286.31 + <attribute name="value"/>
286.32 + <sequential>
286.33 + <property name="@{property}" value="@{value}"/>
286.34 + </sequential>
286.35 + </macrodef>
286.36 + <property file="${user.properties.file}"/>
286.37 + <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
286.38 + <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
286.39 + <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
286.40 + <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
286.41 + <condition>
286.42 + <not>
286.43 + <contains string="${cluster.path.evaluated}" substring="platform"/>
286.44 + </not>
286.45 + </condition>
286.46 + </fail>
286.47 + <import file="${harness.dir}/build.xml"/>
286.48 +</project>
287.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
287.2 +++ b/language/ide/ui/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
287.3 @@ -0,0 +1,8 @@
287.4 +build.xml.data.CRC32=8131ef5a
287.5 +build.xml.script.CRC32=4ac38acd
287.6 +build.xml.stylesheet.CRC32=a56c6a5b@2.49
287.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
287.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
287.9 +nbproject/build-impl.xml.data.CRC32=8131ef5a
287.10 +nbproject/build-impl.xml.script.CRC32=e59dabeb
287.11 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.49
288.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
288.2 +++ b/language/ide/ui/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
288.3 @@ -0,0 +1,3 @@
288.4 +javac.source=1.6
288.5 +javac.compilerargs=-Xlint -Xlint:-serial
288.6 +requires.nb.javac=true
289.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
289.2 +++ b/language/ide/ui/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
289.3 @@ -0,0 +1,151 @@
289.4 +<?xml version="1.0" encoding="UTF-8"?>
289.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
289.6 + <type>org.netbeans.modules.apisupport.project</type>
289.7 + <configuration>
289.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
289.9 + <code-name-base>org.netbeans.modules.jackpot30.ui</code-name-base>
289.10 + <suite-component/>
289.11 + <module-dependencies>
289.12 + <dependency>
289.13 + <code-name-base>org.netbeans.api.annotations.common</code-name-base>
289.14 + <build-prerequisite/>
289.15 + <compile-dependency/>
289.16 + <run-dependency>
289.17 + <release-version>1</release-version>
289.18 + <specification-version>1.13</specification-version>
289.19 + </run-dependency>
289.20 + </dependency>
289.21 + <dependency>
289.22 + <code-name-base>org.netbeans.libs.javacapi</code-name-base>
289.23 + <build-prerequisite/>
289.24 + <compile-dependency/>
289.25 + <run-dependency>
289.26 + <specification-version>7.9.0.3</specification-version>
289.27 + </run-dependency>
289.28 + </dependency>
289.29 + <dependency>
289.30 + <code-name-base>org.netbeans.modules.editor</code-name-base>
289.31 + <build-prerequisite/>
289.32 + <compile-dependency/>
289.33 + <run-dependency>
289.34 + <release-version>3</release-version>
289.35 + <specification-version>1.60.0.5.19.25</specification-version>
289.36 + </run-dependency>
289.37 + </dependency>
289.38 + <dependency>
289.39 + <code-name-base>org.netbeans.modules.editor.lib</code-name-base>
289.40 + <build-prerequisite/>
289.41 + <compile-dependency/>
289.42 + <run-dependency>
289.43 + <release-version>3</release-version>
289.44 + <specification-version>3.19.0.19.25</specification-version>
289.45 + </run-dependency>
289.46 + </dependency>
289.47 + <dependency>
289.48 + <code-name-base>org.netbeans.modules.editor.lib2</code-name-base>
289.49 + <build-prerequisite/>
289.50 + <compile-dependency/>
289.51 + <run-dependency>
289.52 + <release-version>1</release-version>
289.53 + <specification-version>1.54.0.25</specification-version>
289.54 + </run-dependency>
289.55 + </dependency>
289.56 + <dependency>
289.57 + <code-name-base>org.netbeans.modules.java.source</code-name-base>
289.58 + <build-prerequisite/>
289.59 + <compile-dependency/>
289.60 + <run-dependency>
289.61 + <specification-version>0.95.0.19.18.6</specification-version>
289.62 + </run-dependency>
289.63 + </dependency>
289.64 + <dependency>
289.65 + <code-name-base>org.openide.awt</code-name-base>
289.66 + <build-prerequisite/>
289.67 + <compile-dependency/>
289.68 + <run-dependency>
289.69 + <specification-version>7.42</specification-version>
289.70 + </run-dependency>
289.71 + </dependency>
289.72 + <dependency>
289.73 + <code-name-base>org.openide.filesystems</code-name-base>
289.74 + <build-prerequisite/>
289.75 + <compile-dependency/>
289.76 + <run-dependency>
289.77 + <specification-version>7.59</specification-version>
289.78 + </run-dependency>
289.79 + </dependency>
289.80 + <dependency>
289.81 + <code-name-base>org.openide.loaders</code-name-base>
289.82 + <build-prerequisite/>
289.83 + <compile-dependency/>
289.84 + <run-dependency>
289.85 + <specification-version>7.36</specification-version>
289.86 + </run-dependency>
289.87 + </dependency>
289.88 + <dependency>
289.89 + <code-name-base>org.openide.nodes</code-name-base>
289.90 + <build-prerequisite/>
289.91 + <compile-dependency/>
289.92 + <run-dependency>
289.93 + <specification-version>7.27</specification-version>
289.94 + </run-dependency>
289.95 + </dependency>
289.96 + <dependency>
289.97 + <code-name-base>org.openide.util</code-name-base>
289.98 + <build-prerequisite/>
289.99 + <compile-dependency/>
289.100 + <run-dependency>
289.101 + <specification-version>8.22</specification-version>
289.102 + </run-dependency>
289.103 + </dependency>
289.104 + <dependency>
289.105 + <code-name-base>org.openide.util.lookup</code-name-base>
289.106 + <build-prerequisite/>
289.107 + <compile-dependency/>
289.108 + <run-dependency>
289.109 + <specification-version>8.12</specification-version>
289.110 + </run-dependency>
289.111 + </dependency>
289.112 + </module-dependencies>
289.113 + <test-dependencies>
289.114 + <test-type>
289.115 + <name>unit</name>
289.116 + <test-dependency>
289.117 + <code-name-base>org.netbeans.libs.junit4</code-name-base>
289.118 + <compile-dependency/>
289.119 + </test-dependency>
289.120 + <test-dependency>
289.121 + <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
289.122 + <compile-dependency/>
289.123 + </test-dependency>
289.124 + <test-dependency>
289.125 + <code-name-base>org.netbeans.modules.java.editor</code-name-base>
289.126 + <compile-dependency/>
289.127 + </test-dependency>
289.128 + <test-dependency>
289.129 + <code-name-base>org.netbeans.modules.java.hints</code-name-base>
289.130 + <compile-dependency/>
289.131 + </test-dependency>
289.132 + <test-dependency>
289.133 + <code-name-base>org.netbeans.modules.java.hints.declarative</code-name-base>
289.134 + <compile-dependency/>
289.135 + </test-dependency>
289.136 + <test-dependency>
289.137 + <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
289.138 + <recursive/>
289.139 + <compile-dependency/>
289.140 + </test-dependency>
289.141 + <test-dependency>
289.142 + <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
289.143 + <compile-dependency/>
289.144 + </test-dependency>
289.145 + <test-dependency>
289.146 + <code-name-base>org.netbeans.spi.java.hints</code-name-base>
289.147 + <compile-dependency/>
289.148 + </test-dependency>
289.149 + </test-type>
289.150 + </test-dependencies>
289.151 + <public-packages/>
289.152 + </data>
289.153 + </configuration>
289.154 +</project>
290.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
290.2 +++ b/language/ide/ui/nbproject/suite.properties Mon Mar 12 21:10:10 2012 +0100
290.3 @@ -0,0 +1,1 @@
290.4 +suite.dir=${basedir}/..
291.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
291.2 +++ b/language/ide/ui/src/org/netbeans/modules/jackpot30/ui/Bundle.properties Mon Mar 12 21:10:10 2012 +0100
291.3 @@ -0,0 +1,1 @@
291.4 +OpenIDE-Module-Name=Jackpot 3.0 Extra UI
292.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
292.2 +++ b/language/ide/ui/src/org/netbeans/modules/jackpot30/ui/GenerateJackpotScript.java Mon Mar 12 21:10:10 2012 +0100
292.3 @@ -0,0 +1,112 @@
292.4 +/*
292.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
292.6 + *
292.7 + * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
292.8 + *
292.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
292.10 + * Other names may be trademarks of their respective owners.
292.11 + *
292.12 + * The contents of this file are subject to the terms of either the GNU
292.13 + * General Public License Version 2 only ("GPL") or the Common
292.14 + * Development and Distribution License("CDDL") (collectively, the
292.15 + * "License"). You may not use this file except in compliance with the
292.16 + * License. You can obtain a copy of the License at
292.17 + * http://www.netbeans.org/cddl-gplv2.html
292.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
292.19 + * specific language governing permissions and limitations under the
292.20 + * License. When distributing the software, include this License Header
292.21 + * Notice in each file and include the License file at
292.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
292.23 + * particular file as subject to the "Classpath" exception as provided
292.24 + * by Oracle in the GPL Version 2 section of the License file that
292.25 + * accompanied this code. If applicable, add the following below the
292.26 + * License Header, with the fields enclosed by brackets [] replaced by
292.27 + * your own identifying information:
292.28 + * "Portions Copyrighted [year] [name of copyright owner]"
292.29 + *
292.30 + * If you wish your version of this file to be governed by only the CDDL
292.31 + * or only the GPL Version 2, indicate your decision by adding
292.32 + * "[Contributor] elects to include this software in this distribution
292.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
292.34 + * single choice of license, a recipient has the option to distribute
292.35 + * your version of this file under either the CDDL, the GPL Version 2 or
292.36 + * to extend the choice of license to its licensees as provided above.
292.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
292.38 + * Version 2 license, then the option applies only if the new code is
292.39 + * made subject to such option by the copyright holder.
292.40 + *
292.41 + * Contributor(s):
292.42 + *
292.43 + * Portions Copyrighted 2012 Sun Microsystems, Inc.
292.44 + */
292.45 +
292.46 +package org.netbeans.modules.jackpot30.ui;
292.47 +
292.48 +import com.sun.source.util.TreePath;
292.49 +import java.awt.Toolkit;
292.50 +import java.awt.datatransfer.Clipboard;
292.51 +import java.awt.datatransfer.StringSelection;
292.52 +import java.awt.event.ActionEvent;
292.53 +import java.io.IOException;
292.54 +import javax.lang.model.element.Element;
292.55 +import javax.swing.text.JTextComponent;
292.56 +import org.netbeans.api.editor.EditorActionRegistration;
292.57 +import org.netbeans.api.java.source.CompilationController;
292.58 +import org.netbeans.api.java.source.JavaSource;
292.59 +import org.netbeans.api.java.source.JavaSource.Phase;
292.60 +import org.netbeans.api.java.source.Task;
292.61 +import org.netbeans.editor.BaseAction;
292.62 +import org.openide.awt.StatusDisplayer;
292.63 +import org.openide.util.Exceptions;
292.64 +import org.openide.util.Lookup;
292.65 +import org.openide.util.NbBundle.Messages;
292.66 +import org.openide.util.datatransfer.ExClipboard;
292.67 +
292.68 +@Messages("generate-jackpot-script=Generate Jackpot Script")
292.69 +@EditorActionRegistration(name = "generate-jackpot-script")
292.70 +public final class GenerateJackpotScript extends BaseAction {
292.71 +
292.72 + public GenerateJackpotScript() {
292.73 + super();
292.74 + }
292.75 +
292.76 + @Override
292.77 + public void actionPerformed(ActionEvent evt, JTextComponent target) {
292.78 + JavaSource js = JavaSource.forDocument(target.getDocument());
292.79 +
292.80 + if (js == null) {
292.81 + StatusDisplayer.getDefault().setStatusText("Not a Java file.");
292.82 + return ;
292.83 + }
292.84 +
292.85 + final int caret = target.getCaretPosition();
292.86 +
292.87 + try {
292.88 + js.runUserActionTask(new Task<CompilationController>() {
292.89 + @Override public void run(CompilationController parameter) throws Exception {
292.90 + parameter.toPhase(Phase.RESOLVED);
292.91 + TreePath tp = parameter.getTreeUtilities().pathFor(caret);
292.92 + Element el = parameter.getTrees().getElement(tp);
292.93 +
292.94 + if (el != null) {
292.95 + String script = PatternGenerator.generateFindUsagesScript(parameter, el);
292.96 + Clipboard clipboard = Lookup.getDefault().lookup(ExClipboard.class);
292.97 +
292.98 + if (clipboard == null) {
292.99 + clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
292.100 + }
292.101 +
292.102 + clipboard.setContents(new StringSelection(script), null);
292.103 +
292.104 + StatusDisplayer.getDefault().setStatusText("Script generated into clipboard.");
292.105 + } else {
292.106 + StatusDisplayer.getDefault().setStatusText("Cannot resolve Java element.");
292.107 + }
292.108 + }
292.109 + }, true);
292.110 + } catch (IOException ex) {
292.111 + Exceptions.printStackTrace(ex);
292.112 + }
292.113 + }
292.114 +
292.115 +}
293.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
293.2 +++ b/language/ide/ui/src/org/netbeans/modules/jackpot30/ui/PatternGenerator.java Mon Mar 12 21:10:10 2012 +0100
293.3 @@ -0,0 +1,146 @@
293.4 +/*
293.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
293.6 + *
293.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
293.8 + *
293.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
293.10 + * Other names may be trademarks of their respective owners.
293.11 + *
293.12 + * The contents of this file are subject to the terms of either the GNU
293.13 + * General Public License Version 2 only ("GPL") or the Common
293.14 + * Development and Distribution License("CDDL") (collectively, the
293.15 + * "License"). You may not use this file except in compliance with the
293.16 + * License. You can obtain a copy of the License at
293.17 + * http://www.netbeans.org/cddl-gplv2.html
293.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
293.19 + * specific language governing permissions and limitations under the
293.20 + * License. When distributing the software, include this License Header
293.21 + * Notice in each file and include the License file at
293.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
293.23 + * particular file as subject to the "Classpath" exception as provided
293.24 + * by Oracle in the GPL Version 2 section of the License file that
293.25 + * accompanied this code. If applicable, add the following below the
293.26 + * License Header, with the fields enclosed by brackets [] replaced by
293.27 + * your own identifying information:
293.28 + * "Portions Copyrighted [year] [name of copyright owner]"
293.29 + *
293.30 + * If you wish your version of this file to be governed by only the CDDL
293.31 + * or only the GPL Version 2, indicate your decision by adding
293.32 + * "[Contributor] elects to include this software in this distribution
293.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
293.34 + * single choice of license, a recipient has the option to distribute
293.35 + * your version of this file under either the CDDL, the GPL Version 2 or
293.36 + * to extend the choice of license to its licensees as provided above.
293.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
293.38 + * Version 2 license, then the option applies only if the new code is
293.39 + * made subject to such option by the copyright holder.
293.40 + *
293.41 + * Contributor(s):
293.42 + *
293.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
293.44 + */
293.45 +
293.46 +package org.netbeans.modules.jackpot30.ui;
293.47 +
293.48 +import javax.lang.model.element.Element;
293.49 +import javax.lang.model.element.ExecutableElement;
293.50 +import javax.lang.model.element.Modifier;
293.51 +import javax.lang.model.element.TypeElement;
293.52 +import javax.lang.model.element.VariableElement;
293.53 +import org.netbeans.api.annotations.common.CheckForNull;
293.54 +import org.netbeans.api.annotations.common.NonNull;
293.55 +import org.netbeans.api.java.source.CompilationInfo;
293.56 +
293.57 +/**
293.58 + *
293.59 + * @author lahvac
293.60 + */
293.61 +public class PatternGenerator {
293.62 +
293.63 + public static @CheckForNull String generateFindUsagesScript(CompilationInfo info, Element usagesOf) {
293.64 + switch (usagesOf.getKind()) {
293.65 + case METHOD: return generateMethodFindUsagesScript(info, (ExecutableElement) usagesOf);
293.66 + case ENUM_CONSTANT:
293.67 + case FIELD: return generateFieldFindUsagesScript(info, (VariableElement) usagesOf);
293.68 + case ANNOTATION_TYPE:
293.69 + case CLASS:
293.70 + case ENUM:
293.71 + case INTERFACE: return generateClassFindUsagesScript(info, (TypeElement) usagesOf);
293.72 + default: return null;
293.73 + }
293.74 + }
293.75 +
293.76 + private static @NonNull String generateMethodFindUsagesScript(CompilationInfo info, ExecutableElement usagesOf) {
293.77 + StringBuilder script = new StringBuilder();
293.78 + StringBuilder parameters = new StringBuilder();
293.79 + StringBuilder constraints = new StringBuilder();
293.80 + String enclosingType = info.getTypes().erasure(usagesOf.getEnclosingElement().asType()).toString();
293.81 + int count = 1;
293.82 +
293.83 + if (usagesOf.getModifiers().contains(Modifier.STATIC)) {
293.84 + script.append(enclosingType);
293.85 + } else {
293.86 + script.append("$this");
293.87 + constraints.append("$this instanceof ").append(enclosingType);
293.88 + }
293.89 +
293.90 + script.append(".").append(usagesOf.getSimpleName()).append("(");
293.91 +
293.92 + for (VariableElement p : usagesOf.getParameters()) {
293.93 + if (count > 1) {
293.94 + parameters.append(", ");
293.95 + }
293.96 +
293.97 + if (constraints.length() > 0) {
293.98 + constraints.append(" && ");
293.99 + }
293.100 + parameters.append("$").append(count);
293.101 + constraints.append("$").append(count).append(" instanceof ").append(info.getTypes().erasure(p.asType()));
293.102 + count++;
293.103 + }
293.104 +
293.105 + script.append(parameters).append(")");
293.106 +
293.107 + if (constraints.length() > 0) {
293.108 + script.append(" :: ").append(constraints);
293.109 + }
293.110 +
293.111 + script.append(";;");
293.112 +
293.113 + return script.toString();
293.114 + }
293.115 +
293.116 + private static @NonNull String generateFieldFindUsagesScript(CompilationInfo info, VariableElement usagesOf) {
293.117 + StringBuilder script = new StringBuilder();
293.118 + StringBuilder constraints = new StringBuilder();
293.119 + String enclosingType = info.getTypes().erasure(usagesOf.getEnclosingElement().asType()).toString();
293.120 + int count = 1;
293.121 +
293.122 + if (usagesOf.getModifiers().contains(Modifier.STATIC)) {
293.123 + script.append(enclosingType);
293.124 + } else {
293.125 + script.append("$this");
293.126 + constraints.append("$this instanceof ").append(enclosingType);
293.127 + }
293.128 +
293.129 + script.append(".").append(usagesOf.getSimpleName());
293.130 +
293.131 + if (constraints.length() > 0) {
293.132 + script.append(" :: ").append(constraints);
293.133 + }
293.134 +
293.135 + script.append(";;");
293.136 +
293.137 + return script.toString();
293.138 + }
293.139 +
293.140 + private static @NonNull String generateClassFindUsagesScript(CompilationInfo info, TypeElement usagesOf) {
293.141 + StringBuilder script = new StringBuilder();
293.142 +
293.143 + script.append(usagesOf.getQualifiedName());
293.144 + script.append(";;");
293.145 +
293.146 + return script.toString();
293.147 + }
293.148 +
293.149 +}
294.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
294.2 +++ b/language/ide/ui/src/org/netbeans/modules/jackpot30/ui/layer.xml Mon Mar 12 21:10:10 2012 +0100
294.3 @@ -0,0 +1,15 @@
294.4 +<?xml version="1.0" encoding="UTF-8"?>
294.5 +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
294.6 +<filesystem>
294.7 + <folder name="Editors">
294.8 + <folder name="text">
294.9 + <folder name="x-java">
294.10 + <folder name="Popup">
294.11 + <file name="generate-jackpot-script">
294.12 + <attr name="position" intvalue="1590" />
294.13 + </file>
294.14 + </folder>
294.15 + </folder>
294.16 + </folder>
294.17 + </folder>
294.18 +</filesystem>
295.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
295.2 +++ b/language/ide/ui/test/unit/src/org/netbeans/modules/jackpot30/ui/PatternGeneratorTest.java Mon Mar 12 21:10:10 2012 +0100
295.3 @@ -0,0 +1,134 @@
295.4 +/*
295.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
295.6 + *
295.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
295.8 + *
295.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
295.10 + * Other names may be trademarks of their respective owners.
295.11 + *
295.12 + * The contents of this file are subject to the terms of either the GNU
295.13 + * General Public License Version 2 only ("GPL") or the Common
295.14 + * Development and Distribution License("CDDL") (collectively, the
295.15 + * "License"). You may not use this file except in compliance with the
295.16 + * License. You can obtain a copy of the License at
295.17 + * http://www.netbeans.org/cddl-gplv2.html
295.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
295.19 + * specific language governing permissions and limitations under the
295.20 + * License. When distributing the software, include this License Header
295.21 + * Notice in each file and include the License file at
295.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
295.23 + * particular file as subject to the "Classpath" exception as provided
295.24 + * by Oracle in the GPL Version 2 section of the License file that
295.25 + * accompanied this code. If applicable, add the following below the
295.26 + * License Header, with the fields enclosed by brackets [] replaced by
295.27 + * your own identifying information:
295.28 + * "Portions Copyrighted [year] [name of copyright owner]"
295.29 + *
295.30 + * If you wish your version of this file to be governed by only the CDDL
295.31 + * or only the GPL Version 2, indicate your decision by adding
295.32 + * "[Contributor] elects to include this software in this distribution
295.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
295.34 + * single choice of license, a recipient has the option to distribute
295.35 + * your version of this file under either the CDDL, the GPL Version 2 or
295.36 + * to extend the choice of license to its licensees as provided above.
295.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
295.38 + * Version 2 license, then the option applies only if the new code is
295.39 + * made subject to such option by the copyright holder.
295.40 + *
295.41 + * Contributor(s):
295.42 + *
295.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
295.44 + */
295.45 +
295.46 +package org.netbeans.modules.jackpot30.ui;
295.47 +
295.48 +import com.sun.source.util.TreePath;
295.49 +import java.util.List;
295.50 +import java.util.concurrent.atomic.AtomicBoolean;
295.51 +import org.netbeans.api.java.source.CompilationInfo;
295.52 +import org.netbeans.modules.java.hints.infrastructure.TreeRuleTestBase;
295.53 +import org.netbeans.modules.java.hints.jackpot.spi.PatternConvertor;
295.54 +import org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker;
295.55 +import org.netbeans.spi.editor.hints.ErrorDescription;
295.56 +
295.57 +/**
295.58 + *
295.59 + * @author lahvac
295.60 + */
295.61 +public class PatternGeneratorTest extends TreeRuleTestBase {
295.62 +
295.63 + public PatternGeneratorTest(String name) {
295.64 + super(name);
295.65 + }
295.66 +
295.67 + public void testStaticMethod() throws Exception {
295.68 + performTest("package test;\n" +
295.69 + "public class Test {\n" +
295.70 + " public static void te|st(int i, String s) {\n" +
295.71 + " test(i, s);\n" +
295.72 + " }\n" +
295.73 + "}\n",
295.74 + "3:8-3:12:verifier:TODO: No display name");
295.75 + }
295.76 +
295.77 + public void testInstanceMethod() throws Exception {
295.78 + performTest("package test;\n" +
295.79 + "public class Test {\n" +
295.80 + " public void te|st(int i, String s) {\n" +
295.81 + " new Test().test(i, s);\n" +
295.82 + " test(i, s);\n" +
295.83 + " }\n" +
295.84 + "}\n",
295.85 + "3:19-3:23:verifier:TODO: No display name",
295.86 + "4:8-4:12:verifier:TODO: No display name");
295.87 + }
295.88 +
295.89 + public void testStaticField() throws Exception {
295.90 + performTest("package test;\n" +
295.91 + "public class Test {\n" +
295.92 + " public static int I|I = 0;" +
295.93 + " public int test() {\n" +
295.94 + " return II;\n" +
295.95 + " }\n" +
295.96 + "}\n",
295.97 + "3:15-3:17:verifier:TODO: No display name");
295.98 + }
295.99 +
295.100 + public void testInstanceField() throws Exception {
295.101 + performTest("package test;\n" +
295.102 + "public class Test {\n" +
295.103 + " public int I|I = 0;" +
295.104 + " public int test() {\n" +
295.105 + " if (true) return II; else return new Test().II;\n" +
295.106 + " }\n" +
295.107 + "}\n",
295.108 + "3:25-3:27:verifier:TODO: No display name",
295.109 + "3:52-3:54:verifier:TODO: No display name");
295.110 + }
295.111 +
295.112 + private void performTest(String code, String... golden) throws Exception {
295.113 + performAnalysisTest("test/Test.java",
295.114 + code,
295.115 + golden);
295.116 + }
295.117 +
295.118 + @Override
295.119 + protected List<ErrorDescription> computeErrors(CompilationInfo info, TreePath path) {
295.120 + String script = PatternGenerator.generateFindUsagesScript(info, info.getTrees().getElement(path));
295.121 +
295.122 + return new HintsInvoker(info, new AtomicBoolean()).computeHints(info, PatternConvertor.create(script));
295.123 + }
295.124 +
295.125 + @Override
295.126 + public void testIssue105979() throws Exception {}
295.127 +
295.128 + @Override
295.129 + public void testIssue108246() throws Exception {}
295.130 +
295.131 + @Override
295.132 + public void testIssue113933() throws Exception {}
295.133 +
295.134 + @Override
295.135 + public void testNoHintsForSimpleInitialize() throws Exception {}
295.136 +
295.137 +}
296.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
296.2 +++ b/lib/download.xml Mon Mar 12 21:10:10 2012 +0100
296.3 @@ -0,0 +1,88 @@
296.4 +<project name="download" default="download">
296.5 + <target name="download" depends="copy-from-platform">
296.6 + <property name="imported.basedir" value="${basedir}"/>
296.7 +
296.8 + <macrodef name="download">
296.9 + <attribute name="url"/>
296.10 + <attribute name="target"/>
296.11 + <sequential>
296.12 + <antcall target="-download" inheritAll="false">
296.13 + <param name="url" value="@{url}" />
296.14 + <param name="target" value="@{target}" />
296.15 + <param name="imported.basedir" value="${imported.basedir}" />
296.16 + </antcall>
296.17 + </sequential>
296.18 + </macrodef>
296.19 + <download url="http://download.java.net/maven/2/com/sun/jersey/jersey-client/1.0.1/jersey-client-1.0.1.jar" target="jersey-1.1/jersey-client-1.0.1.jar"/>
296.20 + <download url="http://download.java.net/maven/2/com/sun/jersey/jersey-client/1.0.1/jersey-client-1.0.1-javadoc.jar" target="jersey-1.1/jersey-client-1.0.1-javadoc.jar"/>
296.21 + <download url="http://download.java.net/maven/2/com/sun/jersey/jersey-client/1.0.1/jersey-client-1.0.1-sources.jar" target="jersey-1.1/jersey-client-1.0.1-sources.jar"/>
296.22 + <download url="http://download.java.net/maven/2/com/sun/jersey/jersey-core/1.0.1/jersey-core-1.0.1.jar" target="jersey-1.1/jersey-core-1.0.1.jar"/>
296.23 + <download url="http://download.java.net/maven/2/com/sun/jersey/jersey-core/1.0.1/jersey-core-1.0.1-javadoc.jar" target="jersey-1.1/jersey-core-1.0.1-javadoc.jar"/>
296.24 + <download url="http://download.java.net/maven/2/com/sun/jersey/jersey-core/1.0.1/jersey-core-1.0.1-sources.jar" target="jersey-1.1/jersey-core-1.0.1-sources.jar"/>
296.25 + <download url="http://download.java.net/maven/2/com/sun/jersey/jersey-server/1.0.1/jersey-server-1.0.1.jar" target="jersey-1.1/jersey-server-1.0.1.jar"/>
296.26 + <download url="http://download.java.net/maven/2/com/sun/jersey/jersey-server/1.0.1/jersey-server-1.0.1-javadoc.jar" target="jersey-1.1/jersey-server-1.0.1-javadoc.jar"/>
296.27 + <download url="http://download.java.net/maven/2/com/sun/jersey/jersey-server/1.0.1/jersey-server-1.0.1-sources.jar" target="jersey-1.1/jersey-server-1.0.1-sources.jar"/>
296.28 + <download url="http://download.java.net/maven/2/com/sun/grizzly/grizzly-servlet-webserver/1.8.6.3/grizzly-servlet-webserver-1.8.6.3.jar" target="jersey-1.1/grizzly-servlet-webserver-1.8.6.3.jar"/>
296.29 +<!-- <download url="http://download.java.net/maven/2/com/sun/grizzly/grizzly-servlet-webserver/1.9.14/grizzly-servlet-webserver-1.9.14-javadoc.jar" target="jersey-1.1/grizzly-servlet-webserver-1.9.14-javadoc.jar"/>-->
296.30 +<!-- <download url="http://download.java.net/maven/2/com/sun/grizzly/grizzly-servlet-webserver/1.9.14/grizzly-servlet-webserver-1.9.14-sources.jar" target="jersey-1.1/grizzly-servlet-webserver-1.9.14-sources.jar"/>-->
296.31 + <download url="http://download.java.net/maven/2/javax/ws/rs/jsr311-api/1.0/jsr311-api-1.0.jar" target="jersey-1.1/jsr311-api-1.0.jar"/>
296.32 + <download url="http://download.java.net/maven/2/javax/ws/rs/jsr311-api/1.0/jsr311-api-1.0-javadoc.jar" target="jersey-1.1/jsr311-api-1.0-javadoc.jar"/>
296.33 + <download url="http://download.java.net/maven/2/javax/ws/rs/jsr311-api/1.0/jsr311-api-1.0-sources.jar" target="jersey-1.1/jsr311-api-1.0-sources.jar"/>
296.34 + <download url="http://repo2.maven.org/maven2/asm/asm-all/3.1/asm-all-3.1.jar" target="jersey-1.1/asm-all-3.1.jar"/>
296.35 + <download url="http://repo2.maven.org/maven2/asm/asm-all/3.1/asm-all-3.1-sources.jar" target="jersey-1.1/asm-all-3.1-sources.jar"/>
296.36 +
296.37 + <download url="http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/3.5.0/lucene-core-3.5.0.jar" target="lucene-3.5.0/lucene-core-3.5.0.jar" />
296.38 + <download url="http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/3.5.0/lucene-core-3.5.0-javadoc.jar" target="lucene-3.5.0/lucene-core-3.5.0-javadoc.jar" />
296.39 + <download url="http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/3.5.0/lucene-core-3.5.0-sources.jar" target="lucene-3.5.0/lucene-core-3.5.0-sources.jar" />
296.40 +
296.41 + <download url="http://repo1.maven.org/maven2/junit/junit/4.5/junit-4.5.jar" target="junit_4/junit-4.5.jar" />
296.42 + <download url="http://switch.dl.sourceforge.net/project/junit/junit/4.5/junit4.5.zip" target="junit_4/junit-4.5-api.zip" />
296.43 + <download url="http://repo1.maven.org/maven2/junit/junit/4.5/junit-4.5-sources.jar" target="junit_4/junit-4.5-src.jar" />
296.44 +
296.45 + <download url="http://repo1.maven.org/maven2/junit/junit/3.8.2/junit-3.8.2.jar" target="junit/junit-3.8.2.jar" />
296.46 + <download url="http://repo1.maven.org/maven2/junit/junit/3.8.2/junit-3.8.2-javadoc.jar" target="junit/junit-3.8.2-javadoc.jar" />
296.47 + <download url="http://repo1.maven.org/maven2/junit/junit/3.8.2/junit-3.8.2-sources.jar" target="junit/junit-3.8.2-sources.jar" />
296.48 +
296.49 + <download url="http://cdn.bitbucket.org/jlahoda/jackpot30/downloads/org-netbeans-modules-java-j2seproject-copylibstask.jar" target="CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar" />
296.50 +
296.51 + <download url="http://mirrors.ibiblio.org/pub/mirrors/maven2/org/freemarker/freemarker/2.3.16/freemarker-2.3.16.jar" target="freemarker/freemarker-2.3.16.jar" />
296.52 +
296.53 + <download url="http://mirrors.ibiblio.org/pub/mirrors/maven2/net/sf/jopt-simple/jopt-simple/3.2/jopt-simple-3.2.jar" target="jopt-simple/jopt-simple-3.2.jar" />
296.54 + <download url="http://mirrors.ibiblio.org/pub/mirrors/maven2/net/sf/jopt-simple/jopt-simple/3.2/jopt-simple-3.2-sources.jar" target="jopt-simple/jopt-simple-3.2-sources.jar" />
296.55 + <download url="http://mirrors.ibiblio.org/pub/mirrors/maven2/net/sf/jopt-simple/jopt-simple/3.2/jopt-simple-3.2-javadoc.jar" target="jopt-simple/jopt-simple-3.2-javadoc.jar" />
296.56 + </target>
296.57 +
296.58 + <target name="-download-check-exists">
296.59 + <available property="file.exists" file="${imported.basedir}/lib/${target}"/>
296.60 + </target>
296.61 +
296.62 + <target name="-download" depends="-download-check-exists" unless="file.exists">
296.63 + <dirname property="dir" file="${imported.basedir}/${target}" />
296.64 + <mkdir dir="${dir}" />
296.65 + <get src="${url}" dest="${imported.basedir}/${target}" usetimestamp="true"/>
296.66 + </target>
296.67 +
296.68 + <target name="-prepare-imported-basedir-property">
296.69 + <dirname property="imported.basedir" file="${ant.file.download}"/>
296.70 + </target>
296.71 + <target name="-post-init" depends="-prepare-imported-basedir-property,download"/>
296.72 +
296.73 + <target name="copy-from-platform">
296.74 + <fail unless="nbplatform.active.dir" />
296.75 + <copy file="${nbplatform.active.dir}/java/modules/org-netbeans-modules-java-source.jar" todir="." />
296.76 + <copy file="${nbplatform.active.dir}/java/modules/org-netbeans-modules-java-hints.jar" todir="." />
296.77 + <copy file="${nbplatform.active.dir}/platform/core/org-openide-filesystems.jar" todir="." />
296.78 + <copy file="${nbplatform.active.dir}/platform/lib/org-openide-util.jar" todir="." />
296.79 + <copy file="${nbplatform.active.dir}/platform/lib/org-openide-util-lookup.jar" todir="." />
296.80 + <copy file="${nbplatform.active.dir}/ide/modules/org-netbeans-spi-editor-hints.jar" todir="." />
296.81 + <copy file="${nbplatform.active.dir}/ide/modules/org-netbeans-api-java-classpath.jar" todir="." />
296.82 + <copy file="${nbplatform.active.dir}/java/modules/ext/javac-api-nb-7.0-b07.jar" todir="javac" />
296.83 + <copy file="${nbplatform.active.dir}/java/modules/ext/javac-impl-nb-7.0-b07.jar" todir="javac" />
296.84 + <copy file="${nbplatform.active.dir}/ide/modules/org-netbeans-modules-jumpto.jar" todir="." />
296.85 + <copy file="${nbplatform.active.dir}/platform/modules/org-netbeans-modules-masterfs.jar" todir="." />
296.86 + <copy file="${nbplatform.active.dir}/ide/modules/org-netbeans-modules-parsing-lucene.jar" todir="." />
296.87 + <copy file="${nbplatform.active.dir}/ide/modules/org-netbeans-modules-parsing-api.jar" todir="." />
296.88 + <copy file="${nbplatform.active.dir}/ide/modules/org-netbeans-modules-projectapi.jar" todir="." />
296.89 + <copy file="${nbplatform.active.dir}/java/modules/org-netbeans-modules-java-project.jar" todir="." />
296.90 + </target>
296.91 +</project>
297.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
297.2 +++ b/lib/nblibraries.properties Mon Mar 12 21:10:10 2012 +0100
297.3 @@ -0,0 +1,50 @@
297.4 +libs.jopt-simple.classpath=\
297.5 + ${base}/jopt-simple/jopt-simple-3.2.jar
297.6 +libs.jopt-simple.javadoc=\
297.7 + ${base}/jopt-simple/jopt-simple-3.2-javadoc.jar!//
297.8 +libs.jopt-simple.src=\
297.9 + ${base}/jopt-simple/jopt-simple-3.2-sources.jar
297.10 +libs.junit.classpath=\
297.11 + ${base}/junit/junit-3.8.2.jar
297.12 +libs.junit.javadoc=\
297.13 + ${base}/junit/junit-3.8.2-api.zip
297.14 +libs.junit_4.classpath=\
297.15 + ${base}/junit_4/junit-4.5.jar
297.16 +libs.junit_4.javadoc=\
297.17 + ${base}/junit_4/junit-4.5-api.zip
297.18 +libs.junit_4.src=\
297.19 + ${base}/junit_4/junit-4.5-src.jar
297.20 +libs.CopyLibs.classpath=\
297.21 + ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar
297.22 +libs.jersey.classpath=\
297.23 + ${base}/jersey-1.1/grizzly-servlet-webserver-1.8.6.3.jar:\
297.24 + ${base}/jersey-1.1/jersey-client-1.0.1.jar:\
297.25 + ${base}/jersey-1.1/jersey-core-1.0.1.jar:\
297.26 + ${base}/jersey-1.1/jersey-server-1.0.1.jar:\
297.27 + ${base}/jersey-1.1/asm-all-3.1.jar:\
297.28 + ${base}/jersey-1.1/jsr311-api-1.0.jar
297.29 +libs.jersey.src=\
297.30 + ${base}/jersey-1.1/jersey-client-1.0.1-sources.jar:\
297.31 + ${base}/jersey-1.1/jersey-core-1.0.1-sources.jar:\
297.32 + ${base}/jersey-1.1/jersey-server-1.0.1-sources.jar:\
297.33 + ${base}/jersey-1.1/asm-all-3.1-sources.jar:\
297.34 + ${base}/jersey-1.1/jsr311-api-1.0-sources.jar
297.35 +libs.lucene.classpath=\
297.36 + ${base}/lucene-3.5.0/lucene-core-3.5.0.jar
297.37 +libs.jersey.javadoc=\
297.38 + ${base}/jersey-1.1/jersey-client-1.0.1-javadoc.jar!//:\
297.39 + ${base}/jersey-1.1/jersey-core-1.0.1-javadoc.jar!//:\
297.40 + ${base}/jersey-1.1/jersey-server-1.0.1-javadoc.jar!//:\
297.41 + ${base}/jersey-1.1/jsr311-api-1.0-javadoc.jar!//
297.42 +libs.lucene.javadoc=\
297.43 + ${base}/lucene-3.5.0/lucene-core-3.5.0-javadoc.jar!//
297.44 +libs.lucene.src=\
297.45 + ${base}/lucene-3.5.0/lucene-core-3.5.0-sources.jar
297.46 +libs.javac.classpath=\
297.47 + ${base}/javac/javac-api-nb-7.0-b07.jar:\
297.48 + ${base}/javac/javac-impl-nb-7.0-b07.jar
297.49 +libs.freemarker.classpath=\
297.50 + ${base}/freemarker/freemarker-2.3.16.jar
297.51 +libs.freemarker.src=\
297.52 + ${base}/freemarker/freemarker-src.zip
297.53 +
298.1 --- a/nbproject/build-impl.xml Fri Jan 27 13:35:56 2012 +0100
298.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
298.3 @@ -1,56 +0,0 @@
298.4 -<?xml version="1.0" encoding="UTF-8"?>
298.5 -<!--
298.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
298.7 -*** EDIT ../build.xml INSTEAD ***
298.8 --->
298.9 -<project name="jackpot30-impl" basedir=".." xmlns:sproject="http://www.netbeans.org/ns/nb-module-suite-project/1">
298.10 - <fail message="Please build using Ant 1.7.1 or higher.">
298.11 - <condition>
298.12 - <not>
298.13 - <antversion atleast="1.7.1"/>
298.14 - </not>
298.15 - </condition>
298.16 - </fail>
298.17 - <property file="nbproject/private/platform-private.properties"/>
298.18 - <property file="nbproject/platform.properties"/>
298.19 - <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-suite-project/1">
298.20 - <attribute name="name"/>
298.21 - <attribute name="value"/>
298.22 - <sequential>
298.23 - <property name="@{name}" value="${@{value}}"/>
298.24 - </sequential>
298.25 - </macrodef>
298.26 - <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-suite-project/1">
298.27 - <attribute name="property"/>
298.28 - <attribute name="value"/>
298.29 - <sequential>
298.30 - <property name="@{property}" value="@{value}"/>
298.31 - </sequential>
298.32 - </macrodef>
298.33 - <property file="${user.properties.file}"/>
298.34 - <sproject:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir"/>
298.35 - <sproject:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir"/>
298.36 - <sproject:evalprops property="cluster.path.evaluated" value="${cluster.path}"/>
298.37 - <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
298.38 - <condition>
298.39 - <not>
298.40 - <contains string="${cluster.path.evaluated}" substring="platform"/>
298.41 - </not>
298.42 - </condition>
298.43 - </fail>
298.44 - <fail message="Cannot find NetBeans build harness. ${line.separator}Check that nbplatform.${nbplatform.active}.netbeans.dest.dir and nbplatform.${nbplatform.active}.harness.dir are defined. ${line.separator}On a developer machine these are normally defined in ${user.properties.file}=${netbeans.user}/build.properties ${line.separator}but for automated builds you should pass these properties to Ant explicitly.">
298.45 - <condition>
298.46 - <not>
298.47 - <available type="dir" file="${harness.dir}"/>
298.48 - </not>
298.49 - </condition>
298.50 - </fail>
298.51 - <fail message="Cannot find NetBeans build harness. ${line.separator}Check that nbplatform.${nbplatform.active}.netbeans.dest.dir and nbplatform.${nbplatform.active}.harness.dir are defined. ${line.separator}On a developer machine these are normally defined in ${user.properties.file}=${netbeans.user}/build.properties ${line.separator}but for automated builds you should pass these properties to Ant explicitly.">
298.52 - <condition>
298.53 - <not>
298.54 - <available type="dir" file="${harness.dir}"/>
298.55 - </not>
298.56 - </condition>
298.57 - </fail>
298.58 - <import file="${harness.dir}/suite.xml"/>
298.59 -</project>
299.1 --- a/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
299.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
299.3 @@ -1,11 +0,0 @@
299.4 -build.xml.data.CRC32=89e14acc
299.5 -build.xml.script.CRC32=35d4b33f
299.6 -build.xml.stylesheet.CRC32=531c622b@1.28.0.7
299.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
299.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
299.9 -nbproject/build-impl.xml.data.CRC32=89e14acc
299.10 -nbproject/build-impl.xml.script.CRC32=8f595034
299.11 -nbproject/build-impl.xml.stylesheet.CRC32=56de960a@1.38
299.12 -nbproject/platform.xml.data.CRC32=89e14acc
299.13 -nbproject/platform.xml.script.CRC32=db9e1f43
299.14 -nbproject/platform.xml.stylesheet.CRC32=df8ac4dd@2.46
300.1 --- a/nbproject/platform.properties Fri Jan 27 13:35:56 2012 +0100
300.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
300.3 @@ -1,17 +0,0 @@
300.4 -cluster.path=\
300.5 - ${nbplatform.active.dir}/apisupport:\
300.6 - ${nbplatform.active.dir}/cnd:\
300.7 - ${nbplatform.active.dir}/dlight:\
300.8 - ${nbplatform.active.dir}/enterprise:\
300.9 - ${nbplatform.active.dir}/harness:\
300.10 - ${nbplatform.active.dir}/ide:\
300.11 - ${nbplatform.active.dir}/java:\
300.12 - ${nbplatform.active.dir}/nb:\
300.13 - ${nbplatform.active.dir}/platform:\
300.14 - ${nbplatform.active.dir}/profiler:\
300.15 - ${nbplatform.active.dir}/websvccommon:\
300.16 - borrowedtests/build/cluster:\
300.17 - remoting/ide/build/cluster
300.18 -extcluster.remoting/ide/build/cluster.javadoc=
300.19 -extcluster.remoting/ide/build/cluster.sources=/usr/local/home/lahvac/tmp/jackpot/remoting/ide
300.20 -nbplatform.active=default
301.1 --- a/nbproject/platform.xml Fri Jan 27 13:35:56 2012 +0100
301.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
301.3 @@ -1,34 +0,0 @@
301.4 -<?xml version="1.0" encoding="UTF-8"?>
301.5 -<project name="platform" default="download" basedir="..">
301.6 - <condition property="download.required">
301.7 - <and>
301.8 - <not>
301.9 - <available file="${harness.dir}/suite.xml"/>
301.10 - </not>
301.11 - <isset property="bootstrap.url"/>
301.12 - <isset property="autoupdate.catalog.url"/>
301.13 - </and>
301.14 - </condition>
301.15 - <target name="download" if="download.required">
301.16 - <mkdir dir="${harness.dir}"/>
301.17 - <pathconvert pathsep="|" property="download.clusters">
301.18 - <mapper type="flatten"/>
301.19 - <path path="${cluster.path}"/>
301.20 - </pathconvert>
301.21 - <property name="disabled.modules" value=""/>
301.22 - <pathconvert property="module.includes" pathsep="">
301.23 - <mapper type="glob" from="${basedir}${file.separator}*" to="(?!\Q*\E)"/>
301.24 - <path>
301.25 - <filelist files="${disabled.modules}" dir="."/>
301.26 - </path>
301.27 - </pathconvert>
301.28 - <echo message="Downloading clusters ${download.clusters}"/>
301.29 - <property name="tasks.jar" location="${java.io.tmpdir}/tasks.jar"/>
301.30 - <get src="${bootstrap.url}" dest="${tasks.jar}" usetimestamp="true" verbose="true"/>
301.31 - <taskdef name="autoupdate" classname="org.netbeans.nbbuild.AutoUpdate" classpath="${tasks.jar}"/>
301.32 - <autoupdate installdir="${nbplatform.active.dir}" updatecenter="${autoupdate.catalog.url}">
301.33 - <modules includes="${module.includes}.*" clusters="${download.clusters}"/>
301.34 - <modules includes="org[.]netbeans[.]modules[.]apisupport[.]harness" clusters="harness"/>
301.35 - </autoupdate>
301.36 - </target>
301.37 -</project>
302.1 --- a/nbproject/project.properties Fri Jan 27 13:35:56 2012 +0100
302.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
302.3 @@ -1,17 +0,0 @@
302.4 -modules=\
302.5 - ${project.org.netbeans.modules.jackpot30.hintsimpl}:\
302.6 - ${project.org.netbeans.modules.jackpot30.api}:\
302.7 - ${project.org.netbeans.modules.jackpot30.transformers}:\
302.8 - ${project.org.netbeans.modules.jackpot30.kit}:\
302.9 - ${project.org.netbeans.modules.jackpot30.help}:\
302.10 - ${project.org.netbeans.modules.jackpot30.refactoring}:\
302.11 - ${project.org.netbeans.modules.jackpot30.apisupport}
302.12 -project.org.netbeans.modules.jackpot30.api=api
302.13 -project.org.netbeans.modules.jackpot30.apisupport=bridges/apisupport
302.14 -project.org.netbeans.modules.jackpot30.help=help
302.15 -project.org.netbeans.modules.jackpot30.hintsimpl=hintsimpl
302.16 -project.org.netbeans.modules.jackpot30.kit=kit
302.17 -project.org.netbeans.modules.jackpot30.refactoring=bridges/refactoring
302.18 -project.org.netbeans.modules.jackpot30.transformers=transformer
302.19 -
302.20 -project.license=cddl-netbeans-sun
303.1 --- a/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
303.2 +++ b/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
303.3 @@ -1,9 +1,30 @@
303.4 <?xml version="1.0" encoding="UTF-8"?>
303.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
303.6 - <type>org.netbeans.modules.apisupport.project.suite</type>
303.7 +<project xmlns="http://www.netbeans.org/ns/project/1" xmlns:ns1="null" xmlns:ns2="null">
303.8 + <type>org.netbeans.modules.ant.freeform</type>
303.9 <configuration>
303.10 - <data xmlns="http://www.netbeans.org/ns/nb-module-suite-project/1">
303.11 + <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
303.12 + <!-- Do not use Project Properties customizer when editing this file manually. -->
303.13 <name>jackpot30</name>
303.14 - </data>
303.15 + <properties/>
303.16 + <ide-actions/>
303.17 + <view>
303.18 + <items>
303.19 + <source-file>
303.20 + <location>build.xml</location>
303.21 + </source-file>
303.22 + </items>
303.23 + <context-menu/>
303.24 + </view>
303.25 + <subprojects>
303.26 + <project>cmdline</project>
303.27 + <project>duplicates/ide</project>
303.28 + <project>language/ide</project>
303.29 + <project>remoting/common</project>
303.30 + <project>remoting/ide</project>
303.31 + <project>remoting/server/hudson</project>
303.32 + <project>remoting/server/indexer</project>
303.33 + <project>remoting/server/web/web.main</project>
303.34 + </subprojects>
303.35 + </general-data>
303.36 </configuration>
303.37 </project>
304.1 --- a/overlays/netbeans Fri Jan 27 13:35:56 2012 +0100
304.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
304.3 @@ -1,307 +0,0 @@
304.4 -diff --git a/openide.filesystems/src/META-INF/upgrade/org.openide.filesystems.FileObject.hint b/openide.filesystems/src/META-INF/upgrade/org.openide.filesystems.FileObject.hint
304.5 -new file mode 100644
304.6 ---- /dev/null
304.7 -+++ b/openide.filesystems/src/META-INF/upgrade/org.openide.filesystems.FileObject.hint
304.8 -@@ -0,0 +1,23 @@
304.9 -+'FileObject.getPackageNameExt(char, char) is deprecated':
304.10 -+ $0.getPackageNameExt('/', '.') :: $0 instanceof org.openide.FileObject
304.11 -+=> $0.getPath()
304.12 -+;;
304.13 -+'FileObject.getPackageNameExt(char, char) is deprecated':
304.14 -+ $0.getPackageNameExt($1, '.') :: $0 instanceof org.openide.FileObject && $1 instanceof char
304.15 -+=> $0.getPath().replace('/', $1)
304.16 -+;;
304.17 -+
304.18 -+'FileObject.isReadOnly() is deprecated':
304.19 -+ $0.isReadOnly() :: $0 instanceof org.openide.FileObject
304.20 -+=> !$0.canWrite()
304.21 -+;;
304.22 -+
304.23 -+'Repository.getDefaultFileSystem()':
304.24 -+ org.openide.filesystems.Repository.getDefault.getDefaultFileSystem()
304.25 -+=> org.openide.filesystems.FileUtil.getConfigRoot()
304.26 -+;;
304.27 -+
304.28 -+'Repository.getDefaultFileSystem()':
304.29 -+ org.openide.filesystems.Repository.getDefault.getDefaultFileSystem().findResource($path) :: $path instanceof java.lang.String
304.30 -+=> org.openide.filesystems.FileUtil.getConfigFile($path)
304.31 -+;;
304.32 -diff --git a/openide.loaders/src/META-INF/upgrade/org.openide.loaders.DataObject.hint b/openide.loaders/src/META-INF/upgrade/org.openide.loaders.DataObject.hint
304.33 -new file mode 100644
304.34 ---- /dev/null
304.35 -+++ b/openide.loaders/src/META-INF/upgrade/org.openide.loaders.DataObject.hint
304.36 -@@ -0,0 +1,3 @@
304.37 -+'DataObject.getCookie is obsolette':
304.38 -+$this.getCookie($1) :: $this instanceof org.openide.loaders.DataObject && $1 instanceof java.lang.Class
304.39 -+ => $this.getLookup().lookup($1) ;;
304.40 -diff --git a/openide.nodes/src/META-INF/upgrade/org.openide.nodes.Node.hint b/openide.nodes/src/META-INF/upgrade/org.openide.nodes.Node.hint
304.41 -new file mode 100644
304.42 ---- /dev/null
304.43 -+++ b/openide.nodes/src/META-INF/upgrade/org.openide.nodes.Node.hint
304.44 -@@ -0,0 +1,3 @@
304.45 -+'Node.getCookie is obsolette':
304.46 -+$this.getCookie($1) :: $this instanceof org.openide.loaders.DataObject && $1 instanceof java.lang.Class
304.47 -+ => $this.getLookup().lookup($1) ;;
304.48 -diff --git a/openide.text/src/META-INF/upgrade/org.openide.text.Line.hint b/openide.text/src/META-INF/upgrade/org.openide.text.Line.hint
304.49 -new file mode 100644
304.50 ---- /dev/null
304.51 -+++ b/openide.text/src/META-INF/upgrade/org.openide.text.Line.hint
304.52 -@@ -0,0 +1,12 @@
304.53 -+'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_TRY_SHOW, $1) :: $1 instanceof int && $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.NONE, org.openide.text.Line.ShowVisibilityType.NONE, $1) ;;
304.54 -+'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_SHOW, $1) :: $1 instanceof int && $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.OPEN, org.openide.text.Line.ShowVisibilityType.NONE, $1) ;;
304.55 -+'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_GOTO, $1) :: $1 instanceof int && $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.OPEN, org.openide.text.Line.ShowVisibilityType.FOCUS, $1) ;;
304.56 -+'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_TOFRONT, $1) :: $1 instanceof int && $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.OPEN, org.openide.text.Line.ShowVisibilityType.FRONT, $1) ;;
304.57 -+'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_REUSE, $1) :: $1 instanceof int && $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.REUSE, org.openide.text.Line.ShowVisibilityType.FOCUS, $1) ;;
304.58 -+'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_REUSE_NEW, $1) :: $1 instanceof int && $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.REUSE_NEW, org.openide.text.Line.ShowVisibilityType.FOCUS, $1) ;;
304.59 -+'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_TRY_SHOW) :: $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.NONE, org.openide.text.Line.ShowVisibilityType.NONE) ;;
304.60 -+'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_SHOW) :: $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.OPEN, org.openide.text.Line.ShowVisibilityType.NONE) ;;
304.61 -+'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_GOTO) :: $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.OPEN, org.openide.text.Line.ShowVisibilityType.FOCUS) ;;
304.62 -+'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_TOFRONT) :: $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.OPEN, org.openide.text.Line.ShowVisibilityType.FRONT) ;;
304.63 -+'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_REUSE) :: $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.REUSE, org.openide.text.Line.ShowVisibilityType.FOCUS) ;;
304.64 -+'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_REUSE_NEW) :: $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.REUSE_NEW, org.openide.text.Line.ShowVisibilityType.FOCUS) ;;
304.65 -diff --git a/openide.util/src/META-INF/upgrade/org.openide.ErrorManager.hint b/openide.util/src/META-INF/upgrade/org.openide.ErrorManager.hint
304.66 -new file mode 100644
304.67 ---- /dev/null
304.68 -+++ b/openide.util/src/META-INF/upgrade/org.openide.ErrorManager.hint
304.69 -@@ -0,0 +1,104 @@
304.70 -+'ErrorManager.notify is deprecated':
304.71 -+$this.notify(org.openide.ErrorManager.UNKNOWN, $1) :: $1 instanceof java.lang.Throwable && $this instanceof org.openide.ErrorManager
304.72 -+ =>org.openide.util.Exceptions.printStackTrace($1)
304.73 -+ ;;
304.74 -+
304.75 -+'ErrorManager.notify is deprecated':
304.76 -+org.openide.ErrorManager.getDefault().notify(org.openide.ErrorManager.EXCEPTION, $1) :: $1 instanceof java.lang.Throwable && $this instanceof org.openide.ErrorManager
304.77 -+ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.WARNING, null, $1)
304.78 -+ ;;
304.79 -+
304.80 -+'ErrorManager.notify is deprecated':
304.81 -+org.openide.ErrorManager.getDefault().notify(org.openide.ErrorManager.EXCEPTION, $1) :: $1 instanceof java.lang.Throwable && $this instanceof org.openide.ErrorManager
304.82 -+ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.WARNING, null, $1)
304.83 -+ ;;
304.84 -+
304.85 -+'ErrorManager.notify is deprecated':
304.86 -+org.openide.ErrorManager.getDefault().notify(org.openide.ErrorManager.INFORMATIONAL, $1) :: $1 instanceof java.lang.Throwable && $this instanceof org.openide.ErrorManager
304.87 -+ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.INFO, null, $1)
304.88 -+ ;;
304.89 -+
304.90 -+'ErrorManager.notify is deprecated':
304.91 -+org.openide.ErrorManager.getDefault().notify(org.openide.ErrorManager.USER, $1) :: $1 instanceof java.lang.Throwable && $this instanceof org.openide.ErrorManager
304.92 -+ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.WARNING, null, $1)
304.93 -+ ;;
304.94 -+
304.95 -+'ErrorManager.notify is deprecated':
304.96 -+org.openide.ErrorManager.getDefault().notify(org.openide.ErrorManager.WARNING, $1) :: $1 instanceof java.lang.Throwable && $this instanceof org.openide.ErrorManager
304.97 -+ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.WARNING, null, $1)
304.98 -+ ;;
304.99 -+
304.100 -+'ErrorManager.notify is deprecated':
304.101 -+$this.notify($1) :: $1 instanceof java.lang.Throwable && $this instanceof org.openide.ErrorManager
304.102 -+ =>org.openide.util.Exceptions.printStackTrace($1)
304.103 -+ ;;
304.104 -+
304.105 -+'ErrorManager.log is deprecated':
304.106 -+org.openide.ErrorManager.getDefault().log(org.openide.ErrorManager.UNKNOWN, $1) :: $1 instanceof java.lang.String && $this instanceof org.openide.ErrorManager
304.107 -+ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.INFO, $1)
304.108 -+ ;;
304.109 -+
304.110 -+'ErrorManager.log is deprecated':
304.111 -+org.openide.ErrorManager.getDefault().log(org.openide.ErrorManager.ERROR, $1) :: $1 instanceof java.lang.String && $this instanceof org.openide.ErrorManager
304.112 -+ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.SEVERE, $1)
304.113 -+ ;;
304.114 -+
304.115 -+'ErrorManager.log is deprecated':
304.116 -+org.openide.ErrorManager.getDefault().log(org.openide.ErrorManager.EXCEPTION, $1) :: $1 instanceof java.lang.String && $this instanceof org.openide.ErrorManager
304.117 -+ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.SEVERE, $1)
304.118 -+ ;;
304.119 -+
304.120 -+'ErrorManager.log is deprecated':
304.121 -+org.openide.ErrorManager.getDefault().log(org.openide.ErrorManager.INFORMATIONAL, $1) :: $1 instanceof java.lang.String && $this instanceof org.openide.ErrorManager
304.122 -+ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.FINE, $1)
304.123 -+ ;;
304.124 -+
304.125 -+'ErrorManager.log is deprecated':
304.126 -+org.openide.ErrorManager.getDefault().log(org.openide.ErrorManager.USER, $1) :: $1 instanceof java.lang.String && $this instanceof org.openide.ErrorManager
304.127 -+ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.WARNING, $1)
304.128 -+ ;;
304.129 -+
304.130 -+'ErrorManager.log is deprecated':
304.131 -+org.openide.ErrorManager.getDefault().log(org.openide.ErrorManager.WARNING, $1) :: $1 instanceof java.lang.String && $this instanceof org.openide.ErrorManager
304.132 -+ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.WARNING, $1)
304.133 -+ ;;
304.134 -+
304.135 -+'ErrorManager.log is deprecated':
304.136 -+org.openide.ErrorManager.getDefault().log($1) :: $1 instanceof java.lang.String && $this instanceof org.openide.ErrorManager
304.137 -+ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.FINE, $1)
304.138 -+ ;;
304.139 -+
304.140 -+'ErrorManager.isLoggable is deprecated':
304.141 -+org.openide.ErrorManager.getDefault().isLoggable(org.openide.ErrorManager.UNKNOWN) :: $this instanceof org.openide.ErrorManager
304.142 -+ =>java.util.logging.Logger.getLogger("global").isLoggable(java.util.logging.Level.INFO)
304.143 -+ ;;
304.144 -+
304.145 -+'ErrorManager.isLoggable is deprecated':
304.146 -+org.openide.ErrorManager.getDefault().isLoggable(org.openide.ErrorManager.ERROR) :: $this instanceof org.openide.ErrorManager
304.147 -+ =>java.util.logging.Logger.getLogger("global").isLoggable(java.util.logging.Level.SEVERE)
304.148 -+ ;;
304.149 -+
304.150 -+'ErrorManager.isLoggable is deprecated':
304.151 -+org.openide.ErrorManager.getDefault().isLoggable(org.openide.ErrorManager.EXCEPTION) :: $this instanceof org.openide.ErrorManager
304.152 -+ =>java.util.logging.Logger.getLogger("global").isLoggable(java.util.logging.Level.SEVERE)
304.153 -+ ;;
304.154 -+
304.155 -+'ErrorManager.isLoggable is deprecated':
304.156 -+org.openide.ErrorManager.getDefault().isLoggable(org.openide.ErrorManager.INFORMATIONAL) :: $this instanceof org.openide.ErrorManager
304.157 -+ =>java.util.logging.Logger.getLogger("global").isLoggable(java.util.logging.Level.FINE)
304.158 -+ ;;
304.159 -+
304.160 -+'ErrorManager.isLoggable is deprecated':
304.161 -+org.openide.ErrorManager.getDefault().isLoggable(org.openide.ErrorManager.USER) :: $this instanceof org.openide.ErrorManager
304.162 -+ =>java.util.logging.Logger.getLogger("global").isLoggable(java.util.logging.Level.WARNING)
304.163 -+ ;;
304.164 -+
304.165 -+'ErrorManager.isLoggable is deprecated':
304.166 -+org.openide.ErrorManager.getDefault().isLoggable(org.openide.ErrorManager.WARNING) :: $this instanceof org.openide.ErrorManager
304.167 -+ =>java.util.logging.Logger.getLogger("global").isLoggable(java.util.logging.Level.WARNING)
304.168 -+ ;;
304.169 -+
304.170 -+'ErrorManager.annotate is deprecated':
304.171 -+$this.annotate($1, $2) :: $1 instanceof java.lang.Throwable && $2 instanceof java.lang.String && $this instanceof org.openide.ErrorManager
304.172 -+ =>org.openide.util.Exceptions.attachLocalizedMessage($1, $2)
304.173 -+ ;;
304.174 -diff --git a/openide.util/src/META-INF/upgrade/org.openide.util.Lookup.hint b/openide.util/src/META-INF/upgrade/org.openide.util.Lookup.hint
304.175 -new file mode 100644
304.176 ---- /dev/null
304.177 -+++ b/openide.util/src/META-INF/upgrade/org.openide.util.Lookup.hint
304.178 -@@ -0,0 +1,17 @@
304.179 -+'Lookup.lookupAll can be used instead':
304.180 -+$0.lookup(new org.openide.util.Lookup.Template($1)).allInstances() :: $0 instanceof org.openide.util.Lookup && $1 instanceof java.lang.Class
304.181 -+=>
304.182 -+$0.lookupAll($1)
304.183 -+;;
304.184 -+
304.185 -+'Lookup.lookupResult can be used instead':
304.186 -+$0.lookup(new org.openide.util.Lookup.Template($1)) :: $0 instanceof org.openide.util.Lookup && $1 instanceof java.lang.Class && !parentMatches("$_.allInstances()")
304.187 -+=>
304.188 -+$0.lookupResult($1)
304.189 -+;;
304.190 -+
304.191 -+'Lookup.Template() is deprecated':
304.192 -+new org.openide.util.Lookup.Template()
304.193 -+=>
304.194 -+new org.openide.util.Lookup.Template(java.lang.Object.class)
304.195 -+;;
304.196 -diff --git a/openide.util/src/META-INF/upgrade/org.openide.util.Utilities.hint b/openide.util/src/META-INF/upgrade/org.openide.util.Utilities.hint
304.197 -new file mode 100644
304.198 ---- /dev/null
304.199 -+++ b/openide.util/src/META-INF/upgrade/org.openide.util.Utilities.hint
304.200 -@@ -0,0 +1,19 @@
304.201 -+'Utilities.mergeImages is deprecated':
304.202 -+ org.openide.util.Utilities.mergeImages($1, $2, $3, $4) :: $1 instanceof java.awt.Image && $2 instanceof java.awt.Image && $3 instanceof int && $4 instanceof int
304.203 -+=> org.openide.util.ImageUtilities.mergeImages($1, $2, $3, $4)
304.204 -+;;
304.205 -+
304.206 -+'Utilities.loadImage is deprecated':
304.207 -+ org.openide.util.Utilities.loadImage($1) :: $1 instanceof String
304.208 -+=> org.openide.util.ImageUtilities.loadImage($1)
304.209 -+;;
304.210 -+
304.211 -+'Utilities.icon2Image is deprecated':
304.212 -+ org.openide.util.Utilities.icon2Image($1) :: $1 instanceof javax.swing.Icon
304.213 -+=> org.openide.util.ImageUtilities.icon2Image($1)
304.214 -+;;
304.215 -+
304.216 -+'Utilities.image2Icon can be used instead of new ImageIcon':
304.217 -+ new javax.swing.ImageIcon($1) :: $1 instanceof java.awt.Image
304.218 -+=> org.openide.util.ImageUtilities.image2Icon($1)
304.219 -+;;
304.220 -diff --git a/openide.util/test/unit/src/META-INF/upgrade/org.openide.util.Utilities.test b/openide.util/test/unit/src/META-INF/upgrade/org.openide.util.Utilities.test
304.221 -new file mode 100644
304.222 ---- /dev/null
304.223 -+++ b/openide.util/test/unit/src/META-INF/upgrade/org.openide.util.Utilities.test
304.224 -@@ -0,0 +1,86 @@
304.225 -+%%TestCase mergeImages1
304.226 -+package test;
304.227 -+import java.awt.Image;
304.228 -+import org.openide.util.Utilities;
304.229 -+public class Test {
304.230 -+ private void test() {
304.231 -+ Image i1 = null, i2 = null;
304.232 -+ Utilities.mergeImages(i1, i2, -9, 34);
304.233 -+ }
304.234 -+}
304.235 -+%%=>
304.236 -+package test;
304.237 -+import java.awt.Image;
304.238 -+import org.openide.util.ImageUtilities;
304.239 -+import org.openide.util.Utilities;
304.240 -+public class Test {
304.241 -+ private void test() {
304.242 -+ Image i1 = null, i2 = null;
304.243 -+ ImageUtilities.mergeImages(i1, i2, -9, 34);
304.244 -+ }
304.245 -+}
304.246 -+%%TestCase loadImage1
304.247 -+package test;
304.248 -+import java.awt.Image;
304.249 -+import org.openide.util.Utilities;
304.250 -+public class Test {
304.251 -+ private void test() {
304.252 -+ Utilities.loadImage("foobar");
304.253 -+ }
304.254 -+}
304.255 -+%%=>
304.256 -+package test;
304.257 -+import java.awt.Image;
304.258 -+import org.openide.util.ImageUtilities;
304.259 -+import org.openide.util.Utilities;
304.260 -+public class Test {
304.261 -+ private void test() {
304.262 -+ ImageUtilities.loadImage("foobar");
304.263 -+ }
304.264 -+}
304.265 -+%%TestCase icon2Image1
304.266 -+package test;
304.267 -+import javax.swing.Icon;
304.268 -+import org.openide.util.Utilities;
304.269 -+public class Test {
304.270 -+ private void test() {
304.271 -+ Icon i = null;
304.272 -+ Utilities.icon2Image(i);
304.273 -+ }
304.274 -+}
304.275 -+%%=>
304.276 -+package test;
304.277 -+import javax.swing.Icon;
304.278 -+import org.openide.util.ImageUtilities;
304.279 -+import org.openide.util.Utilities;
304.280 -+public class Test {
304.281 -+ private void test() {
304.282 -+ Icon i = null;
304.283 -+ ImageUtilities.icon2Image(i);
304.284 -+ }
304.285 -+}
304.286 -+%%TestCase image2Icon1
304.287 -+package test;
304.288 -+import java.awt.Image;
304.289 -+import javax.swing.Icon;
304.290 -+import javax.swing.ImageIcon;
304.291 -+import org.openide.util.Utilities;
304.292 -+public class Test {
304.293 -+ private void test() {
304.294 -+ Image img = null;
304.295 -+ Icon i = new ImageIcon(img);
304.296 -+ }
304.297 -+}
304.298 -+%%=>
304.299 -+package test;
304.300 -+import java.awt.Image;
304.301 -+import javax.swing.Icon;
304.302 -+import javax.swing.ImageIcon;
304.303 -+import org.openide.util.ImageUtilities;
304.304 -+import org.openide.util.Utilities;
304.305 -+public class Test {
304.306 -+ private void test() {
304.307 -+ Image img = null;
304.308 -+ Icon i = ImageUtilities.image2Icon(img);
304.309 -+ }
304.310 -+}
305.1 --- a/remoting/build-indexing-backend Fri Jan 27 13:35:56 2012 +0100
305.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
305.3 @@ -1,21 +0,0 @@
305.4 -#!/bin/bash
305.5 -rm -rf build
305.6 -mkdir -p build/indexing-backend
305.7 -(cd server/indexer; ant "$@" clean && ant "$@" build-zip && unzip -d ../../build/indexing-backend dist/indexer.zip) || exit 1
305.8 -mkdir -p build/indexing-backend/web
305.9 -(cd server/web/web.main; ant clean && ant jar && cp -r dist/* ../../../build/indexing-backend/web) || exit 1
305.10 -
305.11 -cp server/scripts/* build/indexing-backend
305.12 -
305.13 -chmod u+x build/temp-indexing-backend/index
305.14 -chmod u+x build/temp-indexing-backend/web
305.15 -
305.16 -(cd build; zip -r indexing-backend.zip indexing-backend) || exit 1
305.17 -(cd build; zip -r indexing-backend-shortened.zip `find indexing-backend -type f | grep -v indexing-backend/indexer/enterprise/ | grep -v indexing-backend/indexer/apisupport/ | grep -v indexing-backend/indexer/cnd/ | grep -v indexing-backend/indexer/dlight/ | grep -v indexing-backend/indexer/harness/ | grep -v indexing-backend/indexer/ide/ | grep -v indexing-backend/indexer/java | grep -v indexing-backend/indexer/nb/ | grep -v indexing-backend/indexer/platform/ | grep -v indexing-backend/indexer/profiler/ | grep -v indexing-backend/indexer/websvccommon/`) || exit 1
305.18 -
305.19 -(cd server/hudson; mvn -Dmaven.test.skip=true clean package && cp target/*.hpi ../../build) || exit
305.20 -
305.21 -mkdir -p ide/local/release/index-server
305.22 -(cd server/web/web.main; cp -r dist/* ../../../ide/local/release/index-server) || exit 1
305.23 -(cd ide; ant "$@" clean && ant "$@" nbms && cp -r build/updates ../build) || exit 1
305.24 -
306.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
306.2 +++ b/remoting/build.sh Mon Mar 12 21:10:10 2012 +0100
306.3 @@ -0,0 +1,21 @@
306.4 +#!/bin/bash
306.5 +(cd common; ant "$@" clean && ant "$@" build) || exit 1
306.6 +(cd ide; ant "$@" clean && (cd ../common; ant "$@" -Dbuild.updates.dir=../ide/build/updates nbms) && ant "$@" nbms) || exit 1
306.7 +rm -rf build
306.8 +mkdir -p build/indexing-backend
306.9 +(cd server/indexer; ant "$@" clean && ant "$@" build-zip && unzip -d ../../build/indexing-backend dist/indexer.zip) || exit 1
306.10 +mkdir -p build/indexing-backend/web
306.11 +(cd server/web/web.main; ant clean && ant jar && cp -r dist/* ../../../build/indexing-backend/web) || exit 1
306.12 +
306.13 +cp server/scripts/* build/indexing-backend
306.14 +
306.15 +chmod u+x build/temp-indexing-backend/index
306.16 +chmod u+x build/temp-indexing-backend/web
306.17 +
306.18 +(cd build; zip -r indexing-backend.zip indexing-backend) || exit 1
306.19 +(cd build; zip -r indexing-backend-shortened.zip `find indexing-backend -type f | grep -v indexing-backend/indexer/enterprise/ | grep -v indexing-backend/indexer/apisupport/ | grep -v indexing-backend/indexer/cnd/ | grep -v indexing-backend/indexer/dlight/ | grep -v indexing-backend/indexer/harness/ | grep -v indexing-backend/indexer/ide/ | grep -v indexing-backend/indexer/java | grep -v indexing-backend/indexer/nb/ | grep -v indexing-backend/indexer/platform/ | grep -v indexing-backend/indexer/profiler/ | grep -v indexing-backend/indexer/websvccommon/`) || exit 1
306.20 +
306.21 +(cd server/hudson; mvn -Dmaven.test.skip=true clean package && cp target/*.hpi ../../build) || exit
306.22 +
306.23 +mkdir -p ide/local/release/index-server
306.24 +(cd server/web/web.main; cp -r dist/* ../../../ide/local/release/index-server) || exit 1
307.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
307.2 +++ b/remoting/common/api/build.xml Mon Mar 12 21:10:10 2012 +0100
307.3 @@ -0,0 +1,8 @@
307.4 +<?xml version="1.0" encoding="UTF-8"?>
307.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
307.6 +<!-- for some information on what you could do (e.g. targets to override). -->
307.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
307.8 +<project name="org.netbeans.modules.jackpot30.common" default="netbeans" basedir=".">
307.9 + <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.common.</description>
307.10 + <import file="nbproject/build-impl.xml"/>
307.11 +</project>
308.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
308.2 +++ b/remoting/common/api/manifest.mf Mon Mar 12 21:10:10 2012 +0100
308.3 @@ -0,0 +1,5 @@
308.4 +Manifest-Version: 1.0
308.5 +OpenIDE-Module: org.netbeans.modules.jackpot30.common
308.6 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/common/Bundle.properties
308.7 +OpenIDE-Module-Specification-Version: 1.0
308.8 +
309.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
309.2 +++ b/remoting/common/api/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
309.3 @@ -0,0 +1,45 @@
309.4 +<?xml version="1.0" encoding="UTF-8"?>
309.5 +<!--
309.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
309.7 +*** EDIT ../build.xml INSTEAD ***
309.8 +-->
309.9 +<project name="org.netbeans.modules.jackpot30.common-impl" basedir="..">
309.10 + <fail message="Please build using Ant 1.7.1 or higher.">
309.11 + <condition>
309.12 + <not>
309.13 + <antversion atleast="1.7.1"/>
309.14 + </not>
309.15 + </condition>
309.16 + </fail>
309.17 + <property file="nbproject/private/suite-private.properties"/>
309.18 + <property file="nbproject/suite.properties"/>
309.19 + <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
309.20 + <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
309.21 + <property file="${suite.dir}/nbproject/platform.properties"/>
309.22 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
309.23 + <attribute name="name"/>
309.24 + <attribute name="value"/>
309.25 + <sequential>
309.26 + <property name="@{name}" value="${@{value}}"/>
309.27 + </sequential>
309.28 + </macrodef>
309.29 + <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
309.30 + <attribute name="property"/>
309.31 + <attribute name="value"/>
309.32 + <sequential>
309.33 + <property name="@{property}" value="@{value}"/>
309.34 + </sequential>
309.35 + </macrodef>
309.36 + <property file="${user.properties.file}"/>
309.37 + <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
309.38 + <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
309.39 + <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
309.40 + <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
309.41 + <condition>
309.42 + <not>
309.43 + <contains string="${cluster.path.evaluated}" substring="platform"/>
309.44 + </not>
309.45 + </condition>
309.46 + </fail>
309.47 + <import file="${harness.dir}/build.xml"/>
309.48 +</project>
310.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
310.2 +++ b/remoting/common/api/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
310.3 @@ -0,0 +1,8 @@
310.4 +build.xml.data.CRC32=06439b23
310.5 +build.xml.script.CRC32=22857ef0
310.6 +build.xml.stylesheet.CRC32=a56c6a5b@2.49
310.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
310.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
310.9 +nbproject/build-impl.xml.data.CRC32=06439b23
310.10 +nbproject/build-impl.xml.script.CRC32=29e163a7
310.11 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.49
311.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
311.2 +++ b/remoting/common/api/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
311.3 @@ -0,0 +1,3 @@
311.4 +is.autoload=true
311.5 +javac.source=1.6
311.6 +javac.compilerargs=-Xlint -Xlint:-serial
312.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
312.2 +++ b/remoting/common/api/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
312.3 @@ -0,0 +1,352 @@
312.4 +<?xml version="1.0" encoding="UTF-8"?>
312.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
312.6 + <type>org.netbeans.modules.apisupport.project</type>
312.7 + <configuration>
312.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
312.9 + <code-name-base>org.netbeans.modules.jackpot30.common</code-name-base>
312.10 + <suite-component/>
312.11 + <module-dependencies>
312.12 + <dependency>
312.13 + <code-name-base>org.jdesktop.layout</code-name-base>
312.14 + <build-prerequisite/>
312.15 + <compile-dependency/>
312.16 + <run-dependency>
312.17 + <release-version>1</release-version>
312.18 + <specification-version>1.7.0.103</specification-version>
312.19 + </run-dependency>
312.20 + </dependency>
312.21 + <dependency>
312.22 + <code-name-base>org.netbeans.api.annotations.common</code-name-base>
312.23 + <build-prerequisite/>
312.24 + <compile-dependency/>
312.25 + <run-dependency>
312.26 + <release-version>1</release-version>
312.27 + <specification-version>1.0</specification-version>
312.28 + </run-dependency>
312.29 + </dependency>
312.30 + <dependency>
312.31 + <code-name-base>org.netbeans.api.java.classpath</code-name-base>
312.32 + <build-prerequisite/>
312.33 + <compile-dependency/>
312.34 + <run-dependency>
312.35 + <release-version>1</release-version>
312.36 + <specification-version>1.19</specification-version>
312.37 + </run-dependency>
312.38 + </dependency>
312.39 + <dependency>
312.40 + <code-name-base>org.netbeans.api.progress</code-name-base>
312.41 + <build-prerequisite/>
312.42 + <compile-dependency/>
312.43 + <run-dependency>
312.44 + <release-version>1</release-version>
312.45 + <specification-version>1.13.0.1</specification-version>
312.46 + </run-dependency>
312.47 + </dependency>
312.48 + <dependency>
312.49 + <code-name-base>org.netbeans.libs.javacapi</code-name-base>
312.50 + <build-prerequisite/>
312.51 + <compile-dependency/>
312.52 + <run-dependency>
312.53 + <specification-version>7.5.0.3</specification-version>
312.54 + </run-dependency>
312.55 + </dependency>
312.56 + <dependency>
312.57 + <code-name-base>org.netbeans.libs.javacimpl</code-name-base>
312.58 + <build-prerequisite/>
312.59 + <compile-dependency/>
312.60 + <run-dependency>
312.61 + <release-version>1</release-version>
312.62 + <implementation-version/>
312.63 + </run-dependency>
312.64 + </dependency>
312.65 + <dependency>
312.66 + <code-name-base>org.netbeans.libs.lucene</code-name-base>
312.67 + <build-prerequisite/>
312.68 + <compile-dependency/>
312.69 + <run-dependency>
312.70 + <release-version>1-3</release-version>
312.71 + <specification-version>2.13</specification-version>
312.72 + </run-dependency>
312.73 + </dependency>
312.74 + <dependency>
312.75 + <code-name-base>org.netbeans.modules.diff</code-name-base>
312.76 + <build-prerequisite/>
312.77 + <compile-dependency/>
312.78 + <run-dependency>
312.79 + <release-version>1</release-version>
312.80 + <implementation-version/>
312.81 + </run-dependency>
312.82 + </dependency>
312.83 + <dependency>
312.84 + <code-name-base>org.netbeans.modules.editor</code-name-base>
312.85 + <build-prerequisite/>
312.86 + <compile-dependency/>
312.87 + <run-dependency>
312.88 + <release-version>3</release-version>
312.89 + <specification-version>1.56.0.5.13.6</specification-version>
312.90 + </run-dependency>
312.91 + </dependency>
312.92 + <dependency>
312.93 + <code-name-base>org.netbeans.modules.editor.lib</code-name-base>
312.94 + <build-prerequisite/>
312.95 + <compile-dependency/>
312.96 + <run-dependency>
312.97 + <release-version>1-3</release-version>
312.98 + <specification-version>1.38.0.9.2</specification-version>
312.99 + </run-dependency>
312.100 + </dependency>
312.101 + <dependency>
312.102 + <code-name-base>org.netbeans.modules.editor.lib2</code-name-base>
312.103 + <build-prerequisite/>
312.104 + <compile-dependency/>
312.105 + <run-dependency>
312.106 + <release-version>1</release-version>
312.107 + <specification-version>1.13.0.2</specification-version>
312.108 + </run-dependency>
312.109 + </dependency>
312.110 + <dependency>
312.111 + <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
312.112 + <build-prerequisite/>
312.113 + <compile-dependency/>
312.114 + <run-dependency>
312.115 + <release-version>1</release-version>
312.116 + <specification-version>1.12</specification-version>
312.117 + </run-dependency>
312.118 + </dependency>
312.119 + <dependency>
312.120 + <code-name-base>org.netbeans.modules.editor.settings</code-name-base>
312.121 + <build-prerequisite/>
312.122 + <compile-dependency/>
312.123 + <run-dependency>
312.124 + <release-version>1</release-version>
312.125 + <specification-version>1.25</specification-version>
312.126 + </run-dependency>
312.127 + </dependency>
312.128 + <dependency>
312.129 + <code-name-base>org.netbeans.modules.java.editor</code-name-base>
312.130 + <build-prerequisite/>
312.131 + <compile-dependency/>
312.132 + <run-dependency>
312.133 + <release-version>1</release-version>
312.134 + <implementation-version/>
312.135 + </run-dependency>
312.136 + </dependency>
312.137 + <dependency>
312.138 + <code-name-base>org.netbeans.modules.java.hints</code-name-base>
312.139 + <build-prerequisite/>
312.140 + <compile-dependency/>
312.141 + <run-dependency>
312.142 + <release-version>1</release-version>
312.143 + <implementation-version/>
312.144 + </run-dependency>
312.145 + </dependency>
312.146 + <dependency>
312.147 + <code-name-base>org.netbeans.modules.java.lexer</code-name-base>
312.148 + <build-prerequisite/>
312.149 + <compile-dependency/>
312.150 + <run-dependency>
312.151 + <release-version>1</release-version>
312.152 + <specification-version>1.9</specification-version>
312.153 + </run-dependency>
312.154 + </dependency>
312.155 + <dependency>
312.156 + <code-name-base>org.netbeans.modules.java.platform</code-name-base>
312.157 + <build-prerequisite/>
312.158 + <compile-dependency/>
312.159 + <run-dependency>
312.160 + <release-version>1</release-version>
312.161 + <specification-version>1.12</specification-version>
312.162 + </run-dependency>
312.163 + </dependency>
312.164 + <dependency>
312.165 + <code-name-base>org.netbeans.modules.java.preprocessorbridge</code-name-base>
312.166 + <build-prerequisite/>
312.167 + <compile-dependency/>
312.168 + <run-dependency>
312.169 + <implementation-version/>
312.170 + </run-dependency>
312.171 + </dependency>
312.172 + <dependency>
312.173 + <code-name-base>org.netbeans.modules.java.source</code-name-base>
312.174 + <build-prerequisite/>
312.175 + <compile-dependency/>
312.176 + <run-dependency>
312.177 + <implementation-version/>
312.178 + </run-dependency>
312.179 + </dependency>
312.180 + <dependency>
312.181 + <code-name-base>org.netbeans.modules.lexer</code-name-base>
312.182 + <build-prerequisite/>
312.183 + <compile-dependency/>
312.184 + <run-dependency>
312.185 + <release-version>2</release-version>
312.186 + <specification-version>1.34</specification-version>
312.187 + </run-dependency>
312.188 + </dependency>
312.189 + <dependency>
312.190 + <code-name-base>org.netbeans.modules.options.api</code-name-base>
312.191 + <build-prerequisite/>
312.192 + <compile-dependency/>
312.193 + <run-dependency>
312.194 + <release-version>1</release-version>
312.195 + <specification-version>1.20</specification-version>
312.196 + </run-dependency>
312.197 + </dependency>
312.198 + <dependency>
312.199 + <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
312.200 + <build-prerequisite/>
312.201 + <compile-dependency/>
312.202 + <run-dependency>
312.203 + <release-version>1</release-version>
312.204 + <implementation-version/>
312.205 + </run-dependency>
312.206 + </dependency>
312.207 + <dependency>
312.208 + <code-name-base>org.netbeans.modules.projectapi</code-name-base>
312.209 + <build-prerequisite/>
312.210 + <compile-dependency/>
312.211 + <run-dependency>
312.212 + <release-version>1</release-version>
312.213 + <specification-version>1.24</specification-version>
312.214 + </run-dependency>
312.215 + </dependency>
312.216 + <dependency>
312.217 + <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
312.218 + <build-prerequisite/>
312.219 + <compile-dependency/>
312.220 + <run-dependency>
312.221 + <release-version>1</release-version>
312.222 + <specification-version>1.35.0.6</specification-version>
312.223 + </run-dependency>
312.224 + </dependency>
312.225 + <dependency>
312.226 + <code-name-base>org.netbeans.modules.queries</code-name-base>
312.227 + <build-prerequisite/>
312.228 + <compile-dependency/>
312.229 + <run-dependency>
312.230 + <release-version>1</release-version>
312.231 + <specification-version>1.15</specification-version>
312.232 + </run-dependency>
312.233 + </dependency>
312.234 + <dependency>
312.235 + <code-name-base>org.netbeans.modules.refactoring.api</code-name-base>
312.236 + <build-prerequisite/>
312.237 + <compile-dependency/>
312.238 + <run-dependency>
312.239 + <specification-version>1.6</specification-version>
312.240 + </run-dependency>
312.241 + </dependency>
312.242 + <dependency>
312.243 + <code-name-base>org.netbeans.modules.refactoring.java</code-name-base>
312.244 + <build-prerequisite/>
312.245 + <compile-dependency/>
312.246 + <run-dependency>
312.247 + <release-version>1</release-version>
312.248 + <specification-version>1.6</specification-version>
312.249 + </run-dependency>
312.250 + </dependency>
312.251 + <dependency>
312.252 + <code-name-base>org.netbeans.modules.sendopts</code-name-base>
312.253 + <build-prerequisite/>
312.254 + <compile-dependency/>
312.255 + <run-dependency>
312.256 + <release-version>2</release-version>
312.257 + <specification-version>2.4</specification-version>
312.258 + </run-dependency>
312.259 + </dependency>
312.260 + <dependency>
312.261 + <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
312.262 + <build-prerequisite/>
312.263 + <compile-dependency/>
312.264 + <run-dependency>
312.265 + <release-version>0-1</release-version>
312.266 + <specification-version>1.7.0.7.2</specification-version>
312.267 + </run-dependency>
312.268 + </dependency>
312.269 + <dependency>
312.270 + <code-name-base>org.openide.awt</code-name-base>
312.271 + <build-prerequisite/>
312.272 + <compile-dependency/>
312.273 + <run-dependency>
312.274 + <specification-version>7.7.0.1</specification-version>
312.275 + </run-dependency>
312.276 + </dependency>
312.277 + <dependency>
312.278 + <code-name-base>org.openide.dialogs</code-name-base>
312.279 + <build-prerequisite/>
312.280 + <compile-dependency/>
312.281 + <run-dependency>
312.282 + <specification-version>7.10</specification-version>
312.283 + </run-dependency>
312.284 + </dependency>
312.285 + <dependency>
312.286 + <code-name-base>org.openide.filesystems</code-name-base>
312.287 + <build-prerequisite/>
312.288 + <compile-dependency/>
312.289 + <run-dependency>
312.290 + <specification-version>7.21.0.1.1</specification-version>
312.291 + </run-dependency>
312.292 + </dependency>
312.293 + <dependency>
312.294 + <code-name-base>org.openide.loaders</code-name-base>
312.295 + <build-prerequisite/>
312.296 + <compile-dependency/>
312.297 + <run-dependency>
312.298 + <specification-version>7.5</specification-version>
312.299 + </run-dependency>
312.300 + </dependency>
312.301 + <dependency>
312.302 + <code-name-base>org.openide.modules</code-name-base>
312.303 + <build-prerequisite/>
312.304 + <compile-dependency/>
312.305 + <run-dependency>
312.306 + <specification-version>7.10</specification-version>
312.307 + </run-dependency>
312.308 + </dependency>
312.309 + <dependency>
312.310 + <code-name-base>org.openide.nodes</code-name-base>
312.311 + <build-prerequisite/>
312.312 + <compile-dependency/>
312.313 + <run-dependency>
312.314 + <specification-version>7.9.0.1</specification-version>
312.315 + </run-dependency>
312.316 + </dependency>
312.317 + <dependency>
312.318 + <code-name-base>org.openide.text</code-name-base>
312.319 + <build-prerequisite/>
312.320 + <compile-dependency/>
312.321 + <run-dependency>
312.322 + <specification-version>6.22</specification-version>
312.323 + </run-dependency>
312.324 + </dependency>
312.325 + <dependency>
312.326 + <code-name-base>org.openide.util</code-name-base>
312.327 + <build-prerequisite/>
312.328 + <compile-dependency/>
312.329 + <run-dependency>
312.330 + <specification-version>8.0</specification-version>
312.331 + </run-dependency>
312.332 + </dependency>
312.333 + <dependency>
312.334 + <code-name-base>org.openide.util.lookup</code-name-base>
312.335 + <build-prerequisite/>
312.336 + <compile-dependency/>
312.337 + <run-dependency>
312.338 + <specification-version>8.0.0.1</specification-version>
312.339 + </run-dependency>
312.340 + </dependency>
312.341 + <dependency>
312.342 + <code-name-base>org.openide.windows</code-name-base>
312.343 + <build-prerequisite/>
312.344 + <compile-dependency/>
312.345 + <run-dependency>
312.346 + <specification-version>6.27</specification-version>
312.347 + </run-dependency>
312.348 + </dependency>
312.349 + </module-dependencies>
312.350 + <public-packages>
312.351 + <package>org.netbeans.modules.jackpot30.common.api</package>
312.352 + </public-packages>
312.353 + </data>
312.354 + </configuration>
312.355 +</project>
313.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
313.2 +++ b/remoting/common/api/nbproject/suite.properties Mon Mar 12 21:10:10 2012 +0100
313.3 @@ -0,0 +1,1 @@
313.4 +suite.dir=${basedir}/..
314.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
314.2 +++ b/remoting/common/api/src/org/netbeans/modules/jackpot30/common/Bundle.properties Mon Mar 12 21:10:10 2012 +0100
314.3 @@ -0,0 +1,1 @@
314.4 +OpenIDE-Module-Name=Jackpot 3.0 Common APIs
315.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
315.2 +++ b/remoting/common/api/src/org/netbeans/modules/jackpot30/common/api/IndexAccess.java Mon Mar 12 21:10:10 2012 +0100
315.3 @@ -0,0 +1,117 @@
315.4 +/*
315.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
315.6 + *
315.7 + * Copyright 2012 Sun Microsystems, Inc. All rights reserved.
315.8 + *
315.9 + * The contents of this file are subject to the terms of either the GNU
315.10 + * General Public License Version 2 only ("GPL") or the Common
315.11 + * Development and Distribution License("CDDL") (collectively, the
315.12 + * "License"). You may not use this file except in compliance with the
315.13 + * License. You can obtain a copy of the License at
315.14 + * http://www.netbeans.org/cddl-gplv2.html
315.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
315.16 + * specific language governing permissions and limitations under the
315.17 + * License. When distributing the software, include this License Header
315.18 + * Notice in each file and include the License file at
315.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
315.20 + * particular file as subject to the "Classpath" exception as provided
315.21 + * by Sun in the GPL Version 2 section of the License file that
315.22 + * accompanied this code. If applicable, add the following below the
315.23 + * License Header, with the fields enclosed by brackets [] replaced by
315.24 + * your own identifying information:
315.25 + * "Portions Copyrighted [year] [name of copyright owner]"
315.26 + *
315.27 + * If you wish your version of this file to be governed by only the CDDL
315.28 + * or only the GPL Version 2, indicate your decision by adding
315.29 + * "[Contributor] elects to include this software in this distribution
315.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
315.31 + * single choice of license, a recipient has the option to distribute
315.32 + * your version of this file under either the CDDL, the GPL Version 2 or
315.33 + * to extend the choice of license to its licensees as provided above.
315.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
315.35 + * Version 2 license, then the option applies only if the new code is
315.36 + * made subject to such option by the copyright holder.
315.37 + *
315.38 + * Contributor(s):
315.39 + *
315.40 + * Portions Copyrighted 2012 Sun Microsystems, Inc.
315.41 + */
315.42 +
315.43 +package org.netbeans.modules.jackpot30.common.api;
315.44 +
315.45 +import java.io.File;
315.46 +import java.io.IOException;
315.47 +import java.io.Reader;
315.48 +import java.net.URISyntaxException;
315.49 +import java.net.URL;
315.50 +import org.apache.lucene.analysis.Analyzer;
315.51 +import org.apache.lucene.analysis.TokenStream;
315.52 +import org.apache.lucene.index.CorruptIndexException;
315.53 +import org.apache.lucene.index.IndexWriter;
315.54 +import org.apache.lucene.store.FSDirectory;
315.55 +import org.apache.lucene.store.LockObtainFailedException;
315.56 +import org.netbeans.api.annotations.common.NonNull;
315.57 +import org.netbeans.modules.parsing.spi.indexing.Indexable;
315.58 +import org.openide.filesystems.FileObject;
315.59 +import org.openide.filesystems.FileUtil;
315.60 +import org.openide.util.lookup.ServiceProvider;
315.61 +
315.62 +/**
315.63 + *
315.64 + * @author lahvac
315.65 + */
315.66 +@ServiceProvider(service=IndexAccess.class)
315.67 +public class IndexAccess {
315.68 +
315.69 + private URL root;
315.70 + private IndexWriter w;
315.71 +
315.72 + public @NonNull IndexWriter getIndexWriter(@NonNull URL root, @NonNull FileObject cacheRoot, @NonNull String subindexName) {
315.73 + if (w == null) {
315.74 + this.root = root;
315.75 + File cacheRootFile = FileUtil.toFile(cacheRoot);
315.76 + try {
315.77 + w = new IndexWriter(FSDirectory.open(new File(cacheRootFile, subindexName)), new NoAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
315.78 + } catch (CorruptIndexException ex) {
315.79 + throw new IllegalStateException(ex);
315.80 + } catch (LockObtainFailedException ex) {
315.81 + throw new IllegalStateException(ex);
315.82 + } catch (IOException ex) {
315.83 + throw new IllegalStateException(ex);
315.84 + }
315.85 + }
315.86 +
315.87 + return w;
315.88 + }
315.89 +
315.90 + public void finish() {
315.91 + this.root = null;
315.92 + if (w != null) {
315.93 + try {
315.94 + w.close();
315.95 + } catch (CorruptIndexException ex) {
315.96 + throw new IllegalStateException(ex);
315.97 + } catch (IOException ex) {
315.98 + throw new IllegalStateException(ex);
315.99 + }
315.100 + w = null;
315.101 + }
315.102 + }
315.103 +
315.104 + public String getRelativePath(Indexable i) {
315.105 + try {
315.106 + return root.toURI().relativize(i.getURL().toURI()).toString();
315.107 + } catch (URISyntaxException ex) {
315.108 + throw new IllegalStateException(ex);
315.109 + }
315.110 + }
315.111 +
315.112 + public static final class NoAnalyzer extends Analyzer {
315.113 +
315.114 + @Override
315.115 + public TokenStream tokenStream(String string, Reader reader) {
315.116 + throw new UnsupportedOperationException("Should not be called");
315.117 + }
315.118 +
315.119 + }
315.120 +}
316.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
316.2 +++ b/remoting/common/api/src/org/netbeans/modules/jackpot30/common/api/JavaUtils.java Mon Mar 12 21:10:10 2012 +0100
316.3 @@ -0,0 +1,76 @@
316.4 +/*
316.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
316.6 + *
316.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
316.8 + *
316.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
316.10 + * Other names may be trademarks of their respective owners.
316.11 + *
316.12 + * The contents of this file are subject to the terms of either the GNU
316.13 + * General Public License Version 2 only ("GPL") or the Common
316.14 + * Development and Distribution License("CDDL") (collectively, the
316.15 + * "License"). You may not use this file except in compliance with the
316.16 + * License. You can obtain a copy of the License at
316.17 + * http://www.netbeans.org/cddl-gplv2.html
316.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
316.19 + * specific language governing permissions and limitations under the
316.20 + * License. When distributing the software, include this License Header
316.21 + * Notice in each file and include the License file at
316.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
316.23 + * particular file as subject to the "Classpath" exception as provided
316.24 + * by Oracle in the GPL Version 2 section of the License file that
316.25 + * accompanied this code. If applicable, add the following below the
316.26 + * License Header, with the fields enclosed by brackets [] replaced by
316.27 + * your own identifying information:
316.28 + * "Portions Copyrighted [year] [name of copyright owner]"
316.29 + *
316.30 + * If you wish your version of this file to be governed by only the CDDL
316.31 + * or only the GPL Version 2, indicate your decision by adding
316.32 + * "[Contributor] elects to include this software in this distribution
316.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
316.34 + * single choice of license, a recipient has the option to distribute
316.35 + * your version of this file under either the CDDL, the GPL Version 2 or
316.36 + * to extend the choice of license to its licensees as provided above.
316.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
316.38 + * Version 2 license, then the option applies only if the new code is
316.39 + * made subject to such option by the copyright holder.
316.40 + *
316.41 + * Contributor(s):
316.42 + *
316.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
316.44 + */
316.45 +package org.netbeans.modules.jackpot30.common.api;
316.46 +
316.47 +import java.util.EnumSet;
316.48 +import java.util.Set;
316.49 +import javax.lang.model.element.ElementKind;
316.50 +import org.netbeans.api.java.source.ElementHandle;
316.51 +import org.netbeans.api.java.source.SourceUtils;
316.52 +
316.53 +/**
316.54 + *
316.55 + * @author lahvac
316.56 + */
316.57 +public class JavaUtils {
316.58 +
316.59 + public static final Set<ElementKind> SUPPORTED_KINDS = EnumSet.of(ElementKind.PACKAGE, ElementKind.CLASS,
316.60 + ElementKind.INTERFACE, ElementKind.ENUM, ElementKind.ANNOTATION_TYPE, ElementKind.METHOD,
316.61 + ElementKind.CONSTRUCTOR, ElementKind.INSTANCE_INIT, ElementKind.STATIC_INIT,
316.62 + ElementKind.FIELD, ElementKind.ENUM_CONSTANT);
316.63 +
316.64 + public static String serialize(ElementHandle<?> h) {
316.65 + StringBuilder result = new StringBuilder();
316.66 +
316.67 + result.append(h.getKind());
316.68 +
316.69 + String[] signatures = SourceUtils.getJVMSignature(h);
316.70 +
316.71 + for (String sig : signatures) {
316.72 + result.append(":");
316.73 + result.append(sig);
316.74 + }
316.75 +
316.76 + return result.toString();
316.77 + }
316.78 +
316.79 +}
317.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
317.2 +++ b/remoting/common/api/src/org/netbeans/modules/jackpot30/common/api/LuceneHelpers.java Mon Mar 12 21:10:10 2012 +0100
317.3 @@ -0,0 +1,84 @@
317.4 +/*
317.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
317.6 + *
317.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
317.8 + *
317.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
317.10 + * Other names may be trademarks of their respective owners.
317.11 + *
317.12 + * The contents of this file are subject to the terms of either the GNU
317.13 + * General Public License Version 2 only ("GPL") or the Common
317.14 + * Development and Distribution License("CDDL") (collectively, the
317.15 + * "License"). You may not use this file except in compliance with the
317.16 + * License. You can obtain a copy of the License at
317.17 + * http://www.netbeans.org/cddl-gplv2.html
317.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
317.19 + * specific language governing permissions and limitations under the
317.20 + * License. When distributing the software, include this License Header
317.21 + * Notice in each file and include the License file at
317.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
317.23 + * particular file as subject to the "Classpath" exception as provided
317.24 + * by Oracle in the GPL Version 2 section of the License file that
317.25 + * accompanied this code. If applicable, add the following below the
317.26 + * License Header, with the fields enclosed by brackets [] replaced by
317.27 + * your own identifying information:
317.28 + * "Portions Copyrighted [year] [name of copyright owner]"
317.29 + *
317.30 + * If you wish your version of this file to be governed by only the CDDL
317.31 + * or only the GPL Version 2, indicate your decision by adding
317.32 + * "[Contributor] elects to include this software in this distribution
317.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
317.34 + * single choice of license, a recipient has the option to distribute
317.35 + * your version of this file under either the CDDL, the GPL Version 2 or
317.36 + * to extend the choice of license to its licensees as provided above.
317.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
317.38 + * Version 2 license, then the option applies only if the new code is
317.39 + * made subject to such option by the copyright holder.
317.40 + *
317.41 + * Contributor(s):
317.42 + *
317.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
317.44 + */
317.45 +package org.netbeans.modules.jackpot30.common.api;
317.46 +
317.47 +import java.util.BitSet;
317.48 +import org.apache.lucene.index.IndexReader;
317.49 +import org.apache.lucene.search.Collector;
317.50 +import org.apache.lucene.search.Scorer;
317.51 +
317.52 +/**
317.53 + *
317.54 + * @author lahvac
317.55 + */
317.56 +public class LuceneHelpers {
317.57 +
317.58 + public static class BitSetCollector extends Collector {
317.59 +
317.60 + private int docBase;
317.61 + public final BitSet bits;
317.62 +
317.63 + public BitSetCollector(final BitSet bitSet) {
317.64 + assert bitSet != null;
317.65 + bits = bitSet;
317.66 + }
317.67 +
317.68 + // ignore scorer
317.69 + public void setScorer(Scorer scorer) {
317.70 + }
317.71 +
317.72 + // accept docs out of order (for a BitSet it doesn't matter)
317.73 + public boolean acceptsDocsOutOfOrder() {
317.74 + return true;
317.75 + }
317.76 +
317.77 + public void collect(int doc) {
317.78 + bits.set(doc + docBase);
317.79 + }
317.80 +
317.81 + public void setNextReader(IndexReader reader, int docBase) {
317.82 + this.docBase = docBase;
317.83 + }
317.84 +
317.85 + }
317.86 +
317.87 +}
318.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
318.2 +++ b/remoting/common/borrowedtests/build.xml Mon Mar 12 21:10:10 2012 +0100
318.3 @@ -0,0 +1,13 @@
318.4 +<?xml version="1.0" encoding="UTF-8"?>
318.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
318.6 +<!-- for some information on what you could do (e.g. targets to override). -->
318.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
318.8 +<project name="org.netbeans.modules.jackpot30.test.borrowed" default="netbeans" basedir=".">
318.9 + <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.test.borrowed.</description>
318.10 + <import file="nbproject/build-impl.xml"/>
318.11 +<!-- <import file="../findbugs-import.xml"/>-->
318.12 +
318.13 +<!-- <target name="test" />
318.14 + <target name="test-coverage" />
318.15 + <target name="coverage-report" />-->
318.16 +</project>
319.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
319.2 +++ b/remoting/common/borrowedtests/manifest.mf Mon Mar 12 21:10:10 2012 +0100
319.3 @@ -0,0 +1,6 @@
319.4 +Manifest-Version: 1.0
319.5 +AutoUpdate-Show-In-Client: false
319.6 +OpenIDE-Module: org.netbeans.modules.jackpot30.test.borrowed
319.7 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/test/borrowed/Bundle.properties
319.8 +OpenIDE-Module-Specification-Version: 1.16
319.9 +
320.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
320.2 +++ b/remoting/common/borrowedtests/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
320.3 @@ -0,0 +1,45 @@
320.4 +<?xml version="1.0" encoding="UTF-8"?>
320.5 +<!--
320.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
320.7 +*** EDIT ../build.xml INSTEAD ***
320.8 +-->
320.9 +<project name="org.netbeans.modules.jackpot30.test.borrowed-impl" basedir="..">
320.10 + <fail message="Please build using Ant 1.7.1 or higher.">
320.11 + <condition>
320.12 + <not>
320.13 + <antversion atleast="1.7.1"/>
320.14 + </not>
320.15 + </condition>
320.16 + </fail>
320.17 + <property file="nbproject/private/suite-private.properties"/>
320.18 + <property file="nbproject/suite.properties"/>
320.19 + <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
320.20 + <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
320.21 + <property file="${suite.dir}/nbproject/platform.properties"/>
320.22 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
320.23 + <attribute name="name"/>
320.24 + <attribute name="value"/>
320.25 + <sequential>
320.26 + <property name="@{name}" value="${@{value}}"/>
320.27 + </sequential>
320.28 + </macrodef>
320.29 + <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
320.30 + <attribute name="property"/>
320.31 + <attribute name="value"/>
320.32 + <sequential>
320.33 + <property name="@{property}" value="@{value}"/>
320.34 + </sequential>
320.35 + </macrodef>
320.36 + <property file="${user.properties.file}"/>
320.37 + <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
320.38 + <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
320.39 + <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
320.40 + <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
320.41 + <condition>
320.42 + <not>
320.43 + <contains string="${cluster.path.evaluated}" substring="platform"/>
320.44 + </not>
320.45 + </condition>
320.46 + </fail>
320.47 + <import file="${harness.dir}/build.xml"/>
320.48 +</project>
321.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
321.2 +++ b/remoting/common/borrowedtests/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
321.3 @@ -0,0 +1,8 @@
321.4 +build.xml.data.CRC32=a4393221
321.5 +build.xml.script.CRC32=3cb17d2d
321.6 +build.xml.stylesheet.CRC32=79c3b980@1.28.0.7
321.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
321.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
321.9 +nbproject/build-impl.xml.data.CRC32=ca7a8f66
321.10 +nbproject/build-impl.xml.script.CRC32=cb5fccc2
321.11 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.49
322.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
322.2 +++ b/remoting/common/borrowedtests/nbproject/platform.properties Mon Mar 12 21:10:10 2012 +0100
322.3 @@ -0,0 +1,21 @@
322.4 +cluster.path=\
322.5 + ${nbplatform.active.dir}/identity:\
322.6 + ${nbplatform.active.dir}/enterprise:\
322.7 + ${nbplatform.active.dir}/webcommon:\
322.8 + ${nbplatform.active.dir}/mobility:\
322.9 + ${nbplatform.active.dir}/php:\
322.10 + ${nbplatform.active.dir}/harness:\
322.11 + ${nbplatform.active.dir}/dlight:\
322.12 + ${nbplatform.active.dir}/profiler:\
322.13 + ${nbplatform.active.dir}/platform:\
322.14 + ${nbplatform.active.dir}/websvccommon:\
322.15 + ${nbplatform.active.dir}/nb:\
322.16 + ${nbplatform.active.dir}/apisupport:\
322.17 + ${nbplatform.active.dir}/cnd:\
322.18 + ${nbplatform.active.dir}/ergonomics:\
322.19 + ${nbplatform.active.dir}/java:\
322.20 + ${nbplatform.active.dir}/groovy:\
322.21 + ${nbplatform.active.dir}/ruby:\
322.22 + ${nbplatform.active.dir}/extra:\
322.23 + ${nbplatform.active.dir}/ide
322.24 +nbplatform.active=default
323.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
323.2 +++ b/remoting/common/borrowedtests/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
323.3 @@ -0,0 +1,3 @@
323.4 +is.autoload=true
323.5 +javac.source=1.5
323.6 +javac.compilerargs=-Xlint -Xlint:-serial
324.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
324.2 +++ b/remoting/common/borrowedtests/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
324.3 @@ -0,0 +1,336 @@
324.4 +<?xml version="1.0" encoding="UTF-8"?>
324.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
324.6 + <type>org.netbeans.modules.apisupport.project</type>
324.7 + <configuration>
324.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
324.9 + <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
324.10 + <suite-component/>
324.11 + <module-dependencies>
324.12 + <dependency>
324.13 + <code-name-base>org.netbeans.api.annotations.common</code-name-base>
324.14 + <build-prerequisite/>
324.15 + <compile-dependency/>
324.16 + <run-dependency>
324.17 + <release-version>1</release-version>
324.18 + <specification-version>1.13</specification-version>
324.19 + </run-dependency>
324.20 + </dependency>
324.21 + <dependency>
324.22 + <code-name-base>org.netbeans.api.java</code-name-base>
324.23 + <build-prerequisite/>
324.24 + <compile-dependency/>
324.25 + <run-dependency>
324.26 + <release-version>1</release-version>
324.27 + <specification-version>1.31</specification-version>
324.28 + </run-dependency>
324.29 + </dependency>
324.30 + <dependency>
324.31 + <code-name-base>org.netbeans.api.java.classpath</code-name-base>
324.32 + <build-prerequisite/>
324.33 + <compile-dependency/>
324.34 + <run-dependency>
324.35 + <release-version>1</release-version>
324.36 + <specification-version>1.27</specification-version>
324.37 + </run-dependency>
324.38 + </dependency>
324.39 + <dependency>
324.40 + <code-name-base>org.netbeans.api.progress</code-name-base>
324.41 + <build-prerequisite/>
324.42 + <compile-dependency/>
324.43 + <run-dependency>
324.44 + <release-version>1</release-version>
324.45 + <specification-version>1.22</specification-version>
324.46 + </run-dependency>
324.47 + </dependency>
324.48 + <dependency>
324.49 + <code-name-base>org.netbeans.insane</code-name-base>
324.50 + <build-prerequisite/>
324.51 + <compile-dependency/>
324.52 + <run-dependency>
324.53 + <release-version>1</release-version>
324.54 + <implementation-version/>
324.55 + </run-dependency>
324.56 + </dependency>
324.57 + <dependency>
324.58 + <code-name-base>org.netbeans.libs.javacapi</code-name-base>
324.59 + <build-prerequisite/>
324.60 + <compile-dependency/>
324.61 + <run-dependency>
324.62 + <specification-version>7.1.0.2</specification-version>
324.63 + </run-dependency>
324.64 + </dependency>
324.65 + <dependency>
324.66 + <code-name-base>org.netbeans.libs.javacimpl</code-name-base>
324.67 + <build-prerequisite/>
324.68 + <compile-dependency/>
324.69 + <run-dependency>
324.70 + <release-version>1</release-version>
324.71 + <implementation-version/>
324.72 + </run-dependency>
324.73 + </dependency>
324.74 + <dependency>
324.75 + <code-name-base>org.netbeans.libs.junit4</code-name-base>
324.76 + <build-prerequisite/>
324.77 + <compile-dependency/>
324.78 + <run-dependency>
324.79 + <specification-version>1.12</specification-version>
324.80 + </run-dependency>
324.81 + </dependency>
324.82 + <dependency>
324.83 + <code-name-base>org.netbeans.libs.lucene</code-name-base>
324.84 + <build-prerequisite/>
324.85 + <compile-dependency/>
324.86 + <run-dependency>
324.87 + <release-version>1-3</release-version>
324.88 + <specification-version>2.13</specification-version>
324.89 + </run-dependency>
324.90 + </dependency>
324.91 + <dependency>
324.92 + <code-name-base>org.netbeans.modules.editor.lib2</code-name-base>
324.93 + <build-prerequisite/>
324.94 + <compile-dependency/>
324.95 + <run-dependency>
324.96 + <release-version>1</release-version>
324.97 + <specification-version>1.35.0.5</specification-version>
324.98 + </run-dependency>
324.99 + </dependency>
324.100 + <dependency>
324.101 + <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
324.102 + <build-prerequisite/>
324.103 + <compile-dependency/>
324.104 + <run-dependency>
324.105 + <release-version>1</release-version>
324.106 + <specification-version>1.20</specification-version>
324.107 + </run-dependency>
324.108 + </dependency>
324.109 + <dependency>
324.110 + <code-name-base>org.netbeans.modules.editor.util</code-name-base>
324.111 + <build-prerequisite/>
324.112 + <compile-dependency/>
324.113 + <run-dependency>
324.114 + <release-version>1</release-version>
324.115 + <specification-version>1.39</specification-version>
324.116 + </run-dependency>
324.117 + </dependency>
324.118 + <dependency>
324.119 + <code-name-base>org.netbeans.modules.java.hints</code-name-base>
324.120 + <build-prerequisite/>
324.121 + <compile-dependency/>
324.122 + <run-dependency>
324.123 + <release-version>1</release-version>
324.124 + <implementation-version/>
324.125 + </run-dependency>
324.126 + </dependency>
324.127 + <dependency>
324.128 + <code-name-base>org.netbeans.modules.java.lexer</code-name-base>
324.129 + <build-prerequisite/>
324.130 + <compile-dependency/>
324.131 + <run-dependency>
324.132 + <release-version>1</release-version>
324.133 + <specification-version>1.12</specification-version>
324.134 + </run-dependency>
324.135 + </dependency>
324.136 + <dependency>
324.137 + <code-name-base>org.netbeans.modules.java.source</code-name-base>
324.138 + <build-prerequisite/>
324.139 + <compile-dependency/>
324.140 + <run-dependency>
324.141 + <implementation-version/>
324.142 + </run-dependency>
324.143 + </dependency>
324.144 + <dependency>
324.145 + <code-name-base>org.netbeans.modules.lexer</code-name-base>
324.146 + <build-prerequisite/>
324.147 + <compile-dependency/>
324.148 + <run-dependency>
324.149 + <release-version>2</release-version>
324.150 + <specification-version>1.37.0.1</specification-version>
324.151 + </run-dependency>
324.152 + </dependency>
324.153 + <dependency>
324.154 + <code-name-base>org.netbeans.modules.masterfs</code-name-base>
324.155 + <build-prerequisite/>
324.156 + <compile-dependency/>
324.157 + <run-dependency>
324.158 + <release-version>2</release-version>
324.159 + <implementation-version/>
324.160 + </run-dependency>
324.161 + </dependency>
324.162 + <dependency>
324.163 + <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
324.164 + <build-prerequisite/>
324.165 + <compile-dependency/>
324.166 + <run-dependency>
324.167 + <release-version>1</release-version>
324.168 + <specification-version>1.65</specification-version>
324.169 + </run-dependency>
324.170 + </dependency>
324.171 + <dependency>
324.172 + <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
324.173 + <build-prerequisite/>
324.174 + <compile-dependency/>
324.175 + <run-dependency>
324.176 + <release-version>1</release-version>
324.177 + <implementation-version/>
324.178 + </run-dependency>
324.179 + </dependency>
324.180 + <dependency>
324.181 + <code-name-base>org.netbeans.modules.projectapi</code-name-base>
324.182 + <build-prerequisite/>
324.183 + <compile-dependency/>
324.184 + <run-dependency>
324.185 + <release-version>1</release-version>
324.186 + <specification-version>1.34</specification-version>
324.187 + </run-dependency>
324.188 + </dependency>
324.189 + <dependency>
324.190 + <code-name-base>org.netbeans.modules.projectui</code-name-base>
324.191 + <build-prerequisite/>
324.192 + <compile-dependency/>
324.193 + <run-dependency>
324.194 + <implementation-version/>
324.195 + </run-dependency>
324.196 + </dependency>
324.197 + <dependency>
324.198 + <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
324.199 + <build-prerequisite/>
324.200 + <compile-dependency/>
324.201 + <run-dependency>
324.202 + <release-version>1</release-version>
324.203 + <specification-version>1.49.0.8</specification-version>
324.204 + </run-dependency>
324.205 + </dependency>
324.206 + <dependency>
324.207 + <code-name-base>org.netbeans.modules.queries</code-name-base>
324.208 + <build-prerequisite/>
324.209 + <compile-dependency/>
324.210 + <run-dependency>
324.211 + <release-version>1</release-version>
324.212 + <specification-version>1.21</specification-version>
324.213 + </run-dependency>
324.214 + </dependency>
324.215 + <dependency>
324.216 + <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
324.217 + <build-prerequisite/>
324.218 + <compile-dependency/>
324.219 + <run-dependency>
324.220 + <release-version>0-1</release-version>
324.221 + <specification-version>1.16.0.7.5</specification-version>
324.222 + </run-dependency>
324.223 + </dependency>
324.224 + <dependency>
324.225 + <code-name-base>org.netbeans.spi.java.hints</code-name-base>
324.226 + <build-prerequisite/>
324.227 + <compile-dependency/>
324.228 + <run-dependency>
324.229 + <implementation-version/>
324.230 + </run-dependency>
324.231 + </dependency>
324.232 + <dependency>
324.233 + <code-name-base>org.openide.actions</code-name-base>
324.234 + <build-prerequisite/>
324.235 + <compile-dependency/>
324.236 + <run-dependency>
324.237 + <specification-version>6.19</specification-version>
324.238 + </run-dependency>
324.239 + </dependency>
324.240 + <dependency>
324.241 + <code-name-base>org.openide.awt</code-name-base>
324.242 + <build-prerequisite/>
324.243 + <compile-dependency/>
324.244 + <run-dependency>
324.245 + <specification-version>7.29</specification-version>
324.246 + </run-dependency>
324.247 + </dependency>
324.248 + <dependency>
324.249 + <code-name-base>org.openide.dialogs</code-name-base>
324.250 + <build-prerequisite/>
324.251 + <compile-dependency/>
324.252 + <run-dependency>
324.253 + <specification-version>7.17</specification-version>
324.254 + </run-dependency>
324.255 + </dependency>
324.256 + <dependency>
324.257 + <code-name-base>org.openide.filesystems</code-name-base>
324.258 + <build-prerequisite/>
324.259 + <compile-dependency/>
324.260 + <run-dependency>
324.261 + <specification-version>7.43</specification-version>
324.262 + </run-dependency>
324.263 + </dependency>
324.264 + <dependency>
324.265 + <code-name-base>org.openide.loaders</code-name-base>
324.266 + <build-prerequisite/>
324.267 + <compile-dependency/>
324.268 + <run-dependency>
324.269 + <specification-version>7.19</specification-version>
324.270 + </run-dependency>
324.271 + </dependency>
324.272 + <dependency>
324.273 + <code-name-base>org.openide.nodes</code-name-base>
324.274 + <build-prerequisite/>
324.275 + <compile-dependency/>
324.276 + <run-dependency>
324.277 + <specification-version>7.19</specification-version>
324.278 + </run-dependency>
324.279 + </dependency>
324.280 + <dependency>
324.281 + <code-name-base>org.openide.text</code-name-base>
324.282 + <build-prerequisite/>
324.283 + <compile-dependency/>
324.284 + <run-dependency>
324.285 + <specification-version>6.34</specification-version>
324.286 + </run-dependency>
324.287 + </dependency>
324.288 + <dependency>
324.289 + <code-name-base>org.openide.util</code-name-base>
324.290 + <build-prerequisite/>
324.291 + <compile-dependency/>
324.292 + <run-dependency>
324.293 + <specification-version>8.9</specification-version>
324.294 + </run-dependency>
324.295 + </dependency>
324.296 + <dependency>
324.297 + <code-name-base>org.openide.util.lookup</code-name-base>
324.298 + <build-prerequisite/>
324.299 + <compile-dependency/>
324.300 + <run-dependency>
324.301 + <specification-version>8.5</specification-version>
324.302 + </run-dependency>
324.303 + </dependency>
324.304 + <dependency>
324.305 + <code-name-base>org.openide.windows</code-name-base>
324.306 + <build-prerequisite/>
324.307 + <compile-dependency/>
324.308 + <run-dependency>
324.309 + <specification-version>6.37</specification-version>
324.310 + </run-dependency>
324.311 + </dependency>
324.312 + <dependency>
324.313 + <code-name-base>org.openidex.util</code-name-base>
324.314 + <build-prerequisite/>
324.315 + <compile-dependency/>
324.316 + <run-dependency>
324.317 + <release-version>3</release-version>
324.318 + <specification-version>3.27</specification-version>
324.319 + </run-dependency>
324.320 + </dependency>
324.321 + </module-dependencies>
324.322 + <test-dependencies>
324.323 + <test-type>
324.324 + <name>unit</name>
324.325 + <test-dependency>
324.326 + <code-name-base>org.netbeans.libs.junit4</code-name-base>
324.327 + <compile-dependency/>
324.328 + </test-dependency>
324.329 + <test-dependency>
324.330 + <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
324.331 + <recursive/>
324.332 + <compile-dependency/>
324.333 + </test-dependency>
324.334 + </test-type>
324.335 + </test-dependencies>
324.336 + <public-packages/>
324.337 + </data>
324.338 + </configuration>
324.339 +</project>
325.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
325.2 +++ b/remoting/common/borrowedtests/nbproject/suite.properties Mon Mar 12 21:10:10 2012 +0100
325.3 @@ -0,0 +1,1 @@
325.4 +suite.dir=${basedir}/..
326.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
326.2 +++ b/remoting/common/borrowedtests/src/org/netbeans/api/java/source/SourceUtilsTestUtil.java Mon Mar 12 21:10:10 2012 +0100
326.3 @@ -0,0 +1,441 @@
326.4 +/*
326.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
326.6 + *
326.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
326.8 + *
326.9 + * The contents of this file are subject to the terms of either the GNU
326.10 + * General Public License Version 2 only ("GPL") or the Common
326.11 + * Development and Distribution License("CDDL") (collectively, the
326.12 + * "License"). You may not use this file except in compliance with the
326.13 + * License. You can obtain a copy of the License at
326.14 + * http://www.netbeans.org/cddl-gplv2.html
326.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
326.16 + * specific language governing permissions and limitations under the
326.17 + * License. When distributing the software, include this License Header
326.18 + * Notice in each file and include the License file at
326.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
326.20 + * particular file as subject to the "Classpath" exception as provided
326.21 + * by Sun in the GPL Version 2 section of the License file that
326.22 + * accompanied this code. If applicable, add the following below the
326.23 + * License Header, with the fields enclosed by brackets [] replaced by
326.24 + * your own identifying information:
326.25 + * "Portions Copyrighted [year] [name of copyright owner]"
326.26 + *
326.27 + * Contributor(s):
326.28 + *
326.29 + * The Original Software is NetBeans. The Initial Developer of the Original
326.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
326.31 + * Microsystems, Inc. All Rights Reserved.
326.32 + *
326.33 + * If you wish your version of this file to be governed by only the CDDL
326.34 + * or only the GPL Version 2, indicate your decision by adding
326.35 + * "[Contributor] elects to include this software in this distribution
326.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
326.37 + * single choice of license, a recipient has the option to distribute
326.38 + * your version of this file under either the CDDL, the GPL Version 2 or
326.39 + * to extend the choice of license to its licensees as provided above.
326.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
326.41 + * Version 2 license, then the option applies only if the new code is
326.42 + * made subject to such option by the copyright holder.
326.43 + */
326.44 +package org.netbeans.api.java.source;
326.45 +
326.46 +import com.sun.source.util.JavacTask;
326.47 +import java.beans.PropertyVetoException;
326.48 +import java.io.File;
326.49 +import java.io.IOException;
326.50 +import java.net.URL;
326.51 +import java.util.ArrayList;
326.52 +import java.util.Enumeration;
326.53 +import java.util.HashSet;
326.54 +import java.util.LinkedList;
326.55 +import java.util.List;
326.56 +import java.util.Map;
326.57 +import java.util.Set;
326.58 +import java.util.WeakHashMap;
326.59 +import java.util.logging.Logger;
326.60 +import java.util.logging.Level;
326.61 +import java.util.regex.Pattern;
326.62 +import javax.swing.event.ChangeListener;
326.63 +import junit.framework.Assert;
326.64 +import org.netbeans.api.editor.mimelookup.MimePath;
326.65 +import org.netbeans.api.java.classpath.ClassPath;
326.66 +import org.netbeans.api.java.queries.SourceForBinaryQuery;
326.67 +import org.netbeans.api.java.source.JavaSource.Phase;
326.68 +import org.netbeans.junit.NbTestCase;
326.69 +import org.netbeans.modules.java.JavaDataLoader;
326.70 +import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
326.71 +import org.netbeans.modules.java.source.parsing.JavacParser;
326.72 +import org.netbeans.modules.java.source.parsing.JavacParserFactory;
326.73 +import org.netbeans.modules.java.source.usages.IndexUtil;
326.74 +import org.netbeans.modules.parsing.api.indexing.IndexingManager;
326.75 +import org.netbeans.modules.parsing.impl.indexing.MimeTypes;
326.76 +import org.netbeans.spi.editor.mimelookup.MimeDataProvider;
326.77 +import org.netbeans.spi.java.classpath.ClassPathProvider;
326.78 +import org.netbeans.spi.java.classpath.support.ClassPathSupport;
326.79 +import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
326.80 +import org.netbeans.spi.java.queries.SourceLevelQueryImplementation;
326.81 +import org.openide.filesystems.FileObject;
326.82 +import org.openide.filesystems.FileStateInvalidException;
326.83 +import org.openide.filesystems.FileSystem;
326.84 +import org.openide.filesystems.FileUtil;
326.85 +import org.openide.filesystems.LocalFileSystem;
326.86 +import org.openide.filesystems.MIMEResolver;
326.87 +import org.openide.filesystems.MultiFileSystem;
326.88 +import org.openide.filesystems.Repository;
326.89 +import org.openide.filesystems.URLMapper;
326.90 +import org.openide.filesystems.XMLFileSystem;
326.91 +import org.openide.util.Lookup;
326.92 +import org.openide.util.lookup.Lookups;
326.93 +import org.openide.util.lookup.ProxyLookup;
326.94 +import org.openide.util.lookup.ServiceProvider;
326.95 +import org.xml.sax.SAXException;
326.96 +
326.97 +/**
326.98 + *
326.99 + * @author Jan Lahoda
326.100 + */
326.101 +public final class SourceUtilsTestUtil extends ProxyLookup {
326.102 +
326.103 + private static SourceUtilsTestUtil DEFAULT_LOOKUP = null;
326.104 +
326.105 + public SourceUtilsTestUtil() {
326.106 +// Assert.assertNull(DEFAULT_LOOKUP);
326.107 + DEFAULT_LOOKUP = this;
326.108 + }
326.109 +
326.110 + /**
326.111 + * Set the global default lookup with some fixed instances including META-INF/services/*.
326.112 + */
326.113 + /**
326.114 + * Set the global default lookup with some fixed instances including META-INF/services/*.
326.115 + */
326.116 + public static void setLookup(Object[] instances, ClassLoader cl) {
326.117 + DEFAULT_LOOKUP.setLookups(new Lookup[] {
326.118 + Lookups.fixed(instances),
326.119 + Lookups.metaInfServices(cl),
326.120 + Lookups.singleton(cl),
326.121 + });
326.122 + }
326.123 +
326.124 + private static Object[] extraLookupContent = null;
326.125 +
326.126 + public static void prepareTest(String[] additionalLayers, Object[] additionalLookupContent) throws IOException, SAXException, PropertyVetoException {
326.127 + List<URL> layers = new LinkedList<URL>();
326.128 +
326.129 + for (int cntr = 0; cntr < additionalLayers.length; cntr++) {
326.130 + boolean found = false;
326.131 +
326.132 + for (Enumeration<URL> en = Thread.currentThread().getContextClassLoader().getResources(additionalLayers[cntr]); en.hasMoreElements(); ) {
326.133 + found = true;
326.134 + layers.add(en.nextElement());
326.135 + }
326.136 +
326.137 + Assert.assertTrue(additionalLayers[cntr], found);
326.138 + }
326.139 +
326.140 + XMLFileSystem xmlFS = new XMLFileSystem();
326.141 + xmlFS.setXmlUrls(layers.toArray(new URL[0]));
326.142 +
326.143 + FileSystem system = new MultiFileSystem(new FileSystem[] {FileUtil.createMemoryFileSystem(), xmlFS});
326.144 +
326.145 + Repository repository = new Repository(system);
326.146 + extraLookupContent = new Object[additionalLookupContent.length + 1];
326.147 +
326.148 + System.arraycopy(additionalLookupContent, 0, extraLookupContent, 1, additionalLookupContent.length);
326.149 +
326.150 + extraLookupContent[0] = repository;
326.151 +
326.152 + SourceUtilsTestUtil.setLookup(extraLookupContent, SourceUtilsTestUtil.class.getClassLoader());
326.153 +
326.154 + SourceUtilsTestUtil2.disableLocks();
326.155 +
326.156 + Set<String> mimeTypes = MimeTypes.getAllMimeTypes();
326.157 +
326.158 + if (mimeTypes == null) {
326.159 + mimeTypes = new HashSet<String>();
326.160 + } else {
326.161 + mimeTypes = new HashSet<String>(mimeTypes);
326.162 + }
326.163 +
326.164 + mimeTypes.add("text/x-java");
326.165 +
326.166 + MimeTypes.setAllMimeTypes(mimeTypes);
326.167 + org.netbeans.api.project.ui.OpenProjects.getDefault().getOpenProjects();
326.168 + }
326.169 +
326.170 + static {
326.171 + SourceUtilsTestUtil.class.getClassLoader().setDefaultAssertionStatus(true);
326.172 + System.setProperty("org.openide.util.Lookup", SourceUtilsTestUtil.class.getName());
326.173 + Assert.assertEquals(SourceUtilsTestUtil.class, Lookup.getDefault().getClass());
326.174 + }
326.175 +
326.176 + public static void prepareTest(FileObject sourceRoot, FileObject buildRoot, FileObject cache) throws Exception {
326.177 + prepareTest(sourceRoot, buildRoot, cache, new FileObject[0]);
326.178 + }
326.179 +
326.180 + public static void prepareTest(FileObject sourceRoot, FileObject buildRoot, FileObject cache, FileObject[] classPathElements) throws Exception {
326.181 + if (extraLookupContent == null)
326.182 + prepareTest(new String[0], new Object[0]);
326.183 +
326.184 + Object[] lookupContent = new Object[extraLookupContent.length + 4];
326.185 +
326.186 + System.arraycopy(extraLookupContent, 0, lookupContent, 4, extraLookupContent.length);
326.187 +
326.188 + lookupContent[0] = new TestProxyClassPathProvider(sourceRoot, buildRoot, classPathElements);
326.189 + lookupContent[1] = new TestSourceForBinaryQuery(sourceRoot, buildRoot);
326.190 + lookupContent[2] = new TestSourceLevelQueryImplementation();
326.191 + lookupContent[3] = JavaDataLoader.findObject(JavaDataLoader.class, true);
326.192 +
326.193 + setLookup(lookupContent, SourceUtilsTestUtil.class.getClassLoader());
326.194 +
326.195 + IndexUtil.setCacheFolder(FileUtil.toFile(cache));
326.196 + }
326.197 +
326.198 + private static Map<FileObject, String> file2SourceLevel = new WeakHashMap<FileObject, String>();
326.199 +
326.200 + public static void setSourceLevel(FileObject file, String level) {
326.201 + file2SourceLevel.put(file, level);
326.202 + }
326.203 +
326.204 + /**This method assures that all java classes under sourceRoot are compiled,
326.205 + * and the caches are created for them.
326.206 + */
326.207 + public static void compileRecursively(FileObject sourceRoot) throws Exception {
326.208 + IndexingManager.getDefault().refreshIndexAndWait(sourceRoot.getURL(), null);
326.209 + }
326.210 +
326.211 + private static List<URL> bootClassPath;
326.212 +
326.213 + private static Logger log = Logger.getLogger(SourceUtilsTestUtil.class.getName());
326.214 +
326.215 + public static synchronized List<URL> getBootClassPath() {
326.216 + if (bootClassPath == null) {
326.217 + try {
326.218 + String cp = System.getProperty("sun.boot.class.path");
326.219 + List<URL> urls = new ArrayList<URL>();
326.220 + String[] paths = cp.split(Pattern.quote(System.getProperty("path.separator")));
326.221 +
326.222 + for (String path : paths) {
326.223 + File f = new File(path);
326.224 +
326.225 + if (!f.canRead())
326.226 + continue;
326.227 +
326.228 + FileObject fo = FileUtil.toFileObject(f);
326.229 +
326.230 + if (FileUtil.isArchiveFile(fo)) {
326.231 + fo = FileUtil.getArchiveRoot(fo);
326.232 + }
326.233 +
326.234 + if (fo != null) {
326.235 + urls.add(fo.getURL());
326.236 + }
326.237 + }
326.238 +
326.239 + bootClassPath = urls;
326.240 + } catch (FileStateInvalidException e) {
326.241 + if (log.isLoggable(Level.SEVERE))
326.242 + log.log(Level.SEVERE, e.getMessage(), e);
326.243 + }
326.244 + }
326.245 +
326.246 + return bootClassPath;
326.247 + }
326.248 +
326.249 + private static class TestSourceForBinaryQuery implements SourceForBinaryQueryImplementation {
326.250 +
326.251 + private final FileObject sourceRoot;
326.252 + private final FileObject buildRoot;
326.253 +
326.254 + public TestSourceForBinaryQuery(FileObject sourceRoot, FileObject buildRoot) {
326.255 + this.sourceRoot = sourceRoot;
326.256 + this.buildRoot = buildRoot;
326.257 + }
326.258 +
326.259 + public SourceForBinaryQuery.Result findSourceRoots(URL binaryRoot) {
326.260 + FileObject f = URLMapper.findFileObject(binaryRoot);
326.261 +
326.262 + if (buildRoot.equals(f)) {
326.263 + return new SourceForBinaryQuery.Result() {
326.264 + public FileObject[] getRoots() {
326.265 + return new FileObject[] {
326.266 + sourceRoot,
326.267 + };
326.268 + }
326.269 +
326.270 + public void addChangeListener(ChangeListener l) {
326.271 + }
326.272 +
326.273 + public void removeChangeListener(ChangeListener l) {
326.274 + }
326.275 + };
326.276 + }
326.277 +
326.278 + return null;
326.279 + }
326.280 +
326.281 + }
326.282 +
326.283 + private static class TestProxyClassPathProvider implements ClassPathProvider {
326.284 +
326.285 + private FileObject sourceRoot;
326.286 + private FileObject buildRoot;
326.287 + private FileObject[] classPathElements;
326.288 +
326.289 + public TestProxyClassPathProvider(FileObject sourceRoot, FileObject buildRoot, FileObject[] classPathElements) {
326.290 + this.sourceRoot = sourceRoot;
326.291 + this.buildRoot = buildRoot;
326.292 + this.classPathElements = classPathElements;
326.293 + }
326.294 +
326.295 + public ClassPath findClassPath(FileObject file, String type) {
326.296 + try {
326.297 + if (ClassPath.BOOT == type) {
326.298 + return ClassPathSupport.createClassPath(getBootClassPath().toArray(new URL[0]));
326.299 + }
326.300 +
326.301 + if (ClassPath.SOURCE == type) {
326.302 + return ClassPathSupport.createClassPath(new FileObject[] {
326.303 + sourceRoot
326.304 + });
326.305 + }
326.306 +
326.307 + if (ClassPath.COMPILE == type) {
326.308 + return ClassPathSupport.createClassPath(classPathElements);
326.309 + }
326.310 +
326.311 + if (ClassPath.EXECUTE == type) {
326.312 + return ClassPathSupport.createClassPath(new FileObject[] {
326.313 + buildRoot
326.314 + });
326.315 + }
326.316 + } catch (Exception e) {
326.317 + e.printStackTrace();
326.318 + }
326.319 + return null;
326.320 + }
326.321 +
326.322 + }
326.323 +
326.324 + public static class TestSourceLevelQueryImplementation implements SourceLevelQueryImplementation {
326.325 +
326.326 + public String getSourceLevel(FileObject javaFile) {
326.327 + String level = file2SourceLevel.get(javaFile);
326.328 +
326.329 + if (level == null) {
326.330 + if (javaFile.isFolder()) {
326.331 + for (FileObject data : file2SourceLevel.keySet()) {
326.332 + if (FileUtil.isParentOf(javaFile, data)) {
326.333 + return file2SourceLevel.get(data);
326.334 + }
326.335 + }
326.336 + }
326.337 + return "1.5";
326.338 + } else
326.339 + return level;
326.340 + }
326.341 +
326.342 + }
326.343 +
326.344 + /**Copied from org.netbeans.api.project.
326.345 + * Create a scratch directory for tests.
326.346 + * Will be in /tmp or whatever, and will be empty.
326.347 + * If you just need a java.io.File use clearWorkDir + getWorkDir.
326.348 + */
326.349 + public static FileObject makeScratchDir(NbTestCase test) throws IOException {
326.350 + test.clearWorkDir();
326.351 + File root = test.getWorkDir();
326.352 + assert root.isDirectory() && root.list().length == 0;
326.353 + FileObject fo = FileUtil.toFileObject(root);
326.354 + if (fo != null) {
326.355 + // Presumably using masterfs.
326.356 + return fo;
326.357 + } else {
326.358 + // For the benefit of those not using masterfs.
326.359 + LocalFileSystem lfs = new LocalFileSystem();
326.360 + try {
326.361 + lfs.setRootDirectory(root);
326.362 + } catch (PropertyVetoException e) {
326.363 + assert false : e;
326.364 + }
326.365 + Repository.getDefault().addFileSystem(lfs);
326.366 + return lfs.getRoot();
326.367 + }
326.368 + }
326.369 +
326.370 + public static JavacTask getJavacTaskFor(CompilationInfo info) {
326.371 + return info.impl.getJavacTask();
326.372 + }
326.373 +
326.374 + /** Blocking call for CompilationInfo after given phase is reached.
326.375 + * @param phase to be reached
326.376 + * @return CompilationInfo or null
326.377 + * XXX: REMOVE ME!!!!!!!
326.378 + */
326.379 + public static CompilationInfo getCompilationInfo(JavaSource js, Phase phase ) throws IOException {
326.380 + if (phase == null || phase == Phase.MODIFIED) {
326.381 + throw new IllegalArgumentException (String.format("The %s is not a legal value of phase",phase)); //NOI18N
326.382 + }
326.383 + final DeadlockTask bt = new DeadlockTask(phase);
326.384 + js.runUserActionTask(bt,true);
326.385 + return bt.info;
326.386 + }
326.387 +
326.388 +
326.389 + private static class DeadlockTask implements Task<CompilationController> {
326.390 +
326.391 + private final Phase phase;
326.392 + private CompilationInfo info;
326.393 +
326.394 + public DeadlockTask(Phase phase) {
326.395 + assert phase != null;
326.396 + this.phase = phase;
326.397 + }
326.398 +
326.399 + public void run( CompilationController info ) {
326.400 + try {
326.401 + info.toPhase(this.phase);
326.402 + this.info = info;
326.403 + } catch (IOException ioe) {
326.404 + if (log.isLoggable(Level.SEVERE))
326.405 + log.log(Level.SEVERE, ioe.getMessage(), ioe);
326.406 + }
326.407 + }
326.408 +
326.409 + }
326.410 +
326.411 + @ServiceProvider(service=MimeDataProvider.class)
326.412 + public static final class JavacParserProvider implements MimeDataProvider {
326.413 +
326.414 + private Lookup javaLookup = Lookups.fixed(new JavacParserFactory(), new JavaCustomIndexer.Factory());
326.415 +
326.416 + public Lookup getLookup(MimePath mimePath) {
326.417 + if (mimePath.getPath().endsWith(JavacParser.MIME_TYPE)) {
326.418 + return javaLookup;
326.419 + }
326.420 +
326.421 + return Lookup.EMPTY;
326.422 + }
326.423 +
326.424 + }
326.425 +
326.426 + @ServiceProvider(service=MIMEResolver.class)
326.427 + public static final class JavaMimeResolver extends MIMEResolver {
326.428 +
326.429 + public JavaMimeResolver() {
326.430 + super(JavacParser.MIME_TYPE);
326.431 + }
326.432 +
326.433 + @Override
326.434 + public String findMIMEType(FileObject fo) {
326.435 + if ("java".equals(fo.getExt())) {
326.436 + return JavacParser.MIME_TYPE;
326.437 + }
326.438 +
326.439 + return null;
326.440 + }
326.441 +
326.442 + }
326.443 +
326.444 +}
327.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
327.2 +++ b/remoting/common/borrowedtests/src/org/netbeans/api/java/source/SourceUtilsTestUtil2.java Mon Mar 12 21:10:10 2012 +0100
327.3 @@ -0,0 +1,80 @@
327.4 +/*
327.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
327.6 + *
327.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
327.8 + *
327.9 + * The contents of this file are subject to the terms of either the GNU
327.10 + * General Public License Version 2 only ("GPL") or the Common
327.11 + * Development and Distribution License("CDDL") (collectively, the
327.12 + * "License"). You may not use this file except in compliance with the
327.13 + * License. You can obtain a copy of the License at
327.14 + * http://www.netbeans.org/cddl-gplv2.html
327.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
327.16 + * specific language governing permissions and limitations under the
327.17 + * License. When distributing the software, include this License Header
327.18 + * Notice in each file and include the License file at
327.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
327.20 + * particular file as subject to the "Classpath" exception as provided
327.21 + * by Sun in the GPL Version 2 section of the License file that
327.22 + * accompanied this code. If applicable, add the following below the
327.23 + * License Header, with the fields enclosed by brackets [] replaced by
327.24 + * your own identifying information:
327.25 + * "Portions Copyrighted [year] [name of copyright owner]"
327.26 + *
327.27 + * Contributor(s):
327.28 + *
327.29 + * The Original Software is NetBeans. The Initial Developer of the Original
327.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
327.31 + * Microsystems, Inc. All Rights Reserved.
327.32 + *
327.33 + * If you wish your version of this file to be governed by only the CDDL
327.34 + * or only the GPL Version 2, indicate your decision by adding
327.35 + * "[Contributor] elects to include this software in this distribution
327.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
327.37 + * single choice of license, a recipient has the option to distribute
327.38 + * your version of this file under either the CDDL, the GPL Version 2 or
327.39 + * to extend the choice of license to its licensees as provided above.
327.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
327.41 + * Version 2 license, then the option applies only if the new code is
327.42 + * made subject to such option by the copyright holder.
327.43 + */
327.44 +package org.netbeans.api.java.source;
327.45 +
327.46 +import com.sun.source.tree.Tree;
327.47 +import org.apache.lucene.store.FSDirectory;
327.48 +import org.netbeans.modules.java.source.transform.Transformer;
327.49 +
327.50 +/**
327.51 + *
327.52 + * @author Jan Lahoda
327.53 + */
327.54 +public final class SourceUtilsTestUtil2 {
327.55 +
327.56 + private SourceUtilsTestUtil2() {
327.57 + }
327.58 +
327.59 + public static <R, P> void run(WorkingCopy wc, Transformer<R, P> t) {
327.60 +// if (afterCommit)
327.61 +// throw new IllegalStateException ("The run method can't be called on a WorkingCopy instance after the commit"); //NOI18N
327.62 + t.init();
327.63 + t.attach(wc.impl.getJavacTask().getContext(), wc);
327.64 + t.apply(wc.getCompilationUnit());
327.65 + t.release();
327.66 + t.destroy();
327.67 + }
327.68 +
327.69 + public static <R, P> void run(WorkingCopy wc, Transformer<R, P> t, Tree tree) {
327.70 +// if (afterCommit)
327.71 +// throw new IllegalStateException ("The run method can't be called on a WorkingCopy instance after the commit"); //NOI18N
327.72 + t.init();
327.73 + t.attach(wc.impl.getJavacTask().getContext(), wc);
327.74 + t.apply(tree);
327.75 + t.release();
327.76 + t.destroy();
327.77 + }
327.78 +
327.79 + public static void disableLocks() {
327.80 +// FSDirectory.setDisableLocks(true);
327.81 + }
327.82 +
327.83 +}
328.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
328.2 +++ b/remoting/common/borrowedtests/src/org/netbeans/api/java/source/TestUtilities.java Mon Mar 12 21:10:10 2012 +0100
328.3 @@ -0,0 +1,263 @@
328.4 +/*
328.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
328.6 + *
328.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
328.8 + *
328.9 + * The contents of this file are subject to the terms of either the GNU
328.10 + * General Public License Version 2 only ("GPL") or the Common
328.11 + * Development and Distribution License("CDDL") (collectively, the
328.12 + * "License"). You may not use this file except in compliance with the
328.13 + * License. You can obtain a copy of the License at
328.14 + * http://www.netbeans.org/cddl-gplv2.html
328.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
328.16 + * specific language governing permissions and limitations under the
328.17 + * License. When distributing the software, include this License Header
328.18 + * Notice in each file and include the License file at
328.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
328.20 + * particular file as subject to the "Classpath" exception as provided
328.21 + * by Sun in the GPL Version 2 section of the License file that
328.22 + * accompanied this code. If applicable, add the following below the
328.23 + * License Header, with the fields enclosed by brackets [] replaced by
328.24 + * your own identifying information:
328.25 + * "Portions Copyrighted [year] [name of copyright owner]"
328.26 + *
328.27 + * Contributor(s):
328.28 + *
328.29 + * The Original Software is NetBeans. The Initial Developer of the Original
328.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
328.31 + * Microsystems, Inc. All Rights Reserved.
328.32 + *
328.33 + * If you wish your version of this file to be governed by only the CDDL
328.34 + * or only the GPL Version 2, indicate your decision by adding
328.35 + * "[Contributor] elects to include this software in this distribution
328.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
328.37 + * single choice of license, a recipient has the option to distribute
328.38 + * your version of this file under either the CDDL, the GPL Version 2 or
328.39 + * to extend the choice of license to its licensees as provided above.
328.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
328.41 + * Version 2 license, then the option applies only if the new code is
328.42 + * made subject to such option by the copyright holder.
328.43 + */
328.44 +
328.45 +package org.netbeans.api.java.source;
328.46 +
328.47 +import java.io.ByteArrayInputStream;
328.48 +import java.io.EOFException;
328.49 +import java.io.File;
328.50 +import java.io.FileInputStream;
328.51 +import java.io.FileOutputStream;
328.52 +import java.io.IOException;
328.53 +import java.io.InputStream;
328.54 +import java.io.OutputStream;
328.55 +import java.net.URL;
328.56 +import java.util.ArrayList;
328.57 +import java.util.Collection;
328.58 +import java.util.List;
328.59 +import java.util.concurrent.ExecutionException;
328.60 +import java.util.concurrent.Future;
328.61 +import java.util.concurrent.TimeUnit;
328.62 +import java.util.concurrent.TimeoutException;
328.63 +import java.util.concurrent.atomic.AtomicBoolean;
328.64 +import java.util.zip.GZIPInputStream;
328.65 +
328.66 +import org.netbeans.api.java.classpath.ClassPath;
328.67 +import org.netbeans.modules.java.source.usages.BinaryAnalyser;
328.68 +import org.netbeans.modules.java.source.usages.ClassIndexImpl;
328.69 +import org.netbeans.modules.java.source.usages.ClassIndexManager;
328.70 +import org.netbeans.modules.java.source.usages.IndexUtil;
328.71 +//import org.netbeans.modules.parsing.lucene.support.IndexManager.Action;
328.72 +import org.netbeans.spi.java.classpath.support.ClassPathSupport;
328.73 +import org.openide.filesystems.FileObject;
328.74 +import org.openide.filesystems.FileUtil;
328.75 +
328.76 +/**
328.77 + * Utilities to aid unit testing java.source module.
328.78 + *
328.79 + * @author Jaroslav Tulach
328.80 + * @author Tom Ball
328.81 + * @author Tomas Zezula
328.82 + */
328.83 +public final class TestUtilities {
328.84 +
328.85 + // do not instantiate
328.86 + private TestUtilities() {}
328.87 +
328.88 + /**
328.89 + * Waits for the end of the background scan, this helper method
328.90 + * is designed for tests which require to wait for the end of initial scan.
328.91 + * The method can be used as a barrier but it is not guaranteed that the
328.92 + * background scan will not start again after return from this method, the
328.93 + * test is responsible for it itself. In general it's safer to use {@link JavaSource#runWhenScanFinished}
328.94 + * method and do the critical action inside the run method.
328.95 + * @param timeout the maximum time to wait
328.96 + * @param unit the time unit of the timeout argument
328.97 + * @return true if the scan finished, false when the timeout elapsed before the end of the scan.
328.98 + * @throws InterruptedException is thrown when the waiting thread is interrupted.
328.99 + */
328.100 + public static boolean waitScanFinished (final long timeout, final TimeUnit unit) throws InterruptedException {
328.101 + assert unit != null;
328.102 + final ClasspathInfo cpInfo = ClasspathInfo.create(ClassPathSupport.createClassPath(new URL[0]),
328.103 + ClassPathSupport.createClassPath(new URL[0]), null);
328.104 + assert cpInfo != null;
328.105 + final JavaSource js = JavaSource.create(cpInfo);
328.106 + assert js != null;
328.107 + try {
328.108 + Future<Void> future = js.runWhenScanFinished(new Task<CompilationController>() {
328.109 + public void run(CompilationController parameter) throws Exception {
328.110 + }
328.111 + }, true);
328.112 + future.get(timeout,unit);
328.113 + return true;
328.114 + } catch (IOException ioe) {
328.115 + //Actually never thrown
328.116 + }
328.117 + catch (ExecutionException ee) {
328.118 + //Actually never thrown
328.119 + }
328.120 + catch (TimeoutException timeoutEx) {
328.121 + }
328.122 + return false;
328.123 + }
328.124 +
328.125 +// /**
328.126 +// * Disables use of {@link LibraryManager} in the {@link GlobalSourcePath}. The tests
328.127 +// * which don't register {@link LibraryProvider} or {@link LibraryTypeProvider} may
328.128 +// * use this method to disable use of {@link LibraryManager} in the {@link GlobalSourcePath}.
328.129 +// * @param use false value disables use of {@link LibraryManager}
328.130 +// */
328.131 +// public static void setUseLibraries (final boolean use) {
328.132 +// //GlobalSourcePathTestUtil.setUseLibraries(use);
328.133 +// // IMO this in fact did nothing... If your tests are failing due to this
328.134 +// // please file a defect on editor/parsing & indexing and we will try to help.
328.135 +// }
328.136 +
328.137 + /**
328.138 + * Sets a root folder of the java source caches. This method may be used by tests
328.139 + * which need to do an initial compilation, they require either {@link ClassIndex} or
328.140 + * need to work with a group of related java files.
328.141 + * @param cacheFolder the folder used by java infrastructure as a cache,
328.142 + * has to exist and must be a folder.
328.143 + */
328.144 + public static void setCacheFolder (final File cacheFolder) {
328.145 + IndexUtil.setCacheFolder(cacheFolder);
328.146 + }
328.147 +
328.148 + /**
328.149 + * Creates boot {@link ClassPath} for platform the test is running on,
328.150 + * it uses the sun.boot.class.path property to find out the boot path roots.
328.151 + * @return ClassPath
328.152 + * @throws java.io.IOException when boot path property contains non valid path
328.153 + */
328.154 + public static ClassPath createBootClassPath () throws IOException {
328.155 + String bootPath = System.getProperty ("sun.boot.class.path");
328.156 + String[] paths = bootPath.split(File.pathSeparator);
328.157 + List<URL>roots = new ArrayList<URL> (paths.length);
328.158 + for (String path : paths) {
328.159 + File f = new File (path);
328.160 + if (!f.exists()) {
328.161 + continue;
328.162 + }
328.163 + URL url = f.toURI().toURL();
328.164 + if (FileUtil.isArchiveFile(url)) {
328.165 + url = FileUtil.getArchiveRoot(url);
328.166 + }
328.167 + roots.add (url);
328.168 + }
328.169 + return ClassPathSupport.createClassPath(roots.toArray(new URL[roots.size()]));
328.170 + }
328.171 + /**
328.172 + * Returns a string which contains the contents of a file.
328.173 + *
328.174 + * @param f the file to be read
328.175 + * @return the contents of the file(s).
328.176 + */
328.177 + public final static String copyFileToString (java.io.File f) throws java.io.IOException {
328.178 + int s = (int)f.length ();
328.179 + byte[] data = new byte[s];
328.180 + int len = new FileInputStream (f).read (data);
328.181 + if (len != s)
328.182 + throw new EOFException("truncated file");
328.183 + return new String (data);
328.184 + }
328.185 +
328.186 + /**
328.187 + * Returns a string which contains the contents of a GZIP compressed file.
328.188 + *
328.189 + * @param f the file to be read
328.190 + * @return the contents of the file(s).
328.191 + */
328.192 + public final static String copyGZipFileToString (java.io.File f) throws java.io.IOException {
328.193 + GZIPInputStream is = new GZIPInputStream(new FileInputStream(f));
328.194 + byte[] arr = new byte[256 * 256];
328.195 + int first = 0;
328.196 + for(;;) {
328.197 + int len = is.read(arr, first, arr.length - first);
328.198 + if (first + len < arr.length) {
328.199 + return new String(arr, 0, first + len);
328.200 + }
328.201 + }
328.202 + }
328.203 +
328.204 + /**
328.205 + * Copies a string to a specified file.
328.206 + *
328.207 + * @param f the file to use.
328.208 + * @param content the contents of the returned file.
328.209 + * @return the created file
328.210 + */
328.211 + public final static File copyStringToFile (File f, String content) throws Exception {
328.212 + FileOutputStream os = new FileOutputStream(f);
328.213 + InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
328.214 + FileUtil.copy(is, os);
328.215 + os.close ();
328.216 + is.close();
328.217 +
328.218 + return f;
328.219 + }
328.220 +
328.221 + /**
328.222 + * Copies a string to a specified file.
328.223 + *
328.224 + * @param f the {@link FilObject} to use.
328.225 + * @param content the contents of the returned file.
328.226 + * @return the created file
328.227 + */
328.228 + public final static FileObject copyStringToFile (FileObject f, String content) throws Exception {
328.229 + OutputStream os = f.getOutputStream();
328.230 + InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
328.231 + FileUtil.copy(is, os);
328.232 + os.close ();
328.233 + is.close();
328.234 +
328.235 + return f;
328.236 + }
328.237 +
328.238 + private static final ClassPath EMPTY = ClassPathSupport.createClassPath(new URL[0]);
328.239 +
328.240 +// /**
328.241 +// * Prepare Java caches for given binary roots.
328.242 +// *
328.243 +// * @param urls to analyze
328.244 +// */
328.245 +// public final static void analyzeBinaries(final Collection<URL> urls) throws IOException {
328.246 +// final ClasspathInfo cpInfo = ClasspathInfo.create(EMPTY, EMPTY, EMPTY);
328.247 +// final ClassIndexManager mgr = ClassIndexManager.getDefault();
328.248 +// final JavaSource js = JavaSource.create(cpInfo);
328.249 +// js.runUserActionTask(new Task<CompilationController>() {
328.250 +// public void run(CompilationController parameter) throws Exception {
328.251 +// for (final URL url : urls) {
328.252 +// final ClassIndexImpl cii = mgr.createUsagesQuery(url, false);
328.253 +// ClassIndexManager.getDefault().writeLock(new Action<Void>() {
328.254 +// public Void run() throws IOException, InterruptedException {
328.255 +// BinaryAnalyser ba = cii.getBinaryAnalyser();
328.256 +// ba.start(url, new AtomicBoolean(false), new AtomicBoolean(false));
328.257 +// ba.finish();
328.258 +// return null;
328.259 +// }
328.260 +// });
328.261 +// }
328.262 +// }
328.263 +// }, true);
328.264 +// }
328.265 +
328.266 +}
329.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
329.2 +++ b/remoting/common/borrowedtests/src/org/netbeans/modules/jackpot30/impl/TestUtils.java Mon Mar 12 21:10:10 2012 +0100
329.3 @@ -0,0 +1,116 @@
329.4 +/*
329.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
329.6 + *
329.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
329.8 + *
329.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
329.10 + * Other names may be trademarks of their respective owners.
329.11 + *
329.12 + * The contents of this file are subject to the terms of either the GNU
329.13 + * General Public License Version 2 only ("GPL") or the Common
329.14 + * Development and Distribution License("CDDL") (collectively, the
329.15 + * "License"). You may not use this file except in compliance with the
329.16 + * License. You can obtain a copy of the License at
329.17 + * http://www.netbeans.org/cddl-gplv2.html
329.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
329.19 + * specific language governing permissions and limitations under the
329.20 + * License. When distributing the software, include this License Header
329.21 + * Notice in each file and include the License file at
329.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
329.23 + * particular file as subject to the "Classpath" exception as provided
329.24 + * by Oracle in the GPL Version 2 section of the License file that
329.25 + * accompanied this code. If applicable, add the following below the
329.26 + * License Header, with the fields enclosed by brackets [] replaced by
329.27 + * your own identifying information:
329.28 + * "Portions Copyrighted [year] [name of copyright owner]"
329.29 + *
329.30 + * If you wish your version of this file to be governed by only the CDDL
329.31 + * or only the GPL Version 2, indicate your decision by adding
329.32 + * "[Contributor] elects to include this software in this distribution
329.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
329.34 + * single choice of license, a recipient has the option to distribute
329.35 + * your version of this file under either the CDDL, the GPL Version 2 or
329.36 + * to extend the choice of license to its licensees as provided above.
329.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
329.38 + * Version 2 license, then the option applies only if the new code is
329.39 + * made subject to such option by the copyright holder.
329.40 + *
329.41 + * Contributor(s):
329.42 + *
329.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
329.44 + */
329.45 +package org.netbeans.modules.jackpot30.impl;
329.46 +
329.47 +import java.io.ByteArrayInputStream;
329.48 +import java.io.IOException;
329.49 +import java.net.URL;
329.50 +import java.net.URLConnection;
329.51 +import java.net.URLStreamHandler;
329.52 +import java.net.URLStreamHandlerFactory;
329.53 +import java.util.HashMap;
329.54 +import java.util.Map;
329.55 +import junit.framework.Assert;
329.56 +import org.openide.util.lookup.ServiceProvider;
329.57 +
329.58 +/**
329.59 + *
329.60 + * @author lahvac
329.61 + */
329.62 +public class TestUtils {
329.63 +
329.64 + public static void clearRemoteContent() {
329.65 + content.clear();
329.66 + }
329.67 +
329.68 + public static void addRemoteContent(URL url, String content) {
329.69 + TestUtils.content.put(url, content);
329.70 + }
329.71 +
329.72 + private static final Map<URL, String> content = new HashMap<URL, String>();
329.73 +
329.74 + @ServiceProvider(service=URLStreamHandlerFactory.class)
329.75 + public static final class URLStreamHandlerFactoryImpl implements URLStreamHandlerFactory {
329.76 +
329.77 + public URLStreamHandler createURLStreamHandler(String protocol) {
329.78 + if ("test".equals(protocol)) {
329.79 + return new URLStreamHandlerImpl();
329.80 + }
329.81 +
329.82 + return null;
329.83 + }
329.84 +
329.85 + }
329.86 +
329.87 + private static final class URLStreamHandlerImpl extends URLStreamHandler {
329.88 +
329.89 + @Override
329.90 + protected URLConnection openConnection(URL u) throws IOException {
329.91 + String str = content.get(u);
329.92 +
329.93 + Assert.assertNotNull(u.toExternalForm(), str);
329.94 +
329.95 + return new TestURLConnection(u, str);
329.96 + }
329.97 +
329.98 + }
329.99 +
329.100 + private static final class TestURLConnection extends URLConnection {
329.101 +
329.102 + private final String content;
329.103 +
329.104 + public TestURLConnection(URL url, String content) {
329.105 + super(url);
329.106 + this.content = content;
329.107 + }
329.108 +
329.109 + @Override
329.110 + public void connect() throws IOException {
329.111 + }
329.112 +
329.113 + @Override
329.114 + public Object getContent() throws IOException {
329.115 + return new ByteArrayInputStream(content.getBytes("ASCII")); //XXX
329.116 + }
329.117 +
329.118 + }
329.119 +}
330.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
330.2 +++ b/remoting/common/borrowedtests/src/org/netbeans/modules/jackpot30/test/borrowed/Bundle.properties Mon Mar 12 21:10:10 2012 +0100
330.3 @@ -0,0 +1,38 @@
330.4 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
330.5 +#
330.6 +# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
330.7 +#
330.8 +# The contents of this file are subject to the terms of either the GNU
330.9 +# General Public License Version 2 only ("GPL") or the Common
330.10 +# Development and Distribution License("CDDL") (collectively, the
330.11 +# "License"). You may not use this file except in compliance with the
330.12 +# License. You can obtain a copy of the License at
330.13 +# http://www.netbeans.org/cddl-gplv2.html
330.14 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
330.15 +# specific language governing permissions and limitations under the
330.16 +# License. When distributing the software, include this License Header
330.17 +# Notice in each file and include the License file at
330.18 +# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
330.19 +# particular file as subject to the "Classpath" exception as provided
330.20 +# by Sun in the GPL Version 2 section of the License file that
330.21 +# accompanied this code. If applicable, add the following below the
330.22 +# License Header, with the fields enclosed by brackets [] replaced by
330.23 +# your own identifying information:
330.24 +# "Portions Copyrighted [year] [name of copyright owner]"
330.25 +#
330.26 +# If you wish your version of this file to be governed by only the CDDL
330.27 +# or only the GPL Version 2, indicate your decision by adding
330.28 +# "[Contributor] elects to include this software in this distribution
330.29 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
330.30 +# single choice of license, a recipient has the option to distribute
330.31 +# your version of this file under either the CDDL, the GPL Version 2 or
330.32 +# to extend the choice of license to its licensees as provided above.
330.33 +# However, if you add GPL Version 2 code and therefore, elected the GPL
330.34 +# Version 2 license, then the option applies only if the new code is
330.35 +# made subject to such option by the copyright holder.
330.36 +#
330.37 +# Contributor(s):
330.38 +#
330.39 +# Portions Copyrighted 2009 Sun Microsystems, Inc.
330.40 +
330.41 +OpenIDE-Module-Name=Borrowed Test Infra
331.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
331.2 +++ b/remoting/common/borrowedtests/src/org/netbeans/modules/java/hints/TestUtilities.java Mon Mar 12 21:10:10 2012 +0100
331.3 @@ -0,0 +1,60 @@
331.4 +/*
331.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
331.6 + *
331.7 + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
331.8 + *
331.9 + * The contents of this file are subject to the terms of either the GNU
331.10 + * General Public License Version 2 only ("GPL") or the Common
331.11 + * Development and Distribution License("CDDL") (collectively, the
331.12 + * "License"). You may not use this file except in compliance with the
331.13 + * License. You can obtain a copy of the License at
331.14 + * http://www.netbeans.org/cddl-gplv2.html
331.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
331.16 + * specific language governing permissions and limitations under the
331.17 + * License. When distributing the software, include this License Header
331.18 + * Notice in each file and include the License file at
331.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
331.20 + * particular file as subject to the "Classpath" exception as provided
331.21 + * by Sun in the GPL Version 2 section of the License file that
331.22 + * accompanied this code. If applicable, add the following below the
331.23 + * License Header, with the fields enclosed by brackets [] replaced by
331.24 + * your own identifying information:
331.25 + * "Portions Copyrighted [year] [name of copyright owner]"
331.26 + *
331.27 + * Contributor(s):
331.28 + *
331.29 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
331.30 + */
331.31 +package org.netbeans.modules.java.hints;
331.32 +
331.33 +import junit.framework.Assert;
331.34 +
331.35 +/**
331.36 + *
331.37 + * @author Jan Lahoda
331.38 + */
331.39 +public class TestUtilities {
331.40 +
331.41 + private TestUtilities() {
331.42 + }
331.43 +
331.44 + public static String detectOffsets(String source, int[] positionOrSpan) {
331.45 + //for now, the position/span delimiter is '|', without possibility of escaping:
331.46 + String[] split = source.split("\\|");
331.47 +
331.48 + Assert.assertTrue("incorrect number of position markers (|)", positionOrSpan.length == split.length - 1);
331.49 +
331.50 + StringBuilder sb = new StringBuilder();
331.51 + int index = 0;
331.52 + int offset = 0;
331.53 +
331.54 + for (String s : split) {
331.55 + sb.append(s);
331.56 + if (index < positionOrSpan.length)
331.57 + positionOrSpan[index++] = (offset += s.length());
331.58 + }
331.59 +
331.60 + return sb.toString();
331.61 + }
331.62 +
331.63 +}
332.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
332.2 +++ b/remoting/common/borrowedtests/src/org/netbeans/modules/java/hints/infrastructure/TreeRuleTestBase.java Mon Mar 12 21:10:10 2012 +0100
332.3 @@ -0,0 +1,303 @@
332.4 +/*
332.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
332.6 + *
332.7 + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
332.8 + *
332.9 + * The contents of this file are subject to the terms of either the GNU
332.10 + * General Public License Version 2 only ("GPL") or the Common
332.11 + * Development and Distribution License("CDDL") (collectively, the
332.12 + * "License"). You may not use this file except in compliance with the
332.13 + * License. You can obtain a copy of the License at
332.14 + * http://www.netbeans.org/cddl-gplv2.html
332.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
332.16 + * specific language governing permissions and limitations under the
332.17 + * License. When distributing the software, include this License Header
332.18 + * Notice in each file and include the License file at
332.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
332.20 + * particular file as subject to the "Classpath" exception as provided
332.21 + * by Sun in the GPL Version 2 section of the License file that
332.22 + * accompanied this code. If applicable, add the following below the
332.23 + * License Header, with the fields enclosed by brackets [] replaced by
332.24 + * your own identifying information:
332.25 + * "Portions Copyrighted [year] [name of copyright owner]"
332.26 + *
332.27 + * Contributor(s):
332.28 + *
332.29 + * The Original Software is NetBeans. The Initial Developer of the Original
332.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
332.31 + * Microsystems, Inc. All Rights Reserved.
332.32 + *
332.33 + * If you wish your version of this file to be governed by only the CDDL
332.34 + * or only the GPL Version 2, indicate your decision by adding
332.35 + * "[Contributor] elects to include this software in this distribution
332.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
332.37 + * single choice of license, a recipient has the option to distribute
332.38 + * your version of this file under either the CDDL, the GPL Version 2 or
332.39 + * to extend the choice of license to its licensees as provided above.
332.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
332.41 + * Version 2 license, then the option applies only if the new code is
332.42 + * made subject to such option by the copyright holder.
332.43 + */
332.44 +package org.netbeans.modules.java.hints.infrastructure;
332.45 +
332.46 +import com.sun.source.util.TreePath;
332.47 +import java.io.File;
332.48 +import java.util.Arrays;
332.49 +import java.util.Collections;
332.50 +import java.util.LinkedList;
332.51 +import java.util.List;
332.52 +import java.util.logging.Level;
332.53 +import java.util.logging.Logger;
332.54 +import javax.swing.text.Document;
332.55 +import org.netbeans.api.java.lexer.JavaTokenId;
332.56 +import org.netbeans.api.java.source.CompilationInfo;
332.57 +import org.netbeans.api.java.source.JavaSource;
332.58 +import org.netbeans.api.java.source.JavaSource.Phase;
332.59 +import org.netbeans.api.java.source.SourceUtilsTestUtil;
332.60 +import org.netbeans.api.java.source.TestUtilities;
332.61 +import org.netbeans.api.lexer.Language;
332.62 +import org.netbeans.junit.NbTestCase;
332.63 +import org.netbeans.modules.java.source.TreeLoader;
332.64 +import org.netbeans.spi.editor.hints.ErrorDescription;
332.65 +import org.netbeans.spi.editor.hints.Fix;
332.66 +import org.openide.LifecycleManager;
332.67 +import org.openide.cookies.EditorCookie;
332.68 +import org.openide.filesystems.FileObject;
332.69 +import org.openide.filesystems.FileUtil;
332.70 +import org.openide.loaders.DataObject;
332.71 +
332.72 +/**
332.73 + * @author Jan Lahoda
332.74 + */
332.75 +public abstract class TreeRuleTestBase extends NbTestCase {
332.76 + protected final Logger LOG;
332.77 +
332.78 + public TreeRuleTestBase(String name) {
332.79 + super(name);
332.80 + LOG = Logger.getLogger("test." + name);
332.81 + }
332.82 +
332.83 + @Override
332.84 + protected Level logLevel() {
332.85 + return Level.INFO;
332.86 + }
332.87 +
332.88 + @Override
332.89 + protected void setUp() throws Exception {
332.90 + super.setUp();
332.91 + SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml"}, new Object[0]);
332.92 + TreeLoader.DISABLE_CONFINEMENT_TEST = true;
332.93 + }
332.94 +
332.95 + private void prepareTest(String fileName, String code) throws Exception {
332.96 + clearWorkDir();
332.97 + File wdFile = getWorkDir();
332.98 + FileUtil.refreshFor(wdFile);
332.99 +
332.100 + FileObject wd = FileUtil.toFileObject(wdFile);
332.101 + assertNotNull(wd);
332.102 + sourceRoot = FileUtil.createFolder(wd, "src");
332.103 + FileObject buildRoot = FileUtil.createFolder(wd, "build");
332.104 + FileObject cache = FileUtil.createFolder(wd, "cache");
332.105 +
332.106 + FileObject data = FileUtil.createData(sourceRoot, fileName);
332.107 + File dataFile = FileUtil.toFile(data);
332.108 +
332.109 + assertNotNull(dataFile);
332.110 +
332.111 + TestUtilities.copyStringToFile(dataFile, code);
332.112 +
332.113 + SourceUtilsTestUtil.prepareTest(sourceRoot, buildRoot, cache, extraClassPath());
332.114 +
332.115 + DataObject od = DataObject.find(data);
332.116 + EditorCookie ec = od.getCookie(EditorCookie.class);
332.117 +
332.118 + assertNotNull(ec);
332.119 +
332.120 + doc = ec.openDocument();
332.121 + doc.putProperty(Language.class, JavaTokenId.language());
332.122 + doc.putProperty("mimeType", "text/x-java");
332.123 +
332.124 + JavaSource js = JavaSource.forFileObject(data);
332.125 +
332.126 + assertNotNull(js);
332.127 +
332.128 + info = SourceUtilsTestUtil.getCompilationInfo(js, Phase.RESOLVED);
332.129 +
332.130 + assertNotNull(info);
332.131 + }
332.132 +
332.133 + private FileObject sourceRoot;
332.134 + private CompilationInfo info;
332.135 + private Document doc;
332.136 +
332.137 + protected abstract List<ErrorDescription> computeErrors(CompilationInfo info, TreePath path);
332.138 +
332.139 + protected List<ErrorDescription> computeErrors(CompilationInfo info, TreePath path, int offset) {
332.140 + return computeErrors(info, path);
332.141 + }
332.142 +
332.143 + protected String toDebugString(CompilationInfo info, Fix f) {
332.144 + return f.toString();
332.145 + }
332.146 +
332.147 + protected void performAnalysisTest(String fileName, String code, String... golden) throws Exception {
332.148 + int[] offset = new int[1];
332.149 +
332.150 + code = org.netbeans.modules.java.hints.TestUtilities.detectOffsets(code, offset);
332.151 +
332.152 + performAnalysisTest(fileName, code, offset[0], golden);
332.153 + }
332.154 +
332.155 + protected void performAnalysisTest(String fileName, String code, int pos, String... golden) throws Exception {
332.156 + prepareTest(fileName, code);
332.157 +
332.158 + TreePath path = info.getTreeUtilities().pathFor(pos);
332.159 +
332.160 + List<ErrorDescription> errors = computeErrors(info, path, pos);
332.161 + List<String> errorsNames = new LinkedList<String>();
332.162 +
332.163 + errors = errors != null ? errors : Collections.<ErrorDescription>emptyList();
332.164 +
332.165 + for (ErrorDescription e : errors) {
332.166 + errorsNames.add(e.toString());
332.167 + }
332.168 +
332.169 + assertTrue("The warnings provided by the hint do not match expected warnings. Provided warnings: " + errorsNames.toString(), Arrays.equals(golden, errorsNames.toArray(new String[0])));
332.170 + }
332.171 +
332.172 + protected String performFixTest(String fileName, String code, String errorDescriptionToString, String fixDebugString, String golden) throws Exception {
332.173 + int[] offset = new int[1];
332.174 +
332.175 + code = org.netbeans.modules.java.hints.TestUtilities.detectOffsets(code, offset);
332.176 +
332.177 + return performFixTest(fileName, code, offset[0], errorDescriptionToString, fixDebugString, golden);
332.178 + }
332.179 +
332.180 + protected String performFixTest(String fileName, String code, int pos, String errorDescriptionToString, String fixDebugString, String golden) throws Exception {
332.181 + return performFixTest(fileName, code, pos, errorDescriptionToString, fixDebugString, fileName, golden);
332.182 + }
332.183 +
332.184 + protected String performFixTest(String fileName, String code, String errorDescriptionToString, String fixDebugString, String goldenFileName, String golden) throws Exception {
332.185 + int[] offset = new int[1];
332.186 +
332.187 + code = org.netbeans.modules.java.hints.TestUtilities.detectOffsets(code, offset);
332.188 +
332.189 + return performFixTest(fileName, code, offset[0], errorDescriptionToString, fixDebugString, goldenFileName, golden);
332.190 + }
332.191 +
332.192 + protected String performFixTest(String fileName, String code, int pos, String errorDescriptionToString, String fixDebugString, String goldenFileName, String golden) throws Exception {
332.193 + prepareTest(fileName, code);
332.194 +
332.195 + TreePath path = info.getTreeUtilities().pathFor(pos);
332.196 +
332.197 + List<ErrorDescription> errors = computeErrors(info, path, pos);
332.198 +
332.199 + ErrorDescription toFix = null;
332.200 +
332.201 + for (ErrorDescription d : errors) {
332.202 + if (errorDescriptionToString.equals(d.toString())) {
332.203 + toFix = d;
332.204 + break;
332.205 + }
332.206 + }
332.207 +
332.208 + assertNotNull("Error: \"" + errorDescriptionToString + "\" not found. All ErrorDescriptions: " + errors.toString(), toFix);
332.209 +
332.210 + assertTrue("Must be computed", toFix.getFixes().isComputed());
332.211 +
332.212 + List<Fix> fixes = toFix.getFixes().getFixes();
332.213 + List<String> fixNames = new LinkedList<String>();
332.214 + Fix toApply = null;
332.215 +
332.216 + for (Fix f : fixes) {
332.217 + if (fixDebugString.equals(toDebugString(info, f))) {
332.218 + toApply = f;
332.219 + }
332.220 +
332.221 + fixNames.add(toDebugString(info, f));
332.222 + }
332.223 +
332.224 + assertNotNull("Cannot find fix to invoke: " + fixNames.toString(), toApply);
332.225 +
332.226 + toApply.implement();
332.227 +
332.228 + FileObject toCheck = sourceRoot.getFileObject(goldenFileName);
332.229 +
332.230 + assertNotNull(toCheck);
332.231 +
332.232 + DataObject toCheckDO = DataObject.find(toCheck);
332.233 + EditorCookie ec = toCheckDO.getLookup().lookup(EditorCookie.class);
332.234 + Document toCheckDocument = ec.openDocument();
332.235 +
332.236 + String realCode = toCheckDocument.getText(0, toCheckDocument.getLength());
332.237 +
332.238 + //ignore whitespaces:
332.239 + realCode = realCode.replaceAll("[ \t\n]+", " ");
332.240 +
332.241 + if (golden != null) {
332.242 + assertEquals("The output code does not match the expected code.", golden, realCode);
332.243 + }
332.244 +
332.245 + LifecycleManager.getDefault().saveAll();
332.246 +
332.247 + return realCode;
332.248 + }
332.249 +
332.250 + protected FileObject[] extraClassPath() {
332.251 + return new FileObject[0];
332.252 + }
332.253 +
332.254 + // common tests to check nothing is reported
332.255 + public void testIssue105979() throws Exception {
332.256 + String before = "package test; class Test {" +
332.257 + " return b;" +
332.258 + "}\n";
332.259 +
332.260 + for (int i = 0; i < before.length(); i++) {
332.261 + LOG.info("testing position " + i + " at " + before.charAt(i));
332.262 + clearWorkDir();
332.263 + performAnalysisTest("test/Test.java", before, i);
332.264 +}
332.265 + }
332.266 + public void testIssue108246() throws Exception {
332.267 +
332.268 + String before = "package test; class Test {" +
332.269 + " Integer ii = new Integer(0);" +
332.270 + " String s = ii.toString();" +
332.271 + "\n}\n";
332.272 +
332.273 + for (int i = 0; i < before.length(); i++) {
332.274 + LOG.info("testing position " + i + " at " + before.charAt(i));
332.275 + clearWorkDir();
332.276 + performAnalysisTest("test/Test.java", before, i);
332.277 + }
332.278 + }
332.279 +
332.280 + public void testNoHintsForSimpleInitialize() throws Exception {
332.281 +
332.282 + String before = "package test; class Test {" +
332.283 + " { java.lang.System.out.println(); } " +
332.284 + "}\n";
332.285 +
332.286 + for (int i = 0; i < before.length(); i++) {
332.287 + LOG.info("testing position " + i + " at " + before.charAt(i));
332.288 + clearWorkDir();
332.289 + performAnalysisTest("test/Test.java", before, i);
332.290 + }
332.291 + }
332.292 +
332.293 + public void testIssue113933() throws Exception {
332.294 +
332.295 + String before = "package test; class Test {" +
332.296 + " public void test() {" +
332.297 + " super.A();" +
332.298 + "\n}\n}\n";
332.299 +
332.300 + for (int i = 0; i < before.length(); i++) {
332.301 + LOG.info("testing position " + i + " at " + before.charAt(i));
332.302 + clearWorkDir();
332.303 + performAnalysisTest("test/Test.java", before, i);
332.304 + }
332.305 + }
332.306 +}
333.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
333.2 +++ b/remoting/common/borrowedtests/src/org/netbeans/modules/java/hints/jackpot/code/spi/TestBase.java Mon Mar 12 21:10:10 2012 +0100
333.3 @@ -0,0 +1,341 @@
333.4 +/*
333.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
333.6 + *
333.7 + * Copyright 2009-2010 Oracle and/or its affiliates. All rights reserved.
333.8 + *
333.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
333.10 + * Other names may be trademarks of their respective owners.
333.11 + *
333.12 + * The contents of this file are subject to the terms of either the GNU
333.13 + * General Public License Version 2 only ("GPL") or the Common
333.14 + * Development and Distribution License("CDDL") (collectively, the
333.15 + * "License"). You may not use this file except in compliance with the
333.16 + * License. You can obtain a copy of the License at
333.17 + * http://www.netbeans.org/cddl-gplv2.html
333.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
333.19 + * specific language governing permissions and limitations under the
333.20 + * License. When distributing the software, include this License Header
333.21 + * Notice in each file and include the License file at
333.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
333.23 + * particular file as subject to the "Classpath" exception as provided
333.24 + * by Oracle in the GPL Version 2 section of the License file that
333.25 + * accompanied this code. If applicable, add the following below the
333.26 + * License Header, with the fields enclosed by brackets [] replaced by
333.27 + * your own identifying information:
333.28 + * "Portions Copyrighted [year] [name of copyright owner]"
333.29 + *
333.30 + * If you wish your version of this file to be governed by only the CDDL
333.31 + * or only the GPL Version 2, indicate your decision by adding
333.32 + * "[Contributor] elects to include this software in this distribution
333.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
333.34 + * single choice of license, a recipient has the option to distribute
333.35 + * your version of this file under either the CDDL, the GPL Version 2 or
333.36 + * to extend the choice of license to its licensees as provided above.
333.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
333.38 + * Version 2 license, then the option applies only if the new code is
333.39 + * made subject to such option by the copyright holder.
333.40 + *
333.41 + * Contributor(s):
333.42 + *
333.43 + * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
333.44 + */
333.45 +
333.46 +package org.netbeans.modules.java.hints.jackpot.code.spi;
333.47 +
333.48 +import java.io.File;
333.49 +import java.lang.reflect.Method;
333.50 +import java.util.ArrayList;
333.51 +import java.util.Arrays;
333.52 +import java.util.Collection;
333.53 +import java.util.Collections;
333.54 +import java.util.Comparator;
333.55 +import java.util.HashMap;
333.56 +import java.util.HashSet;
333.57 +import java.util.LinkedList;
333.58 +import java.util.List;
333.59 +import java.util.Map;
333.60 +import java.util.Map.Entry;
333.61 +import java.util.Set;
333.62 +import java.util.concurrent.atomic.AtomicBoolean;
333.63 +import java.util.logging.Level;
333.64 +import java.util.logging.Logger;
333.65 +import javax.swing.text.Document;
333.66 +import org.netbeans.api.java.lexer.JavaTokenId;
333.67 +import org.netbeans.api.java.source.CompilationInfo;
333.68 +import org.netbeans.api.java.source.JavaSource;
333.69 +import org.netbeans.api.java.source.JavaSource.Phase;
333.70 +import org.netbeans.api.java.source.SourceUtilsTestUtil;
333.71 +import org.netbeans.api.java.source.TestUtilities;
333.72 +import org.netbeans.api.java.source.support.CaretAwareJavaSourceTaskFactory;
333.73 +import org.netbeans.api.lexer.Language;
333.74 +import org.netbeans.junit.NbTestCase;
333.75 +import org.netbeans.modules.java.hints.jackpot.spi.HintsRunner;
333.76 +import org.netbeans.modules.java.hints.providers.code.CodeHintProviderImpl;
333.77 +import org.netbeans.modules.java.hints.providers.code.FSWrapper;
333.78 +import org.netbeans.modules.java.hints.providers.code.FSWrapper.ClassWrapper;
333.79 +import org.netbeans.modules.java.hints.providers.spi.HintDescription;
333.80 +import org.netbeans.modules.java.hints.providers.spi.HintMetadata;
333.81 +import org.netbeans.modules.java.source.TreeLoader;
333.82 +import org.netbeans.spi.editor.hints.ErrorDescription;
333.83 +import org.netbeans.spi.editor.hints.Fix;
333.84 +import org.openide.LifecycleManager;
333.85 +import org.openide.cookies.EditorCookie;
333.86 +import org.openide.filesystems.FileObject;
333.87 +import org.openide.filesystems.FileUtil;
333.88 +import org.openide.loaders.DataObject;
333.89 +import org.openide.util.NbBundle;
333.90 +
333.91 +/**
333.92 + *
333.93 + * @author lahvac
333.94 + */
333.95 +public abstract class TestBase extends NbTestCase {
333.96 + private final Class<?> hintClass;
333.97 + protected final Logger LOG;
333.98 +
333.99 + public TestBase(String name, Class<?> hintClass) {
333.100 + super(name);
333.101 + this.hintClass = hintClass;
333.102 + LOG = Logger.getLogger("test." + name);
333.103 + }
333.104 +
333.105 + @Override
333.106 + protected Level logLevel() {
333.107 + return Level.INFO;
333.108 + }
333.109 +
333.110 + @Override
333.111 + protected void setUp() throws Exception {
333.112 + super.setUp();
333.113 + SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml", "META-INF/generated-layer.xml"}, new Object[0]);
333.114 + TreeLoader.DISABLE_CONFINEMENT_TEST = true;
333.115 + }
333.116 +
333.117 + private String sourceLevel = "1.5";
333.118 +
333.119 + protected void setSourceLevel(String sourceLevel) {
333.120 + this.sourceLevel = sourceLevel;
333.121 + }
333.122 +
333.123 + protected void prepareTest(String fileName, String code) throws Exception {
333.124 + clearWorkDir();
333.125 + File wdFile = getWorkDir();
333.126 + FileUtil.refreshFor(wdFile);
333.127 +
333.128 + FileObject wd = FileUtil.toFileObject(wdFile);
333.129 + assertNotNull(wd);
333.130 + sourceRoot = FileUtil.createFolder(wd, "src");
333.131 + FileObject buildRoot = FileUtil.createFolder(wd, "build");
333.132 + FileObject cache = FileUtil.createFolder(wd, "cache");
333.133 +
333.134 + FileObject data = FileUtil.createData(sourceRoot, fileName);
333.135 + File dataFile = FileUtil.toFile(data);
333.136 +
333.137 + assertNotNull(dataFile);
333.138 +
333.139 + TestUtilities.copyStringToFile(dataFile, code);
333.140 +
333.141 + SourceUtilsTestUtil.prepareTest(sourceRoot, buildRoot, cache, extraClassPath());
333.142 +
333.143 + SourceUtilsTestUtil.setSourceLevel(data, sourceLevel);
333.144 +
333.145 + DataObject od = DataObject.find(data);
333.146 + EditorCookie ec = od.getCookie(EditorCookie.class);
333.147 +
333.148 + assertNotNull(ec);
333.149 +
333.150 + doc = ec.openDocument();
333.151 + doc.putProperty(Language.class, JavaTokenId.language());
333.152 + doc.putProperty("mimeType", "text/x-java");
333.153 +
333.154 + JavaSource js = JavaSource.forFileObject(data);
333.155 +
333.156 + assertNotNull(js);
333.157 +
333.158 + info = SourceUtilsTestUtil.getCompilationInfo(js, Phase.RESOLVED);
333.159 +
333.160 + assertNotNull(info);
333.161 + }
333.162 +
333.163 + private FileObject sourceRoot;
333.164 + private CompilationInfo info;
333.165 + private Document doc;
333.166 +
333.167 + protected final void setTestFileCaretLocation(int pos) throws Exception {
333.168 + Method m = CaretAwareJavaSourceTaskFactory.class.getDeclaredMethod("setLastPosition", FileObject.class, int.class);
333.169 +
333.170 + m.setAccessible(true);
333.171 + m.invoke(null, info.getFileObject(), pos);
333.172 + }
333.173 +
333.174 + private List<ErrorDescription> computeErrors(CompilationInfo info) {
333.175 + Map<HintMetadata, Collection<HintDescription>> hints = new HashMap<HintMetadata, Collection<HintDescription>>();
333.176 +
333.177 + ClassWrapper found = null;
333.178 +
333.179 + for (ClassWrapper w : FSWrapper.listClasses()) {
333.180 + if (w.getName().equals(hintClass.getName())) {
333.181 + found = w;
333.182 + break;
333.183 + }
333.184 + }
333.185 +
333.186 + assertNotNull(found);
333.187 +
333.188 + CodeHintProviderImpl.processClass(found, hints);
333.189 +
333.190 + List<HintDescription> total = new LinkedList<HintDescription>();
333.191 +
333.192 + for (Collection<? extends HintDescription> l : hints.values()) {
333.193 + total.addAll(l);
333.194 + }
333.195 +
333.196 + List<ErrorDescription> result = new ArrayList<ErrorDescription>();
333.197 +
333.198 + for (Entry<HintDescription, List<ErrorDescription>> e : HintsRunner.computeErrors(info, total, new AtomicBoolean()).entrySet()) {
333.199 + result.addAll(e.getValue());
333.200 + }
333.201 +
333.202 + return result;
333.203 + }
333.204 +
333.205 + protected String toDebugString(CompilationInfo info, Fix f) {
333.206 + return "FixImpl";
333.207 + }
333.208 +
333.209 + protected void performAnalysisTest(String fileName, String code, String... golden) throws Exception {
333.210 + prepareTest(fileName, code);
333.211 +
333.212 + List<ErrorDescription> errors = computeErrors(info);
333.213 + Collections.sort (errors, ERRORS_COMPARATOR);
333.214 + List<String> errorsNames = new LinkedList<String>();
333.215 +
333.216 + errors = errors != null ? errors : Collections.<ErrorDescription>emptyList();
333.217 +
333.218 + for (ErrorDescription e : errors) {
333.219 + errorsNames.add(e.toString());
333.220 + }
333.221 +
333.222 + assertTrue("The warnings provided by the hint do not match expected warnings. Provided warnings: " + errorsNames.toString(), Arrays.equals(golden, errorsNames.toArray(new String[0])));
333.223 + }
333.224 +
333.225 + protected void performAnalysisContainsTest(String fileName, String code, String... golden) throws Exception {
333.226 + prepareTest(fileName, code);
333.227 +
333.228 + Set<String> goldenSet = new HashSet<String>();
333.229 + for (String s : golden) {
333.230 + goldenSet.add(s);
333.231 + }
333.232 +
333.233 + List<ErrorDescription> errors = computeErrors(info);
333.234 + Collections.sort (errors, ERRORS_COMPARATOR);
333.235 + List<String> errorsNames = new LinkedList<String>();
333.236 +
333.237 + errors = errors != null ? errors : Collections.<ErrorDescription>emptyList();
333.238 +
333.239 + for (ErrorDescription d : errors) {
333.240 + goldenSet.remove(d.toString());
333.241 + errorsNames.add(d.toString());
333.242 + }
333.243 + assertTrue("The warnings provided by the hint do not contain expected warnings. Provided warnings: " + errorsNames.toString(), goldenSet.isEmpty());
333.244 + }
333.245 +
333.246 + protected void performAnalysisExcludesTest(String fileName, String code, String... golden) throws Exception {
333.247 + prepareTest(fileName, code);
333.248 +
333.249 + Set<String> goldenSet = new HashSet<String>();
333.250 + for (String s : golden) {
333.251 + goldenSet.add(s);
333.252 + }
333.253 +
333.254 + List<ErrorDescription> errors = computeErrors(info);
333.255 + Collections.sort (errors, ERRORS_COMPARATOR);
333.256 + List<String> errorsNames = new LinkedList<String>();
333.257 +
333.258 + errors = errors != null ? errors : Collections.<ErrorDescription>emptyList();
333.259 +
333.260 + boolean fail = false;
333.261 + for (ErrorDescription d : errors) {
333.262 + if (goldenSet.remove(d.getDescription()))
333.263 + fail = true;
333.264 + errorsNames.add(d.toString());
333.265 + }
333.266 + assertFalse("The warnings provided by the hint do not exclude expected warnings. Provided warnings: " + errorsNames.toString(), fail);
333.267 + }
333.268 +
333.269 + protected String performFixTest(String fileName, String code, String errorDescriptionToString, String fixDebugString, String golden) throws Exception {
333.270 + return performFixTest(fileName, code, errorDescriptionToString, fixDebugString, fileName, golden);
333.271 + }
333.272 +
333.273 + protected String performFixTest(String fileName, String code, String errorDescriptionToString, String fixDebugString, String goldenFileName, String golden) throws Exception {
333.274 + prepareTest(fileName, code);
333.275 +
333.276 + List<ErrorDescription> errors = computeErrors(info);
333.277 + Collections.sort (errors, ERRORS_COMPARATOR);
333.278 +
333.279 + ErrorDescription toFix = null;
333.280 +
333.281 + for (ErrorDescription d : errors) {
333.282 + if (errorDescriptionToString.equals(d.toString())) {
333.283 + toFix = d;
333.284 + break;
333.285 + }
333.286 + }
333.287 +
333.288 + assertNotNull("Error: \"" + errorDescriptionToString + "\" not found. All ErrorDescriptions: " + errors.toString(), toFix);
333.289 +
333.290 + assertTrue("Must be computed", toFix.getFixes().isComputed());
333.291 +
333.292 + List<Fix> fixes = toFix.getFixes().getFixes();
333.293 + List<String> fixNames = new LinkedList<String>();
333.294 + Fix toApply = null;
333.295 +
333.296 + for (Fix f : fixes) {
333.297 + if (fixDebugString.equals(toDebugString(info, f))) {
333.298 + toApply = f;
333.299 + }
333.300 +
333.301 + fixNames.add(toDebugString(info, f));
333.302 + }
333.303 +
333.304 + assertNotNull("Cannot find fix to invoke: " + fixNames.toString(), toApply);
333.305 +
333.306 + toApply.implement();
333.307 +
333.308 + FileObject toCheck = sourceRoot.getFileObject(goldenFileName);
333.309 +
333.310 + assertNotNull(toCheck);
333.311 +
333.312 + DataObject toCheckDO = DataObject.find(toCheck);
333.313 + EditorCookie ec = toCheckDO.getLookup().lookup(EditorCookie.class);
333.314 + Document toCheckDocument = ec.openDocument();
333.315 +
333.316 + String realCode = toCheckDocument.getText(0, toCheckDocument.getLength());
333.317 +
333.318 + //ignore whitespaces:
333.319 + realCode = realCode.replaceAll("[ \t\n]+", " ");
333.320 +
333.321 + if (golden != null) {
333.322 + assertEquals("The output code does not match the expected code.", golden, realCode);
333.323 + }
333.324 +
333.325 + LifecycleManager.getDefault().saveAll();
333.326 +
333.327 + return realCode;
333.328 + }
333.329 +
333.330 + protected FileObject[] extraClassPath() {
333.331 + return new FileObject[0];
333.332 + }
333.333 +
333.334 + static {
333.335 + NbBundle.setBranding("test");
333.336 + }
333.337 +
333.338 + private static final Comparator<ErrorDescription> ERRORS_COMPARATOR = new Comparator<ErrorDescription> () {
333.339 +
333.340 + public int compare (ErrorDescription e1, ErrorDescription e2) {
333.341 + return e1.getRange ().getBegin ().getOffset () - e2.getRange ().getBegin ().getOffset ();
333.342 + }
333.343 + };
333.344 +}
334.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
334.2 +++ b/remoting/common/borrowedtests/src/org/netbeans/modules/java/hints/jackpot/impl/pm/BulkSearchTestPerformer.java Mon Mar 12 21:10:10 2012 +0100
334.3 @@ -0,0 +1,665 @@
334.4 +/*
334.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
334.6 + *
334.7 + * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
334.8 + *
334.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
334.10 + * Other names may be trademarks of their respective owners.
334.11 + *
334.12 + * The contents of this file are subject to the terms of either the GNU
334.13 + * General Public License Version 2 only ("GPL") or the Common
334.14 + * Development and Distribution License("CDDL") (collectively, the
334.15 + * "License"). You may not use this file except in compliance with the
334.16 + * License. You can obtain a copy of the License at
334.17 + * http://www.netbeans.org/cddl-gplv2.html
334.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
334.19 + * specific language governing permissions and limitations under the
334.20 + * License. When distributing the software, include this License Header
334.21 + * Notice in each file and include the License file at
334.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
334.23 + * particular file as subject to the "Classpath" exception as provided
334.24 + * by Oracle in the GPL Version 2 section of the License file that
334.25 + * accompanied this code. If applicable, add the following below the
334.26 + * License Header, with the fields enclosed by brackets [] replaced by
334.27 + * your own identifying information:
334.28 + * "Portions Copyrighted [year] [name of copyright owner]"
334.29 + *
334.30 + * If you wish your version of this file to be governed by only the CDDL
334.31 + * or only the GPL Version 2, indicate your decision by adding
334.32 + * "[Contributor] elects to include this software in this distribution
334.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
334.34 + * single choice of license, a recipient has the option to distribute
334.35 + * your version of this file under either the CDDL, the GPL Version 2 or
334.36 + * to extend the choice of license to its licensees as provided above.
334.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
334.38 + * Version 2 license, then the option applies only if the new code is
334.39 + * made subject to such option by the copyright holder.
334.40 + *
334.41 + * Contributor(s):
334.42 + *
334.43 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
334.44 + */
334.45 +
334.46 +package org.netbeans.modules.java.hints.jackpot.impl.pm;
334.47 +
334.48 +import com.sun.source.util.TreePath;
334.49 +import java.io.ByteArrayInputStream;
334.50 +import java.io.ByteArrayOutputStream;
334.51 +import java.io.File;
334.52 +import java.util.Arrays;
334.53 +import java.util.Collection;
334.54 +import java.util.Collections;
334.55 +import java.util.HashMap;
334.56 +import java.util.HashSet;
334.57 +import java.util.LinkedList;
334.58 +import java.util.List;
334.59 +import java.util.Map;
334.60 +import java.util.Map.Entry;
334.61 +import java.util.Set;
334.62 +import java.util.regex.Pattern;
334.63 +import javax.swing.text.Document;
334.64 +import org.netbeans.api.java.lexer.JavaTokenId;
334.65 +import org.netbeans.api.java.source.CompilationInfo;
334.66 +import org.netbeans.api.java.source.JavaSource;
334.67 +import org.netbeans.api.java.source.JavaSource.Phase;
334.68 +import org.netbeans.api.java.source.SourceUtilsTestUtil;
334.69 +import org.netbeans.api.java.source.TestUtilities;
334.70 +import org.netbeans.api.java.source.TreePathHandle;
334.71 +import org.netbeans.api.lexer.Language;
334.72 +import org.netbeans.junit.NbTestCase;
334.73 +import org.netbeans.modules.java.source.TreeLoader;
334.74 +import org.openide.cookies.EditorCookie;
334.75 +import org.openide.filesystems.FileObject;
334.76 +import org.openide.filesystems.FileUtil;
334.77 +import org.openide.loaders.DataObject;
334.78 +import static org.junit.Assert.*;
334.79 +import org.netbeans.modules.java.hints.spiimpl.pm.BulkSearch;
334.80 +import org.netbeans.modules.java.hints.spiimpl.pm.BulkSearch.BulkPattern;
334.81 +import org.netbeans.modules.java.hints.spiimpl.pm.BulkSearch.EncodingContext;
334.82 +
334.83 +/**
334.84 + *
334.85 + * @author lahvac
334.86 + */
334.87 +public abstract class BulkSearchTestPerformer extends NbTestCase {
334.88 +
334.89 + public BulkSearchTestPerformer(String name) {
334.90 + super(name);
334.91 + }
334.92 +
334.93 + @Override
334.94 + protected void setUp() throws Exception {
334.95 + super.setUp();
334.96 + SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml"}, new Object[0]);
334.97 + TreeLoader.DISABLE_CONFINEMENT_TEST = true;
334.98 + }
334.99 +
334.100 +// public static TestSuite suite() {
334.101 +// NbTestSuite s = new NbTestSuite();
334.102 +//
334.103 +// s.addTestSuite(NFABasedBulkSearchTest.class);
334.104 +//
334.105 +// return s;
334.106 +// }
334.107 +
334.108 + public void testSimple1() throws Exception {
334.109 + performTest("package test; public class Test { private void test() { System.err./**/println(\"\");}}",
334.110 + Collections.singletonMap("System.err.println(\"\")", Arrays.asList("System.err./**/println(\"\")")),
334.111 + Arrays.asList("System.err.println(\"\" + \"\")"));
334.112 + }
334.113 +
334.114 + public void testDontCare() throws Exception {
334.115 + performTest("package test; public class Test { private void test() { System.err./**/println(\"\" + \"\");}}",
334.116 + Collections.singletonMap("System.err.println($1)", Arrays.asList("System.err./**/println(\"\" + \"\")")),
334.117 + Collections.<String>emptyList());
334.118 + }
334.119 +
334.120 + public void testMemberSelectAndIdentifier() throws Exception {
334.121 + performTest("package test; public class Test { private static void test() { test();}}",
334.122 + Collections.singletonMap("test.Test.test()", Arrays.asList("test()")),
334.123 + Collections.<String>emptyList());
334.124 + }
334.125 +
334.126 + public void testUnpureMemberSelect() throws Exception {
334.127 + performTest("package test; public class Test { private static void test() { new StringBuilder().append(\"\");}}",
334.128 + Collections.<String, List<String>>emptyMap(),
334.129 + Arrays.asList("test.append(\"\")"));
334.130 + }
334.131 +
334.132 + public void testMemberSelectWithVariables1() throws Exception {
334.133 + performTest("package test; public class Test { private static void test() { new StringBuilder().append(\"\");}}",
334.134 + Collections.singletonMap("$0.append(\"\")", Arrays.asList("new StringBuilder().append(\"\")")),
334.135 + Collections.<String>emptyList());
334.136 + }
334.137 +
334.138 + public void testMemberSelectWithVariables2() throws Exception {
334.139 + performTest("package test; public class Test { private void append(char c) { append(\"\");}}",
334.140 + Collections.singletonMap("$0.append(\"\")", Arrays.asList("append(\"\")")),
334.141 + Collections.<String>emptyList());
334.142 + }
334.143 +
334.144 + public void testLocalVariables() throws Exception {
334.145 + performTest("package test; public class Test { private void test() { { int y; y = 1; } }}",
334.146 + Collections.singletonMap("{ int $1; $1 = 1; }", Arrays.asList("{ int y; y = 1; }")),
334.147 + Collections.<String>emptyList());
334.148 + }
334.149 +
334.150 + public void testAssert() throws Exception {
334.151 + performTest("package test; public class Test { private void test() { assert true : \"\"; }}",
334.152 + Collections.singletonMap("assert $1 : $2;", Arrays.asList("assert true : \"\";")),
334.153 + Collections.<String>emptyList());
334.154 + }
334.155 +
334.156 + public void testStatementAndSingleBlockStatementAreSame1() throws Exception {
334.157 + performTest("package test; public class Test { private void test() { { int y; { y = 1; } } }}",
334.158 + Collections.singletonMap("{ int $1; $1 = 1; }", Arrays.asList("{ int y; { y = 1; } }")),
334.159 + Collections.<String>emptyList());
334.160 + }
334.161 +
334.162 + public void testStatementAndSingleBlockStatementAreSame2() throws Exception {
334.163 + performTest("package test; public class Test { private void test() { { int y; y = 1; } }}",
334.164 + Collections.singletonMap("{ int $1; { $1 = 1; } }", Arrays.asList("{ int y; y = 1; }")),
334.165 + Collections.<String>emptyList());
334.166 + }
334.167 +
334.168 + public void testStatementVariables1() throws Exception {
334.169 + performTest("package test; public class Test { public int test1() { if (true) return 1; else return 2; } }",
334.170 + Collections.singletonMap("if ($1) $2; else $3;", Arrays.asList("if (true) return 1; else return 2;")),
334.171 + Collections.<String>emptyList());
334.172 + }
334.173 +
334.174 + public void testMultiStatementVariables1() throws Exception {
334.175 + performTest("package test; public class Test { public int test1(int i) { System.err.println(i); System.err.println(i); i = 3; System.err.println(i); System.err.println(i); return i; } }",
334.176 + Collections.singletonMap("{ $s1$; i = 3; $s2$; return i; }", Arrays.asList("{ System.err.println(i); System.err.println(i); i = 3; System.err.println(i); System.err.println(i); return i; }")),
334.177 + Collections.<String>emptyList());
334.178 + }
334.179 +
334.180 + public void testMultiStatementVariables2() throws Exception {
334.181 + performTest("package test; public class Test { public int test1(int i) { i = 3; return i; } }",
334.182 + Collections.singletonMap("{ $s1$; i = 3; $s2$; return i; }", Arrays.asList("{ i = 3; return i; }")),
334.183 + Collections.<String>emptyList());
334.184 + }
334.185 +
334.186 + public void testMultiStatementVariablesAndBlocks1() throws Exception {
334.187 + performTest("package test; public class Test { public void test1() { if (true) System.err.println(); } }",
334.188 + Collections.singletonMap("if ($c) {$s1$; System.err.println(); $s2$; }", Arrays.asList("if (true) System.err.println();")),
334.189 + Collections.<String>emptyList());
334.190 + }
334.191 +
334.192 + public void testMultiStatementVariablesAndBlocks2() throws Exception {
334.193 + performTest("package test; public class Test { public void test1() { if (true) System.err.println(); } }",
334.194 + Collections.singletonMap("if ($c) {$s1$; System.err.println(); }", Arrays.asList("if (true) System.err.println();")),
334.195 + Collections.<String>emptyList());
334.196 + }
334.197 +
334.198 + public void testMultiStatementVariablesAndBlocks3() throws Exception {
334.199 + performTest("package test; public class Test { public void test1() { if (true) System.err.println(); } }",
334.200 + Collections.singletonMap("if ($c) {System.err.println(); $s2$; }", Arrays.asList("if (true) System.err.println();")),
334.201 + Collections.<String>emptyList());
334.202 + }
334.203 +
334.204 + public void testMultiStatementVariablesAndBlocks4() throws Exception {
334.205 + performTest("package test; public class Test { public void test1() { if (true) System.err.println(); } }",
334.206 + Collections.singletonMap("{ $s1$; System.err.println(); $s2$; }", Arrays.asList("System.err.println();")),
334.207 + Collections.<String>emptyList());
334.208 + }
334.209 +
334.210 + public void testTwoPatterns() throws Exception {
334.211 + Map<String, List<String>> contained = new HashMap<String, List<String>>();
334.212 +
334.213 + contained.put("if ($a) $ret = $b; else $ret = $c;", Arrays.asList("if (b) q = 2; else q = 3;"));
334.214 + contained.put("{ $p$; $T $v; if($a) $v = $b; else $v = $c; $q$; }", Arrays.asList("{ int q; if (b) q = 2; else q = 3; }"));
334.215 +
334.216 + performTest("package test; public class Test { public void test1(boolean b) { int q; if (b) q = 2; else q = 3; } }",
334.217 + contained,
334.218 + Collections.<String>emptyList());
334.219 + }
334.220 +
334.221 + public void testEffectiveNewClass() throws Exception {
334.222 + performTest("package test; import javax.swing.ImageIcon; public class Test { public void test1(java.awt.Image i) { new ImageIcon(i); new String(i); } }",
334.223 + Collections.singletonMap("new javax.swing.ImageIcon($1)", Arrays.asList("new ImageIcon(i)")),
334.224 + Collections.<String>emptyList());
334.225 + }
334.226 +
334.227 + public void testSynchronizedAndMultiStatementVariables() throws Exception {
334.228 + performTest("package test; public class Test {public void test() { Object o = null; int i = 0; synchronized (o) {} } }",
334.229 + Collections.singletonMap("synchronized($var) {$stmts$;}", Arrays.asList("synchronized (o) {}")),
334.230 + Collections.<String>emptyList());
334.231 + }
334.232 +
334.233 + public void testJackpot30_2() throws Exception {
334.234 + String code = "package test;\n" +
334.235 + "public class Test {\n" +
334.236 + " private void m() {\n" +
334.237 + " a(c.i().getFileObject());\n" +
334.238 + " if (span != null && span[0] != (-1) && span[1] != (-1));\n" +
334.239 + " }\n" +
334.240 + "}\n";
334.241 +
334.242 + performTest(code,
334.243 + Collections.<String, List<String>>emptyMap(),
334.244 + Arrays.asList("$0.getFileObject($1)"));
334.245 + }
334.246 +
334.247 + public void testIdentifierInPureMemberSelect() throws Exception {
334.248 + String code = "package test;\n" +
334.249 + "public class Test {\n" +
334.250 + " public Test test;\n" +
334.251 + " public String name;\n" +
334.252 + " private void test() {\n" +
334.253 + " Test t = null;\n" +
334.254 + " String s = t.test.name;\n" +
334.255 + " }\n" +
334.256 + "}\n";
334.257 +
334.258 + performTest(code,
334.259 + Collections.singletonMap("$Test.test", Arrays.asList("test", "t.test")),
334.260 + Collections.<String>emptyList());
334.261 + }
334.262 +
334.263 + public void testNoExponentialTimeComplexity() throws Exception {
334.264 + try {
334.265 + String code = "package test;\n" +
334.266 + "public class Test {\n" +
334.267 + " private void test() {\n" +
334.268 + " Object o;\n" +
334.269 + " if(o == null) {\n" +
334.270 + " f(\"\");\n" +
334.271 + " }|\n" +
334.272 + " }\n" +
334.273 + "}";
334.274 + String pattern = "{ $p$; $T $v; if($a) $v = $b; else $v = $c; }";
334.275 +
334.276 + measure(code, "\na(\"\");", 5, pattern); //to load needed classes, etc.
334.277 +
334.278 + int rep = 1;
334.279 + long baseline;
334.280 +
334.281 + while (true) {
334.282 + baseline = measure(code, "\na(\"\");", rep, pattern);
334.283 +
334.284 + if (baseline >= 2000) {
334.285 + break;
334.286 + }
334.287 +
334.288 + rep *= 2;
334.289 + }
334.290 +
334.291 + long doubleSize = measure(code, "\na(\"\");", 2 * rep, pattern);
334.292 +
334.293 + assertTrue("baseline=" + baseline + ", actual=" + String.valueOf(doubleSize), doubleSize <= 4 * baseline);
334.294 + } catch (OutOfMemoryError oome) {
334.295 + //OK
334.296 + }
334.297 + }
334.298 +
334.299 + public void testMultiParameter1() throws Exception {
334.300 + performTest("package test; public class Test { { java.util.Arrays.asList(\"a\", \"b\", \"c\"); } }",
334.301 + Collections.singletonMap("java.util.Arrays.asList($params$)", Arrays.asList("java.util.Arrays.asList(\"a\", \"b\", \"c\")")),
334.302 + Collections.<String>emptyList());
334.303 + }
334.304 +
334.305 + public void testMultiParameter2() throws Exception {
334.306 + performTest("package test; public class Test { { java.util.Arrays.asList(); } }",
334.307 + Collections.singletonMap("java.util.Arrays.asList($params$)", Arrays.asList("java.util.Arrays.asList()")),
334.308 + Collections.<String>emptyList());
334.309 + }
334.310 +
334.311 + public void testTypeParameter() throws Exception {
334.312 + performTest("package test; public class Test { { java.util.Arrays.<String>asList(); } }",
334.313 + Collections.singletonMap("java.util.Arrays.<$1>asList($params$)", Arrays.asList("java.util.Arrays.<String>asList()")),
334.314 + Collections.<String>emptyList());
334.315 + }
334.316 +
334.317 + public void testField1() throws Exception {
334.318 + String code = "package test;\n" +
334.319 + "public class Test {\n" +
334.320 + " String name = null;\n" +
334.321 + "}\n";
334.322 +
334.323 + performTest(code,
334.324 + Collections.singletonMap("$modifiers$ java.lang.String $name = $initializer;", Arrays.asList("String name = null;")),
334.325 + Collections.<String>emptyList());
334.326 + }
334.327 +
334.328 + public void testField2() throws Exception {
334.329 + String code = "package test;\n" +
334.330 + "public class Test {\n" +
334.331 + " private String name = null;\n" +
334.332 + "}\n";
334.333 +
334.334 + performTest(code,
334.335 + Collections.singletonMap("$modifiers$ java.lang.String $name = $initializer;", Arrays.asList("private String name = null;")),
334.336 + Collections.<String>emptyList());
334.337 + }
334.338 +
334.339 + public void testMemberSelectWithVariable() throws Exception {
334.340 + String code = "package test;\n" +
334.341 + "import java.util.Arrays;\n" +
334.342 + "public class Test {" +
334.343 + " {\n" +
334.344 + " foo.bar(0, 3, 4);\n" +
334.345 + " }\n" +
334.346 + "}\n";
334.347 +
334.348 + performTest(code,
334.349 + Collections.singletonMap("$foo.$bar($p1, $p2$)", Arrays.asList("foo.bar(0, 3, 4)")),
334.350 + Collections.<String>emptyList());
334.351 + }
334.352 +
334.353 + public void testCheckIdentifiers1() throws Exception {
334.354 + String code = "package test;\n" +
334.355 + "import static java.util.Arrays.*;\n" +
334.356 + "public class Test {" +
334.357 + " {\n" +
334.358 + " toString(new int[] {0, 3, 4});\n" +
334.359 + " }\n" +
334.360 + "}\n";
334.361 +
334.362 + performTest(code,
334.363 + Collections.singletonMap("java.util.Arrays.toString($x)", Arrays.asList("toString(new int[] {0, 3, 4})")),
334.364 + Collections.<String>emptyList());
334.365 + }
334.366 +
334.367 + public void testCheckIdentifiers2() throws Exception {
334.368 + String code = "package test;\n" +
334.369 + "public class Test {" +
334.370 + " {\n" +
334.371 + " toString(new int[] {0, 3, 4});\n" +
334.372 + " }\n" +
334.373 + "}\n";
334.374 +
334.375 + performTest(code,
334.376 + Collections.<String, List<String>>emptyMap(),
334.377 + Collections.singletonList("java.util.Arrays.toString($x)"));
334.378 + }
334.379 +
334.380 + public void testCheckIdentifiers3() throws Exception {
334.381 + String code = "package test;\n" +
334.382 + "import static java.util.Arrays.*;\n" +
334.383 + "public class Test {" +
334.384 + " {\n" +
334.385 + " Foo.toString(new int[] {0, 3, 4});\n" +
334.386 + " }\n" +
334.387 + "}\n";
334.388 +
334.389 + performTest(code,
334.390 + Collections.<String, List<String>>emptyMap(),
334.391 + Collections.singletonList("java.util.Arrays.toString($x)"));
334.392 + }
334.393 +
334.394 + public void testCheckIdentifiers4() throws Exception {
334.395 + String code = "package test;\n" +
334.396 + "public class Test {" +
334.397 + " {\n" +
334.398 + " java.util.Arrays.toString(new int[] {0, 3, 4});\n" +
334.399 + " }\n" +
334.400 + "}\n";
334.401 +
334.402 + performTest(code,
334.403 + Collections.singletonMap("Arrays", Arrays.asList("java.util.Arrays")), //could be imported in the input pattern
334.404 + Collections.<String>emptyList());
334.405 + }
334.406 +
334.407 + public void testLambdaInput() throws Exception {
334.408 + String code = "package test; public class Test {public void test() { new java.io.FilenameFilter() { public boolean accept(java.io.File dir, String name) { return true; } }; } }";
334.409 +
334.410 + performTest(code,
334.411 + Collections.singletonMap("new $type() {public $retType $name($params$) { $body$; } }", Arrays.asList("new java.io.FilenameFilter() { public boolean accept(java.io.File dir, String name) { return true; } }")),
334.412 +
334.413 + Collections.<String>emptyList());
334.414 + }
334.415 +
334.416 + public void testDoubleCheckedLockingWithVariable() throws Exception {
334.417 + String dcl = "if (o == null) {\n" +
334.418 + " Object o1 = new Object();\n" +
334.419 + " synchronized (Test.class) {\n" +
334.420 + " if (o == null) {\n" +
334.421 + " o = o1;\n" +
334.422 + " }\n" +
334.423 + " }\n" +
334.424 + " }";
334.425 + String code = "package test;\n" +
334.426 + "public class Test {\n" +
334.427 + " private Object o;\n" +
334.428 + " private void t() {\n" +
334.429 + " " + dcl + "\n" +
334.430 + " }\n" +
334.431 + "}\n";
334.432 +
334.433 + performTest(code,
334.434 + Collections.singletonMap("if ($var == null) {$pref$; synchronized ($lock) { if ($var == null) { $init$; } } }", Arrays.asList(dcl)),
334.435 + Collections.<String>emptyList());
334.436 + }
334.437 +
334.438 + public void testMethodName1() throws Exception {
334.439 + String code = "package test; public class Test {public void test() { clone(); } }";
334.440 +
334.441 + performTest(code,
334.442 + Collections.<String, List<String>>emptyMap(),
334.443 + Collections.<String>singletonList("public void clone() {$stmts$;}"));
334.444 + }
334.445 +
334.446 + public void testMethodName2() throws Exception {
334.447 + String code = "package test; public class Test {public void test() { clone(); } }";
334.448 +
334.449 + performTest(code,
334.450 + Collections.singletonMap("public void test() {$stmts$;}", Arrays.asList("public void test() { clone(); }")),
334.451 + Collections.<String>emptyList());
334.452 + }
334.453 +
334.454 + private long measure(String baseCode, String toInsert, int repetitions, String pattern) throws Exception {
334.455 + int pos = baseCode.indexOf('|');
334.456 +
334.457 + assertTrue(pos != (-1));
334.458 +
334.459 + baseCode = baseCode.replaceAll(Pattern.quote("|"), "");
334.460 +
334.461 + StringBuilder code = new StringBuilder(baseCode.length() + repetitions * toInsert.length());
334.462 +
334.463 + code.append(baseCode);
334.464 +
334.465 + while (repetitions-- > 0) {
334.466 + code.insert(pos, toInsert);
334.467 + }
334.468 +
334.469 + long startTime = System.currentTimeMillis();
334.470 +
334.471 + performTest(code.toString(),
334.472 + Collections.<String, List<String>>emptyMap(),
334.473 + Arrays.asList(pattern));
334.474 +
334.475 + long endTime = System.currentTimeMillis();
334.476 +
334.477 + return endTime - startTime;
334.478 + }
334.479 +
334.480 + public void XtestMeasureTime() throws Exception {
334.481 + String code = TestUtilities.copyFileToString(new File("/usr/local/home/lahvac/src/nb//outgoing/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionProvider.java"));
334.482 + List<String> patterns = new LinkedList<String>();
334.483 +
334.484 + for (int cntr = 0; cntr < 1000; cntr++) {
334.485 + patterns.add("System.err.println($1)");
334.486 + }
334.487 +
334.488 + performTest(code,
334.489 + Collections.<String, List<String>>emptyMap(),
334.490 + patterns);
334.491 + }
334.492 +
334.493 + public void testMatches1() throws Exception {
334.494 + performMatchesTest("package test; public class Test { private void test() { f.isDirectory(); } }", Arrays.asList("$1.isDirectory()", "new ImageIcon($1)"), true);
334.495 + }
334.496 +
334.497 + public void testSerialization() throws Exception {
334.498 + String text = "package test; public class Test { public void test1(boolean b) { int q; if (b) q = 2; else q = 3; } }";
334.499 +
334.500 + prepareTest("test/Test.java", text);
334.501 +
334.502 + ByteArrayOutputStream out = new ByteArrayOutputStream();
334.503 + EncodingContext ec = new EncodingContext(out, false);
334.504 +
334.505 + createSearch().encode(info.getCompilationUnit(), ec);
334.506 +
334.507 + boolean matches = createSearch().matches(new ByteArrayInputStream(out.toByteArray()), createSearch().create(info, "{ $p$; $T $v; if($a) $v = $b; else $v = $c; $q$; }"));
334.508 +
334.509 + assertTrue(matches);
334.510 + }
334.511 +
334.512 + public void testFrequencies() throws Exception {
334.513 + String text = "package test; public class Test { public void test1(boolean b) { java.io.File f = null; f.isDirectory(); f.isDirectory(); new javax.swing.ImageIcon(null); } }";
334.514 +
334.515 + prepareTest("test/Test.java", text);
334.516 +
334.517 + ByteArrayOutputStream out = new ByteArrayOutputStream();
334.518 + EncodingContext ec = new EncodingContext(out, false);
334.519 +
334.520 + createSearch().encode(info.getCompilationUnit(), ec);
334.521 +
334.522 + Map<String, Integer> actual = createSearch().matchesWithFrequencies(new ByteArrayInputStream(out.toByteArray()), createSearch().create(info, "$1.isDirectory()", "new ImageIcon($1)"));
334.523 + Map<String, Integer> golden = new HashMap<String, Integer>();
334.524 +
334.525 + golden.put("$1.isDirectory()", 2);
334.526 + golden.put("new ImageIcon($1)", 1);
334.527 +
334.528 + assertEquals(golden, actual);
334.529 + }
334.530 +
334.531 + public void testPatternEncodingAndIdentifiers() throws Exception {
334.532 + String text = "package test; public class Test { }";
334.533 +
334.534 + prepareTest("test/Test.java", text);
334.535 +
334.536 + BulkPattern bp = createSearch().create(info, "$0.isDirectory()");
334.537 +
334.538 + assertEquals(Arrays.asList(new HashSet<String>(Arrays.asList("isDirectory"))), bp.getIdentifiers());
334.539 + //TODO: the actual code for kinds differs for NFABased search and REBased search:
334.540 +// assertEquals(Arrays.asList(new HashSet<String>(Arrays.asList(Kind.METHOD_INVOCATION.name()))), bp.getKinds());
334.541 + }
334.542 +
334.543 + protected abstract BulkSearch createSearch();
334.544 +
334.545 + private void performMatchesTest(String text, List<String> patterns, boolean golden) throws Exception {
334.546 + prepareTest("test/Test.java", text);
334.547 +
334.548 + BulkPattern p = createSearch().create(info, patterns);
334.549 +
334.550 + boolean result = createSearch().matches(info, new TreePath(info.getCompilationUnit()), p);
334.551 +
334.552 + assertEquals(golden, result);
334.553 + }
334.554 +
334.555 + private void performTest(String text, Map<String, List<String>> containedPatterns, Collection<String> notContainedPatterns) throws Exception {
334.556 + prepareTest("test/Test.java", text);
334.557 +
334.558 + List<String> patterns = new LinkedList<String>();
334.559 +
334.560 + patterns.addAll(containedPatterns.keySet());
334.561 + patterns.addAll(notContainedPatterns);
334.562 +
334.563 + long s1 = System.currentTimeMillis();
334.564 + BulkPattern p = createSearch().create(info, patterns);
334.565 + long e1 = System.currentTimeMillis();
334.566 +
334.567 +// System.err.println("create: " + (e1 - s1));
334.568 +
334.569 + long s2 = System.currentTimeMillis();
334.570 + Map<String, Collection<TreePath>> result = createSearch().match(info, new TreePath(info.getCompilationUnit()), p);
334.571 + long e2 = System.currentTimeMillis();
334.572 +
334.573 +// System.err.println("match: " + (e2 - s2));
334.574 +
334.575 + assertTrue(result.toString(), result.keySet().containsAll(containedPatterns.keySet()));
334.576 +
334.577 + for (Entry<String, Collection<TreePath>> e : result.entrySet()) {
334.578 + List<String> actual = new LinkedList<String>();
334.579 +
334.580 + for (TreePath tp : e.getValue()) {
334.581 + assertNotNull(TreePathHandle.create(tp, info).resolve(info));
334.582 +
334.583 + int start = (int) info.getTrees().getSourcePositions().getStartPosition(info.getCompilationUnit(), tp.getLeaf());
334.584 + int end = (int) info.getTrees().getSourcePositions().getEndPosition(info.getCompilationUnit(), tp.getLeaf());
334.585 +
334.586 + actual.add(info.getText().substring(start, end));
334.587 + }
334.588 +
334.589 + assertEquals(e.getKey(), containedPatterns.get(e.getKey()), actual);
334.590 + }
334.591 +
334.592 +
334.593 + Set<String> none = new HashSet<String>(result.keySet());
334.594 +
334.595 + none.retainAll(notContainedPatterns);
334.596 +
334.597 + assertTrue(none.isEmpty());
334.598 +
334.599 + if (!verifyIndexingData())
334.600 + return ;
334.601 +
334.602 + //ensure the returned identifiers/treeKinds are correct:
334.603 + ByteArrayOutputStream data = new ByteArrayOutputStream();
334.604 + EncodingContext ec = new EncodingContext(data, false);
334.605 +
334.606 + createSearch().encode(info.getCompilationUnit(), ec);
334.607 +
334.608 + for (int i = 0; i < containedPatterns.size(); i++) {
334.609 + assertTrue("expected: " + p.getIdentifiers().get(i) + ", but exist only: " + ec.getIdentifiers(), ec.getIdentifiers().containsAll(p.getIdentifiers().get(i)));
334.610 +
334.611 + for (List<String> phrase : p.getRequiredContent().get(i)) {
334.612 + assertTrue("expected: " + phrase + ", but exist only: " + ec.getContent() + "(all phrases: " + p.getRequiredContent().get(i) + ")", Collections.indexOfSubList(ec.getContent(), phrase) != (-1));
334.613 + }
334.614 + }
334.615 +
334.616 + data.close();
334.617 + assertEquals(!containedPatterns.isEmpty(), createSearch().matches(new ByteArrayInputStream(data.toByteArray()), p));
334.618 + }
334.619 +
334.620 + private void prepareTest(String fileName, String code) throws Exception {
334.621 + clearWorkDir();
334.622 +
334.623 + FileUtil.refreshFor(File.listRoots());
334.624 +
334.625 + FileObject workFO = FileUtil.toFileObject(getWorkDir());
334.626 +
334.627 + assertNotNull(workFO);
334.628 +
334.629 + workFO.refresh();
334.630 +
334.631 + sourceRoot = workFO.createFolder("src");
334.632 + FileObject buildRoot = workFO.createFolder("build");
334.633 + FileObject cache = workFO.createFolder("cache");
334.634 +
334.635 + FileObject data = FileUtil.createData(sourceRoot, fileName);
334.636 + File dataFile = FileUtil.toFile(data);
334.637 +
334.638 + assertNotNull(dataFile);
334.639 +
334.640 + TestUtilities.copyStringToFile(dataFile, code);
334.641 +
334.642 + SourceUtilsTestUtil.prepareTest(sourceRoot, buildRoot, cache);
334.643 +
334.644 + DataObject od = DataObject.find(data);
334.645 + EditorCookie ec = od.getLookup().lookup(EditorCookie.class);
334.646 +
334.647 + assertNotNull(ec);
334.648 +
334.649 + doc = ec.openDocument();
334.650 + doc.putProperty(Language.class, JavaTokenId.language());
334.651 +
334.652 + JavaSource js = JavaSource.forFileObject(data);
334.653 +
334.654 + assertNotNull(js);
334.655 +
334.656 + info = SourceUtilsTestUtil.getCompilationInfo(js, Phase.RESOLVED);
334.657 +
334.658 + assertNotNull(info);
334.659 + }
334.660 +
334.661 + private FileObject sourceRoot;
334.662 + private CompilationInfo info;
334.663 + private Document doc;
334.664 +
334.665 + protected boolean verifyIndexingData() {
334.666 + return true;
334.667 + }
334.668 +}
335.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
335.2 +++ b/remoting/common/borrowedtests/src/org/netbeans/modules/java/source/transform/Transformer.java Mon Mar 12 21:10:10 2012 +0100
335.3 @@ -0,0 +1,133 @@
335.4 +/*
335.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
335.6 + *
335.7 + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
335.8 + *
335.9 + * The contents of this file are subject to the terms of either the GNU
335.10 + * General Public License Version 2 only ("GPL") or the Common
335.11 + * Development and Distribution License("CDDL") (collectively, the
335.12 + * "License"). You may not use this file except in compliance with the
335.13 + * License. You can obtain a copy of the License at
335.14 + * http://www.netbeans.org/cddl-gplv2.html
335.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
335.16 + * specific language governing permissions and limitations under the
335.17 + * License. When distributing the software, include this License Header
335.18 + * Notice in each file and include the License file at
335.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
335.20 + * particular file as subject to the "Classpath" exception as provided
335.21 + * by Sun in the GPL Version 2 section of the License file that
335.22 + * accompanied this code. If applicable, add the following below the
335.23 + * License Header, with the fields enclosed by brackets [] replaced by
335.24 + * your own identifying information:
335.25 + * "Portions Copyrighted [year] [name of copyright owner]"
335.26 + *
335.27 + * Contributor(s):
335.28 + *
335.29 + * The Original Software is NetBeans. The Initial Developer of the Original
335.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
335.31 + * Microsystems, Inc. All Rights Reserved.
335.32 + *
335.33 + * If you wish your version of this file to be governed by only the CDDL
335.34 + * or only the GPL Version 2, indicate your decision by adding
335.35 + * "[Contributor] elects to include this software in this distribution
335.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
335.37 + * single choice of license, a recipient has the option to distribute
335.38 + * your version of this file under either the CDDL, the GPL Version 2 or
335.39 + * to extend the choice of license to its licensees as provided above.
335.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
335.41 + * Version 2 license, then the option applies only if the new code is
335.42 + * made subject to such option by the copyright holder.
335.43 + */
335.44 +
335.45 +package org.netbeans.modules.java.source.transform;
335.46 +
335.47 +import org.netbeans.modules.java.source.query.CommentHandler;
335.48 +import org.openide.util.NbBundle;
335.49 +import com.sun.source.tree.*;
335.50 +import com.sun.source.util.TreeScanner;
335.51 +import com.sun.tools.javac.model.JavacTypes;
335.52 +import com.sun.tools.javac.util.Context;
335.53 +import java.util.List;
335.54 +import java.util.logging.*;
335.55 +import javax.lang.model.util.Types;
335.56 +import org.netbeans.api.java.source.WorkingCopy;
335.57 +import org.netbeans.modules.java.source.builder.ASTService;
335.58 +import org.netbeans.modules.java.source.builder.CommentHandlerService;
335.59 +import org.netbeans.modules.java.source.builder.TreeFactory;
335.60 +
335.61 +/**
335.62 + * A Transformer is an Query that modifies the model. Model transformation
335.63 + * is done by a supplied ImmutableTreeTranslator implementation. A new context
335.64 + * is set upon successful completion of this Transformer.
335.65 + */
335.66 +public abstract class Transformer<R, P> extends TreeScanner<R,P> {
335.67 +
335.68 + CommentHandler commentHandler;
335.69 + public TreeFactory make;
335.70 + protected WorkingCopy copy;
335.71 + protected String refactoringDescription;
335.72 + protected Types types; // used by tests
335.73 + private String failureMessage;
335.74 + protected ASTService model;
335.75 +
335.76 + static final Logger logger = Logger.getLogger("org.netbeans.modules.java.source");
335.77 +
335.78 + public void init() {
335.79 + }
335.80 +
335.81 + /**
335.82 + * Initialize and associate this Query instance with the
335.83 + * specified QueryEnvironment.
335.84 + */
335.85 + public void attach(Context context, WorkingCopy copy) {
335.86 + make = TreeFactory.instance(context);
335.87 + types = JavacTypes.instance(context);
335.88 + commentHandler = CommentHandlerService.instance(context);
335.89 + model = ASTService.instance(context);
335.90 + this.copy = copy;
335.91 + }
335.92 +
335.93 + /**
335.94 + * Release any instance data created during attach() invocation. This
335.95 + * is necessary because the Java reflection support may cache created
335.96 + * instances, preventing the session data from being garbage-collected.
335.97 + */
335.98 + public void release() {
335.99 + //changes.release(); // enable when async results are supported
335.100 + //result.release()
335.101 + make = null;
335.102 + types = null;
335.103 + this.copy = null;
335.104 + }
335.105 +
335.106 + public void destroy() {}
335.107 +
335.108 + public String getRefactoringDescription() {
335.109 + return refactoringDescription != null ? refactoringDescription : "Unnamed Refactoring";
335.110 + }
335.111 +
335.112 + public void setRefactoringDescription(String description) {
335.113 + refactoringDescription = description;
335.114 + }
335.115 +
335.116 + public void apply(Tree t) {
335.117 + t.accept(this, null);
335.118 + }
335.119 +
335.120 + String getString(String key) {
335.121 + return NbBundle.getBundle(Transformer.class).getString(key); //NOI18N
335.122 + }
335.123 +
335.124 + /**
335.125 + * True if no translation failures occurred.
335.126 + */
335.127 + protected boolean translationSuccessful() {
335.128 + return failureMessage == null;
335.129 + }
335.130 +
335.131 + public final void copyCommentTo(Tree from, Tree to) {
335.132 + if (from != null && to != null) {
335.133 + commentHandler.copyComments(from, to);
335.134 + }
335.135 + }
335.136 +}
336.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
336.2 +++ b/remoting/common/borrowedtests/src/org/netbeans/modules/java/source/usages/IndexUtil.java Mon Mar 12 21:10:10 2012 +0100
336.3 @@ -0,0 +1,58 @@
336.4 +/*
336.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
336.6 + *
336.7 + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
336.8 + *
336.9 + * The contents of this file are subject to the terms of either the GNU
336.10 + * General Public License Version 2 only ("GPL") or the Common
336.11 + * Development and Distribution License("CDDL") (collectively, the
336.12 + * "License"). You may not use this file except in compliance with the
336.13 + * License. You can obtain a copy of the License at
336.14 + * http://www.netbeans.org/cddl-gplv2.html
336.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
336.16 + * specific language governing permissions and limitations under the
336.17 + * License. When distributing the software, include this License Header
336.18 + * Notice in each file and include the License file at
336.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
336.20 + * particular file as subject to the "Classpath" exception as provided
336.21 + * by Sun in the GPL Version 2 section of the License file that
336.22 + * accompanied this code. If applicable, add the following below the
336.23 + * License Header, with the fields enclosed by brackets [] replaced by
336.24 + * your own identifying information:
336.25 + * "Portions Copyrighted [year] [name of copyright owner]"
336.26 + *
336.27 + * Contributor(s):
336.28 + *
336.29 + * The Original Software is NetBeans. The Initial Developer of the Original
336.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
336.31 + * Microsystems, Inc. All Rights Reserved.
336.32 + *
336.33 + * If you wish your version of this file to be governed by only the CDDL
336.34 + * or only the GPL Version 2, indicate your decision by adding
336.35 + * "[Contributor] elects to include this software in this distribution
336.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
336.37 + * single choice of license, a recipient has the option to distribute
336.38 + * your version of this file under either the CDDL, the GPL Version 2 or
336.39 + * to extend the choice of license to its licensees as provided above.
336.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
336.41 + * Version 2 license, then the option applies only if the new code is
336.42 + * made subject to such option by the copyright holder.
336.43 + */
336.44 +
336.45 +package org.netbeans.modules.java.source.usages;
336.46 +
336.47 +import java.io.File;
336.48 +import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
336.49 +import org.openide.filesystems.FileUtil;
336.50 +
336.51 +/**
336.52 + *
336.53 + * @author Tomas Zezula
336.54 + */
336.55 +public class IndexUtil {
336.56 +
336.57 + public static void setCacheFolder (final File cacheFolder) {
336.58 + CacheFolder.setCacheFolder(FileUtil.toFileObject(cacheFolder));
336.59 + }
336.60 +
336.61 +}
337.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
337.2 +++ b/remoting/common/borrowedtests/src/org/netbeans/modules/parsing/impl/indexing/MimeTypes.java Mon Mar 12 21:10:10 2012 +0100
337.3 @@ -0,0 +1,66 @@
337.4 +/*
337.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
337.6 + *
337.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
337.8 + *
337.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
337.10 + * Other names may be trademarks of their respective owners.
337.11 + *
337.12 + * The contents of this file are subject to the terms of either the GNU
337.13 + * General Public License Version 2 only ("GPL") or the Common
337.14 + * Development and Distribution License("CDDL") (collectively, the
337.15 + * "License"). You may not use this file except in compliance with the
337.16 + * License. You can obtain a copy of the License at
337.17 + * http://www.netbeans.org/cddl-gplv2.html
337.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
337.19 + * specific language governing permissions and limitations under the
337.20 + * License. When distributing the software, include this License Header
337.21 + * Notice in each file and include the License file at
337.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
337.23 + * particular file as subject to the "Classpath" exception as provided
337.24 + * by Oracle in the GPL Version 2 section of the License file that
337.25 + * accompanied this code. If applicable, add the following below the
337.26 + * License Header, with the fields enclosed by brackets [] replaced by
337.27 + * your own identifying information:
337.28 + * "Portions Copyrighted [year] [name of copyright owner]"
337.29 + *
337.30 + * If you wish your version of this file to be governed by only the CDDL
337.31 + * or only the GPL Version 2, indicate your decision by adding
337.32 + * "[Contributor] elects to include this software in this distribution
337.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
337.34 + * single choice of license, a recipient has the option to distribute
337.35 + * your version of this file under either the CDDL, the GPL Version 2 or
337.36 + * to extend the choice of license to its licensees as provided above.
337.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
337.38 + * Version 2 license, then the option applies only if the new code is
337.39 + * made subject to such option by the copyright holder.
337.40 + *
337.41 + * Contributor(s):
337.42 + *
337.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
337.44 + */
337.45 +package org.netbeans.modules.parsing.impl.indexing;
337.46 +
337.47 +import java.util.Set;
337.48 +import org.netbeans.api.annotations.common.CheckForNull;
337.49 +import org.netbeans.api.annotations.common.NonNull;
337.50 +import org.openide.util.Parameters;
337.51 +
337.52 +/**
337.53 + *
337.54 + * @author Tomas Zezula
337.55 + */
337.56 +public class MimeTypes {
337.57 +
337.58 + private MimeTypes() {}
337.59 +
337.60 + public static void setAllMimeTypes(@NonNull final Set<String> allMimeTypes) {
337.61 + Parameters.notNull("allMimeTypes", allMimeTypes); //NOI18N
337.62 + Util.allMimeTypes = allMimeTypes;
337.63 + }
337.64 +
337.65 + @CheckForNull
337.66 + public static Set<String> getAllMimeTypes() {
337.67 + return Util.allMimeTypes;
337.68 + }
337.69 +}
338.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
338.2 +++ b/remoting/common/borrowedtests/src/org/openide/util/test/AnnotationProcessorTestUtils.java Mon Mar 12 21:10:10 2012 +0100
338.3 @@ -0,0 +1,139 @@
338.4 +/*
338.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
338.6 + *
338.7 + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
338.8 + *
338.9 + * The contents of this file are subject to the terms of either the GNU
338.10 + * General Public License Version 2 only ("GPL") or the Common
338.11 + * Development and Distribution License("CDDL") (collectively, the
338.12 + * "License"). You may not use this file except in compliance with the
338.13 + * License. You can obtain a copy of the License at
338.14 + * http://www.netbeans.org/cddl-gplv2.html
338.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
338.16 + * specific language governing permissions and limitations under the
338.17 + * License. When distributing the software, include this License Header
338.18 + * Notice in each file and include the License file at
338.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
338.20 + * particular file as subject to the "Classpath" exception as provided
338.21 + * by Sun in the GPL Version 2 section of the License file that
338.22 + * accompanied this code. If applicable, add the following below the
338.23 + * License Header, with the fields enclosed by brackets [] replaced by
338.24 + * your own identifying information:
338.25 + * "Portions Copyrighted [year] [name of copyright owner]"
338.26 + *
338.27 + * If you wish your version of this file to be governed by only the CDDL
338.28 + * or only the GPL Version 2, indicate your decision by adding
338.29 + * "[Contributor] elects to include this software in this distribution
338.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
338.31 + * single choice of license, a recipient has the option to distribute
338.32 + * your version of this file under either the CDDL, the GPL Version 2 or
338.33 + * to extend the choice of license to its licensees as provided above.
338.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
338.35 + * Version 2 license, then the option applies only if the new code is
338.36 + * made subject to such option by the copyright holder.
338.37 + *
338.38 + * Contributor(s):
338.39 + *
338.40 + * Portions Copyrighted 2008 Sun Microsystems, Inc.
338.41 + */
338.42 +
338.43 +package org.openide.util.test;
338.44 +
338.45 +import java.io.File;
338.46 +import java.io.FileWriter;
338.47 +import java.io.IOException;
338.48 +import java.io.OutputStream;
338.49 +import java.io.PrintWriter;
338.50 +import java.io.Writer;
338.51 +import java.util.ArrayList;
338.52 +import java.util.List;
338.53 +import java.util.regex.Pattern;
338.54 +import javax.tools.JavaCompiler;
338.55 +import javax.tools.ToolProvider;
338.56 +import junit.framework.Assert;
338.57 +
338.58 +/**
338.59 + * Utilities useful to those testing JSR 269 annotation processors.
338.60 + * <p>If you just want to test that the output of the processor is correct,
338.61 + * you do not need to do anything special:
338.62 + * just use the annotation on some sample classes nested inside your unit test.
338.63 + * They will be processed, and you check that your SPI loads them correctly.
338.64 + * These utilities are useful mainly in case you want to check that the processor
338.65 + * rejects erroneous sources, and that any messages it prints are reasonable;
338.66 + * that it behaves correctly on incremental compilations; etc.
338.67 + */
338.68 +public class AnnotationProcessorTestUtils {
338.69 +
338.70 + private AnnotationProcessorTestUtils() {}
338.71 +
338.72 + /**
338.73 + * Create a source file.
338.74 + * @param dir source root
338.75 + * @param clazz a fully-qualified class name
338.76 + * @param content lines of text (skip package decl)
338.77 + */
338.78 + public static void makeSource(File dir, String clazz, String... content) throws IOException {
338.79 + File f = new File(dir, clazz.replace('.', File.separatorChar) + ".java");
338.80 + f.getParentFile().mkdirs();
338.81 + Writer w = new FileWriter(f);
338.82 + try {
338.83 + PrintWriter pw = new PrintWriter(w);
338.84 + String pkg = clazz.replaceFirst("\\.[^.]+$", "");
338.85 + if (!pkg.equals(clazz)) {
338.86 + pw.println("package " + pkg + ";");
338.87 + }
338.88 + for (String line : content) {
338.89 + pw.println(line);
338.90 + }
338.91 + pw.flush();
338.92 + } finally {
338.93 + w.close();
338.94 + }
338.95 + }
338.96 +
338.97 + /**
338.98 + * Run the Java compiler.
338.99 + * (A JSR 199 implementation must be available.)
338.100 + * @param src a source root (runs javac on all *.java it finds matching {@code srcIncludes})
338.101 + * @param srcIncludes a pattern of source files names without path to compile (useful for testing incremental compiles), or null for all
338.102 + * @param dest a dest dir to compile classes to
338.103 + * @param cp classpath entries; if null, use Java classpath of test
338.104 + * @param stderr output stream to print messages to, or null for test console (i.e. do not capture)
338.105 + * @return true if compilation succeeded, false if it failed
338.106 + */
338.107 + public static boolean runJavac(File src, String srcIncludes, File dest, File[] cp, OutputStream stderr) {
338.108 + List<String> args = new ArrayList<String>();
338.109 + args.add("-classpath");
338.110 + if (cp != null) {
338.111 + StringBuffer b = new StringBuffer();
338.112 + for (File entry : cp) {
338.113 + b.append(File.pathSeparatorChar);
338.114 + b.append(entry.getAbsolutePath());
338.115 + }
338.116 + args.add(b.toString());
338.117 + } else {
338.118 + args.add(System.getProperty("java.class.path"));
338.119 + }
338.120 + args.add("-d");
338.121 + args.add(dest.getAbsolutePath());
338.122 + args.add("-sourcepath");
338.123 + args.add(src.getAbsolutePath());
338.124 + dest.mkdirs();
338.125 + scan(args, src, srcIncludes);
338.126 + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
338.127 + Assert.assertNotNull("no JSR 199 compiler impl found; try e.g.: " +
338.128 + "test.unit.run.cp.extra=${nb_all}/apisupport.harness/external/openjdk-javac-6-b12.jar", compiler);
338.129 + //System.err.println("running javac with args: " + args);
338.130 + return compiler.run(null, null, stderr, args.toArray(new String[args.size()])) == 0;
338.131 + }
338.132 + private static void scan(List<String> names, File f, String includes) {
338.133 + if (f.isDirectory()) {
338.134 + for (File kid : f.listFiles()) {
338.135 + scan(names, kid, includes);
338.136 + }
338.137 + } else if (f.getName().endsWith(".java") && (includes == null || Pattern.compile(includes).matcher(f.getName()).find())) {
338.138 + names.add(f.getAbsolutePath());
338.139 + }
338.140 + }
338.141 +
338.142 +}
339.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
339.2 +++ b/remoting/common/build.xml Mon Mar 12 21:10:10 2012 +0100
339.3 @@ -0,0 +1,8 @@
339.4 +<?xml version="1.0" encoding="UTF-8"?>
339.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
339.6 +<!-- for some information on what you could do (e.g. targets to override). -->
339.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
339.8 +<project name="base" basedir=".">
339.9 + <description>Builds the module suite base.</description>
339.10 + <import file="nbproject/build-impl.xml"/>
339.11 +</project>
340.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
340.2 +++ b/remoting/common/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
340.3 @@ -0,0 +1,50 @@
340.4 +<?xml version="1.0" encoding="UTF-8"?>
340.5 +<!--
340.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
340.7 +*** EDIT ../build.xml INSTEAD ***
340.8 +-->
340.9 +<project name="base-impl" basedir=".." xmlns:sproject="http://www.netbeans.org/ns/nb-module-suite-project/1">
340.10 + <fail message="Please build using Ant 1.7.1 or higher.">
340.11 + <condition>
340.12 + <not>
340.13 + <antversion atleast="1.7.1"/>
340.14 + </not>
340.15 + </condition>
340.16 + </fail>
340.17 + <property file="nbproject/private/platform-private.properties"/>
340.18 + <property file="nbproject/platform.properties"/>
340.19 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-suite-project/1">
340.20 + <attribute name="name"/>
340.21 + <attribute name="value"/>
340.22 + <sequential>
340.23 + <property name="@{name}" value="${@{value}}"/>
340.24 + </sequential>
340.25 + </macrodef>
340.26 + <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-suite-project/1">
340.27 + <attribute name="property"/>
340.28 + <attribute name="value"/>
340.29 + <sequential>
340.30 + <property name="@{property}" value="@{value}"/>
340.31 + </sequential>
340.32 + </macrodef>
340.33 + <property file="${user.properties.file}"/>
340.34 + <sproject:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir"/>
340.35 + <sproject:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir"/>
340.36 + <sproject:evalprops property="cluster.path.evaluated" value="${cluster.path}"/>
340.37 + <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
340.38 + <condition>
340.39 + <not>
340.40 + <contains string="${cluster.path.evaluated}" substring="platform"/>
340.41 + </not>
340.42 + </condition>
340.43 + </fail>
340.44 + <ant antfile="nbproject/platform.xml"/>
340.45 + <fail message="Cannot find NetBeans build harness. ${line.separator}Check that nbplatform.${nbplatform.active}.netbeans.dest.dir and nbplatform.${nbplatform.active}.harness.dir are defined. ${line.separator}On a developer machine these are normally defined in ${user.properties.file}=${netbeans.user}/build.properties ${line.separator}but for automated builds you should pass these properties to Ant explicitly. ${line.separator}You may instead download the harness and platform: -Dbootstrap.url=.../tasks.jar -Dautoupdate.catalog.url=.../updates.xml">
340.46 + <condition>
340.47 + <not>
340.48 + <available file="${harness.dir}/suite.xml"/>
340.49 + </not>
340.50 + </condition>
340.51 + </fail>
340.52 + <import file="${harness.dir}/suite.xml"/>
340.53 +</project>
341.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
341.2 +++ b/remoting/common/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
341.3 @@ -0,0 +1,11 @@
341.4 +build.xml.data.CRC32=8c462dad
341.5 +build.xml.script.CRC32=263c4f10
341.6 +build.xml.stylesheet.CRC32=eaf9f76a@2.49
341.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
341.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
341.9 +nbproject/build-impl.xml.data.CRC32=8c462dad
341.10 +nbproject/build-impl.xml.script.CRC32=64b5d2e4
341.11 +nbproject/build-impl.xml.stylesheet.CRC32=0f381476@2.49
341.12 +nbproject/platform.xml.data.CRC32=8c462dad
341.13 +nbproject/platform.xml.script.CRC32=db9e1f43
341.14 +nbproject/platform.xml.stylesheet.CRC32=df8ac4dd@2.49
342.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
342.2 +++ b/remoting/common/nbproject/platform.properties Mon Mar 12 21:10:10 2012 +0100
342.3 @@ -0,0 +1,12 @@
342.4 +cluster.path=\
342.5 + ${nbplatform.active.dir}/apisupport:\
342.6 + ${nbplatform.active.dir}/profiler:\
342.7 + ${nbplatform.active.dir}/ide:\
342.8 + ${nbplatform.active.dir}/nb:\
342.9 + ${nbplatform.active.dir}/java:\
342.10 + ${nbplatform.active.dir}/harness:\
342.11 + ${nbplatform.active.dir}/javafx:\
342.12 + ${nbplatform.active.dir}/websvccommon:\
342.13 + ${nbplatform.active.dir}/platform:\
342.14 + ${nbplatform.active.dir}/extra
342.15 +nbplatform.active=default
343.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
343.2 +++ b/remoting/common/nbproject/platform.xml Mon Mar 12 21:10:10 2012 +0100
343.3 @@ -0,0 +1,34 @@
343.4 +<?xml version="1.0" encoding="UTF-8"?>
343.5 +<project name="platform" default="download" basedir="..">
343.6 + <condition property="download.required">
343.7 + <and>
343.8 + <not>
343.9 + <available file="${harness.dir}/suite.xml"/>
343.10 + </not>
343.11 + <isset property="bootstrap.url"/>
343.12 + <isset property="autoupdate.catalog.url"/>
343.13 + </and>
343.14 + </condition>
343.15 + <target name="download" if="download.required">
343.16 + <mkdir dir="${harness.dir}"/>
343.17 + <pathconvert pathsep="|" property="download.clusters">
343.18 + <mapper type="flatten"/>
343.19 + <path path="${cluster.path}"/>
343.20 + </pathconvert>
343.21 + <property name="disabled.modules" value=""/>
343.22 + <pathconvert property="module.includes" pathsep="">
343.23 + <mapper type="glob" from="${basedir}${file.separator}*" to="(?!\Q*\E)"/>
343.24 + <path>
343.25 + <filelist files="${disabled.modules}" dir="."/>
343.26 + </path>
343.27 + </pathconvert>
343.28 + <echo message="Downloading clusters ${download.clusters}"/>
343.29 + <property name="tasks.jar" location="${java.io.tmpdir}/tasks.jar"/>
343.30 + <get src="${bootstrap.url}" dest="${tasks.jar}" usetimestamp="true" verbose="true"/>
343.31 + <taskdef name="autoupdate" classname="org.netbeans.nbbuild.AutoUpdate" classpath="${tasks.jar}"/>
343.32 + <autoupdate installdir="${nbplatform.active.dir}" updatecenter="${autoupdate.catalog.url}">
343.33 + <modules includes="${module.includes}.*" clusters="${download.clusters}"/>
343.34 + <modules includes="org[.]netbeans[.]modules[.]apisupport[.]harness" clusters="harness"/>
343.35 + </autoupdate>
343.36 + </target>
343.37 +</project>
344.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
344.2 +++ b/remoting/common/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
344.3 @@ -0,0 +1,8 @@
344.4 +app.title=common
344.5 +modules=\
344.6 + ${project.org.netbeans.modules.jackpot30.common}:\
344.7 + ${project.org.netbeans.modules.jackpot30.test.borrowed}:\
344.8 + ${project.org.netbeans.modules.jackpot30.common.test}
344.9 +project.org.netbeans.modules.jackpot30.common=api
344.10 +project.org.netbeans.modules.jackpot30.common.test=test
344.11 +project.org.netbeans.modules.jackpot30.test.borrowed=borrowedtests
345.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
345.2 +++ b/remoting/common/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
345.3 @@ -0,0 +1,9 @@
345.4 +<?xml version="1.0" encoding="UTF-8"?>
345.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
345.6 + <type>org.netbeans.modules.apisupport.project.suite</type>
345.7 + <configuration>
345.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-suite-project/1">
345.9 + <name>base</name>
345.10 + </data>
345.11 + </configuration>
345.12 +</project>
346.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
346.2 +++ b/remoting/common/test/build.xml Mon Mar 12 21:10:10 2012 +0100
346.3 @@ -0,0 +1,8 @@
346.4 +<?xml version="1.0" encoding="UTF-8"?>
346.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
346.6 +<!-- for some information on what you could do (e.g. targets to override). -->
346.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
346.8 +<project name="org.netbeans.modules.jackpot30.common.test" default="netbeans" basedir=".">
346.9 + <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.common.test.</description>
346.10 + <import file="nbproject/build-impl.xml"/>
346.11 +</project>
347.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
347.2 +++ b/remoting/common/test/manifest.mf Mon Mar 12 21:10:10 2012 +0100
347.3 @@ -0,0 +1,5 @@
347.4 +Manifest-Version: 1.0
347.5 +OpenIDE-Module: org.netbeans.modules.jackpot30.common.test
347.6 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/common/test/Bundle.properties
347.7 +OpenIDE-Module-Specification-Version: 1.0
347.8 +
348.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
348.2 +++ b/remoting/common/test/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
348.3 @@ -0,0 +1,45 @@
348.4 +<?xml version="1.0" encoding="UTF-8"?>
348.5 +<!--
348.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
348.7 +*** EDIT ../build.xml INSTEAD ***
348.8 +-->
348.9 +<project name="org.netbeans.modules.jackpot30.common.test-impl" basedir="..">
348.10 + <fail message="Please build using Ant 1.7.1 or higher.">
348.11 + <condition>
348.12 + <not>
348.13 + <antversion atleast="1.7.1"/>
348.14 + </not>
348.15 + </condition>
348.16 + </fail>
348.17 + <property file="nbproject/private/suite-private.properties"/>
348.18 + <property file="nbproject/suite.properties"/>
348.19 + <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
348.20 + <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
348.21 + <property file="${suite.dir}/nbproject/platform.properties"/>
348.22 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
348.23 + <attribute name="name"/>
348.24 + <attribute name="value"/>
348.25 + <sequential>
348.26 + <property name="@{name}" value="${@{value}}"/>
348.27 + </sequential>
348.28 + </macrodef>
348.29 + <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
348.30 + <attribute name="property"/>
348.31 + <attribute name="value"/>
348.32 + <sequential>
348.33 + <property name="@{property}" value="@{value}"/>
348.34 + </sequential>
348.35 + </macrodef>
348.36 + <property file="${user.properties.file}"/>
348.37 + <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
348.38 + <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
348.39 + <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
348.40 + <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
348.41 + <condition>
348.42 + <not>
348.43 + <contains string="${cluster.path.evaluated}" substring="platform"/>
348.44 + </not>
348.45 + </condition>
348.46 + </fail>
348.47 + <import file="${harness.dir}/build.xml"/>
348.48 +</project>
349.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
349.2 +++ b/remoting/common/test/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
349.3 @@ -0,0 +1,8 @@
349.4 +build.xml.data.CRC32=4735325c
349.5 +build.xml.script.CRC32=b3a2b248
349.6 +build.xml.stylesheet.CRC32=a56c6a5b@2.49
349.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
349.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
349.9 +nbproject/build-impl.xml.data.CRC32=4735325c
349.10 +nbproject/build-impl.xml.script.CRC32=4e8c4baf
349.11 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.49
350.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
350.2 +++ b/remoting/common/test/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
350.3 @@ -0,0 +1,3 @@
350.4 +is.autoload=true
350.5 +javac.source=1.6
350.6 +javac.compilerargs=-Xlint -Xlint:-serial
351.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
351.2 +++ b/remoting/common/test/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
351.3 @@ -0,0 +1,339 @@
351.4 +<?xml version="1.0" encoding="UTF-8"?>
351.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
351.6 + <type>org.netbeans.modules.apisupport.project</type>
351.7 + <configuration>
351.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
351.9 + <code-name-base>org.netbeans.modules.jackpot30.common.test</code-name-base>
351.10 + <suite-component/>
351.11 + <module-dependencies>
351.12 + <dependency>
351.13 + <code-name-base>org.netbeans.api.annotations.common</code-name-base>
351.14 + <build-prerequisite/>
351.15 + <compile-dependency/>
351.16 + <run-dependency>
351.17 + <release-version>1</release-version>
351.18 + <specification-version>1.13</specification-version>
351.19 + </run-dependency>
351.20 + </dependency>
351.21 + <dependency>
351.22 + <code-name-base>org.netbeans.api.java</code-name-base>
351.23 + <build-prerequisite/>
351.24 + <compile-dependency/>
351.25 + <run-dependency>
351.26 + <release-version>1</release-version>
351.27 + <specification-version>1.31</specification-version>
351.28 + </run-dependency>
351.29 + </dependency>
351.30 + <dependency>
351.31 + <code-name-base>org.netbeans.api.java.classpath</code-name-base>
351.32 + <build-prerequisite/>
351.33 + <compile-dependency/>
351.34 + <run-dependency>
351.35 + <release-version>1</release-version>
351.36 + <specification-version>1.27</specification-version>
351.37 + </run-dependency>
351.38 + </dependency>
351.39 + <dependency>
351.40 + <code-name-base>org.netbeans.api.progress</code-name-base>
351.41 + <build-prerequisite/>
351.42 + <compile-dependency/>
351.43 + <run-dependency>
351.44 + <release-version>1</release-version>
351.45 + <specification-version>1.22</specification-version>
351.46 + </run-dependency>
351.47 + </dependency>
351.48 + <dependency>
351.49 + <code-name-base>org.netbeans.core.startup</code-name-base>
351.50 + <build-prerequisite/>
351.51 + <compile-dependency/>
351.52 + <run-dependency>
351.53 + <release-version>1</release-version>
351.54 + <implementation-version/>
351.55 + </run-dependency>
351.56 + </dependency>
351.57 + <dependency>
351.58 + <code-name-base>org.netbeans.insane</code-name-base>
351.59 + <build-prerequisite/>
351.60 + <compile-dependency/>
351.61 + <run-dependency>
351.62 + <release-version>1</release-version>
351.63 + <implementation-version/>
351.64 + </run-dependency>
351.65 + </dependency>
351.66 + <dependency>
351.67 + <code-name-base>org.netbeans.libs.javacapi</code-name-base>
351.68 + <build-prerequisite/>
351.69 + <compile-dependency/>
351.70 + <run-dependency>
351.71 + <specification-version>7.1.0.2</specification-version>
351.72 + </run-dependency>
351.73 + </dependency>
351.74 + <dependency>
351.75 + <code-name-base>org.netbeans.libs.javacimpl</code-name-base>
351.76 + <build-prerequisite/>
351.77 + <compile-dependency/>
351.78 + <run-dependency>
351.79 + <release-version>1</release-version>
351.80 + <implementation-version/>
351.81 + </run-dependency>
351.82 + </dependency>
351.83 + <dependency>
351.84 + <code-name-base>org.netbeans.libs.junit4</code-name-base>
351.85 + <build-prerequisite/>
351.86 + <compile-dependency/>
351.87 + <run-dependency>
351.88 + <specification-version>1.12</specification-version>
351.89 + </run-dependency>
351.90 + </dependency>
351.91 + <dependency>
351.92 + <code-name-base>org.netbeans.libs.lucene</code-name-base>
351.93 + <build-prerequisite/>
351.94 + <compile-dependency/>
351.95 + <run-dependency>
351.96 + <release-version>1-3</release-version>
351.97 + <specification-version>2.13</specification-version>
351.98 + </run-dependency>
351.99 + </dependency>
351.100 + <dependency>
351.101 + <code-name-base>org.netbeans.modules.editor.lib2</code-name-base>
351.102 + <build-prerequisite/>
351.103 + <compile-dependency/>
351.104 + <run-dependency>
351.105 + <release-version>1</release-version>
351.106 + <specification-version>1.35.0.5</specification-version>
351.107 + </run-dependency>
351.108 + </dependency>
351.109 + <dependency>
351.110 + <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
351.111 + <build-prerequisite/>
351.112 + <compile-dependency/>
351.113 + <run-dependency>
351.114 + <release-version>1</release-version>
351.115 + <specification-version>1.20</specification-version>
351.116 + </run-dependency>
351.117 + </dependency>
351.118 + <dependency>
351.119 + <code-name-base>org.netbeans.modules.editor.util</code-name-base>
351.120 + <build-prerequisite/>
351.121 + <compile-dependency/>
351.122 + <run-dependency>
351.123 + <release-version>1</release-version>
351.124 + <specification-version>1.39</specification-version>
351.125 + </run-dependency>
351.126 + </dependency>
351.127 + <dependency>
351.128 + <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
351.129 + <build-prerequisite/>
351.130 + <compile-dependency/>
351.131 + <run-dependency>
351.132 + <implementation-version/>
351.133 + </run-dependency>
351.134 + </dependency>
351.135 + <dependency>
351.136 + <code-name-base>org.netbeans.modules.java.hints</code-name-base>
351.137 + <build-prerequisite/>
351.138 + <compile-dependency/>
351.139 + <run-dependency>
351.140 + <release-version>1</release-version>
351.141 + <implementation-version/>
351.142 + </run-dependency>
351.143 + </dependency>
351.144 + <dependency>
351.145 + <code-name-base>org.netbeans.modules.java.lexer</code-name-base>
351.146 + <build-prerequisite/>
351.147 + <compile-dependency/>
351.148 + <run-dependency>
351.149 + <release-version>1</release-version>
351.150 + <specification-version>1.12</specification-version>
351.151 + </run-dependency>
351.152 + </dependency>
351.153 + <dependency>
351.154 + <code-name-base>org.netbeans.modules.java.preprocessorbridge</code-name-base>
351.155 + <build-prerequisite/>
351.156 + <compile-dependency/>
351.157 + <run-dependency>
351.158 + <implementation-version/>
351.159 + </run-dependency>
351.160 + </dependency>
351.161 + <dependency>
351.162 + <code-name-base>org.netbeans.modules.java.source</code-name-base>
351.163 + <build-prerequisite/>
351.164 + <compile-dependency/>
351.165 + <run-dependency>
351.166 + <implementation-version/>
351.167 + </run-dependency>
351.168 + </dependency>
351.169 + <dependency>
351.170 + <code-name-base>org.netbeans.modules.lexer</code-name-base>
351.171 + <build-prerequisite/>
351.172 + <compile-dependency/>
351.173 + <run-dependency>
351.174 + <release-version>2</release-version>
351.175 + <specification-version>1.37.0.1</specification-version>
351.176 + </run-dependency>
351.177 + </dependency>
351.178 + <dependency>
351.179 + <code-name-base>org.netbeans.modules.masterfs</code-name-base>
351.180 + <build-prerequisite/>
351.181 + <compile-dependency/>
351.182 + <run-dependency>
351.183 + <release-version>2</release-version>
351.184 + <implementation-version/>
351.185 + </run-dependency>
351.186 + </dependency>
351.187 + <dependency>
351.188 + <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
351.189 + <build-prerequisite/>
351.190 + <compile-dependency/>
351.191 + <run-dependency>
351.192 + <release-version>1</release-version>
351.193 + <specification-version>1.65</specification-version>
351.194 + </run-dependency>
351.195 + </dependency>
351.196 + <dependency>
351.197 + <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
351.198 + <build-prerequisite/>
351.199 + <compile-dependency/>
351.200 + <run-dependency>
351.201 + <release-version>1</release-version>
351.202 + <implementation-version/>
351.203 + </run-dependency>
351.204 + </dependency>
351.205 + <dependency>
351.206 + <code-name-base>org.netbeans.modules.projectapi</code-name-base>
351.207 + <build-prerequisite/>
351.208 + <compile-dependency/>
351.209 + <run-dependency>
351.210 + <release-version>1</release-version>
351.211 + <specification-version>1.34</specification-version>
351.212 + </run-dependency>
351.213 + </dependency>
351.214 + <dependency>
351.215 + <code-name-base>org.netbeans.modules.projectui</code-name-base>
351.216 + <build-prerequisite/>
351.217 + <compile-dependency/>
351.218 + <run-dependency>
351.219 + <implementation-version/>
351.220 + </run-dependency>
351.221 + </dependency>
351.222 + <dependency>
351.223 + <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
351.224 + <build-prerequisite/>
351.225 + <compile-dependency/>
351.226 + <run-dependency>
351.227 + <release-version>1</release-version>
351.228 + <specification-version>1.49.0.8</specification-version>
351.229 + </run-dependency>
351.230 + </dependency>
351.231 + <dependency>
351.232 + <code-name-base>org.netbeans.modules.queries</code-name-base>
351.233 + <build-prerequisite/>
351.234 + <compile-dependency/>
351.235 + <run-dependency>
351.236 + <release-version>1</release-version>
351.237 + <specification-version>1.21</specification-version>
351.238 + </run-dependency>
351.239 + </dependency>
351.240 + <dependency>
351.241 + <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
351.242 + <build-prerequisite/>
351.243 + <compile-dependency/>
351.244 + <run-dependency>
351.245 + <release-version>0-1</release-version>
351.246 + <specification-version>1.16.0.7.5</specification-version>
351.247 + </run-dependency>
351.248 + </dependency>
351.249 + <dependency>
351.250 + <code-name-base>org.openide.actions</code-name-base>
351.251 + <build-prerequisite/>
351.252 + <compile-dependency/>
351.253 + <run-dependency>
351.254 + <specification-version>6.19</specification-version>
351.255 + </run-dependency>
351.256 + </dependency>
351.257 + <dependency>
351.258 + <code-name-base>org.openide.awt</code-name-base>
351.259 + <build-prerequisite/>
351.260 + <compile-dependency/>
351.261 + <run-dependency>
351.262 + <specification-version>7.29</specification-version>
351.263 + </run-dependency>
351.264 + </dependency>
351.265 + <dependency>
351.266 + <code-name-base>org.openide.dialogs</code-name-base>
351.267 + <build-prerequisite/>
351.268 + <compile-dependency/>
351.269 + <run-dependency>
351.270 + <specification-version>7.17</specification-version>
351.271 + </run-dependency>
351.272 + </dependency>
351.273 + <dependency>
351.274 + <code-name-base>org.openide.filesystems</code-name-base>
351.275 + <build-prerequisite/>
351.276 + <compile-dependency/>
351.277 + <run-dependency>
351.278 + <specification-version>7.43</specification-version>
351.279 + </run-dependency>
351.280 + </dependency>
351.281 + <dependency>
351.282 + <code-name-base>org.openide.loaders</code-name-base>
351.283 + <build-prerequisite/>
351.284 + <compile-dependency/>
351.285 + <run-dependency>
351.286 + <specification-version>7.19</specification-version>
351.287 + </run-dependency>
351.288 + </dependency>
351.289 + <dependency>
351.290 + <code-name-base>org.openide.nodes</code-name-base>
351.291 + <build-prerequisite/>
351.292 + <compile-dependency/>
351.293 + <run-dependency>
351.294 + <specification-version>7.19</specification-version>
351.295 + </run-dependency>
351.296 + </dependency>
351.297 + <dependency>
351.298 + <code-name-base>org.openide.text</code-name-base>
351.299 + <build-prerequisite/>
351.300 + <compile-dependency/>
351.301 + <run-dependency>
351.302 + <specification-version>6.34</specification-version>
351.303 + </run-dependency>
351.304 + </dependency>
351.305 + <dependency>
351.306 + <code-name-base>org.openide.util</code-name-base>
351.307 + <build-prerequisite/>
351.308 + <compile-dependency/>
351.309 + <run-dependency>
351.310 + <specification-version>8.9</specification-version>
351.311 + </run-dependency>
351.312 + </dependency>
351.313 + <dependency>
351.314 + <code-name-base>org.openide.util.lookup</code-name-base>
351.315 + <build-prerequisite/>
351.316 + <compile-dependency/>
351.317 + <run-dependency>
351.318 + <specification-version>8.5</specification-version>
351.319 + </run-dependency>
351.320 + </dependency>
351.321 + <dependency>
351.322 + <code-name-base>org.openide.windows</code-name-base>
351.323 + <build-prerequisite/>
351.324 + <compile-dependency/>
351.325 + <run-dependency>
351.326 + <specification-version>6.37</specification-version>
351.327 + </run-dependency>
351.328 + </dependency>
351.329 + <dependency>
351.330 + <code-name-base>org.openidex.util</code-name-base>
351.331 + <build-prerequisite/>
351.332 + <compile-dependency/>
351.333 + <run-dependency>
351.334 + <release-version>3</release-version>
351.335 + <specification-version>3.27</specification-version>
351.336 + </run-dependency>
351.337 + </dependency>
351.338 + </module-dependencies>
351.339 + <public-packages/>
351.340 + </data>
351.341 + </configuration>
351.342 +</project>
352.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
352.2 +++ b/remoting/common/test/nbproject/suite.properties Mon Mar 12 21:10:10 2012 +0100
352.3 @@ -0,0 +1,1 @@
352.4 +suite.dir=${basedir}/..
353.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
353.2 +++ b/remoting/common/test/src/org/netbeans/modules/jackpot30/common/test/Bundle.properties Mon Mar 12 21:10:10 2012 +0100
353.3 @@ -0,0 +1,1 @@
353.4 +OpenIDE-Module-Name=Jackpot 3.0 Common Test APIs
354.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
354.2 +++ b/remoting/common/test/src/org/netbeans/modules/jackpot30/common/test/IndexTestBase.java Mon Mar 12 21:10:10 2012 +0100
354.3 @@ -0,0 +1,192 @@
354.4 +/*
354.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
354.6 + *
354.7 + * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
354.8 + *
354.9 + * The contents of this file are subject to the terms of either the GNU
354.10 + * General Public License Version 2 only ("GPL") or the Common
354.11 + * Development and Distribution License("CDDL") (collectively, the
354.12 + * "License"). You may not use this file except in compliance with the
354.13 + * License. You can obtain a copy of the License at
354.14 + * http://www.netbeans.org/cddl-gplv2.html
354.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
354.16 + * specific language governing permissions and limitations under the
354.17 + * License. When distributing the software, include this License Header
354.18 + * Notice in each file and include the License file at
354.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
354.20 + * particular file as subject to the "Classpath" exception as provided
354.21 + * by Sun in the GPL Version 2 section of the License file that
354.22 + * accompanied this code. If applicable, add the following below the
354.23 + * License Header, with the fields enclosed by brackets [] replaced by
354.24 + * your own identifying information:
354.25 + * "Portions Copyrighted [year] [name of copyright owner]"
354.26 + *
354.27 + * If you wish your version of this file to be governed by only the CDDL
354.28 + * or only the GPL Version 2, indicate your decision by adding
354.29 + * "[Contributor] elects to include this software in this distribution
354.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
354.31 + * single choice of license, a recipient has the option to distribute
354.32 + * your version of this file under either the CDDL, the GPL Version 2 or
354.33 + * to extend the choice of license to its licensees as provided above.
354.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
354.35 + * Version 2 license, then the option applies only if the new code is
354.36 + * made subject to such option by the copyright holder.
354.37 + *
354.38 + * Contributor(s):
354.39 + *
354.40 + * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
354.41 + */
354.42 +
354.43 +package org.netbeans.modules.jackpot30.common.test;
354.44 +
354.45 +import java.net.URL;
354.46 +import java.util.Collections;
354.47 +import org.netbeans.api.editor.mimelookup.MimePath;
354.48 +import org.netbeans.api.java.classpath.ClassPath;
354.49 +import org.netbeans.api.java.classpath.GlobalPathRegistry;
354.50 +import org.netbeans.api.java.source.SourceUtils;
354.51 +import org.netbeans.api.java.source.SourceUtilsTestUtil;
354.52 +import org.netbeans.api.java.source.TestUtilities;
354.53 +import org.netbeans.core.startup.Main;
354.54 +import org.netbeans.junit.NbTestCase;
354.55 +import org.netbeans.modules.java.preprocessorbridge.spi.JavaIndexerPlugin;
354.56 +import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
354.57 +import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
354.58 +import org.netbeans.modules.parsing.impl.indexing.MimeTypes;
354.59 +import org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater;
354.60 +import org.netbeans.modules.parsing.spi.indexing.Context;
354.61 +import org.netbeans.modules.parsing.spi.indexing.CustomIndexer;
354.62 +import org.netbeans.modules.parsing.spi.indexing.CustomIndexerFactory;
354.63 +import org.netbeans.modules.parsing.spi.indexing.Indexable;
354.64 +import org.netbeans.spi.editor.mimelookup.MimeDataProvider;
354.65 +import org.netbeans.spi.java.classpath.ClassPathProvider;
354.66 +import org.netbeans.spi.java.classpath.support.ClassPathSupport;
354.67 +import org.openide.filesystems.FileObject;
354.68 +import org.openide.filesystems.FileUtil;
354.69 +import org.openide.util.Lookup;
354.70 +import org.openide.util.lookup.Lookups;
354.71 +import org.openide.util.lookup.ServiceProvider;
354.72 +
354.73 +/**
354.74 + *
354.75 + * @author lahvac
354.76 + */
354.77 +public abstract class IndexTestBase extends NbTestCase {
354.78 +
354.79 + public IndexTestBase(String name) {
354.80 + super(name);
354.81 + }
354.82 +
354.83 + @Override
354.84 + protected void setUp() throws Exception {
354.85 + SourceUtilsTestUtil.prepareTest(new String[0], new Object[] {new TestClassPathProvider()});
354.86 + Main.initializeURLFactory();
354.87 + org.netbeans.api.project.ui.OpenProjects.getDefault().getOpenProjects();
354.88 + prepareTest();
354.89 + MimeTypes.setAllMimeTypes(Collections.singleton("text/x-java"));
354.90 + GlobalPathRegistry.getDefault().register(ClassPath.SOURCE, new ClassPath[] {sourceCP});
354.91 + RepositoryUpdater.getDefault().start(true);
354.92 + super.setUp();
354.93 + }
354.94 +
354.95 + @Override
354.96 + protected void tearDown() throws Exception {
354.97 + super.tearDown();
354.98 + GlobalPathRegistry.getDefault().unregister(ClassPath.SOURCE, new ClassPath[] {sourceCP});
354.99 + }
354.100 +
354.101 + protected FileObject sources;
354.102 + protected FileObject src;
354.103 + protected FileObject src2;
354.104 + protected FileObject build;
354.105 + protected FileObject cache;
354.106 +
354.107 + private ClassPath sourceCP;
354.108 +
354.109 + private void prepareTest() throws Exception {
354.110 + FileObject workdir = SourceUtilsTestUtil.makeScratchDir(this);
354.111 +
354.112 + sources = FileUtil.createFolder(workdir, "sources");
354.113 + src = FileUtil.createFolder(sources, "src");
354.114 + src2 = FileUtil.createFolder(sources, "src2");
354.115 + build = FileUtil.createFolder(workdir, "build");
354.116 + cache = FileUtil.createFolder(workdir, "cache");
354.117 +
354.118 + sourceCP = ClassPathSupport.createClassPath(src, src2);
354.119 +
354.120 + SourceUtilsTestUtil.prepareTest(src, build, cache);
354.121 + }
354.122 +
354.123 + public static void writeFiles(FileObject sourceRoot, File... files) throws Exception {
354.124 + for (FileObject c : sourceRoot.getChildren()) {
354.125 + c.delete();
354.126 + }
354.127 +
354.128 + for (File f : files) {
354.129 + FileObject fo = FileUtil.createData(sourceRoot, f.filename);
354.130 + TestUtilities.copyStringToFile(fo, f.content);
354.131 + }
354.132 + }
354.133 +
354.134 + public static void writeFilesAndWaitForScan(FileObject sourceRoot, File... files) throws Exception {
354.135 + writeFiles(sourceRoot, files);
354.136 + SourceUtils.waitScanFinished();
354.137 + }
354.138 +
354.139 + public static final class File {
354.140 + public final String filename;
354.141 + public final String content;
354.142 +
354.143 + public File(String filename, String content) {
354.144 + this.filename = filename;
354.145 + this.content = content;
354.146 + }
354.147 + }
354.148 +
354.149 + @ServiceProvider(service=MimeDataProvider.class)
354.150 + public static final class MimeDataProviderImpl implements MimeDataProvider {
354.151 +
354.152 + private static final Lookup L = Lookups.fixed(new JavaCustomIndexer.Factory());
354.153 +
354.154 + @Override
354.155 + public Lookup getLookup(MimePath mp) {
354.156 + if ("text/x-java".equals(mp.getPath())) {
354.157 + return L;
354.158 + }
354.159 + return Lookup.EMPTY;
354.160 + }
354.161 +
354.162 + }
354.163 +
354.164 + private class TestClassPathProvider implements ClassPathProvider {
354.165 +
354.166 + public TestClassPathProvider() {
354.167 + }
354.168 +
354.169 + public ClassPath findClassPath(FileObject file, String type) {
354.170 + try {
354.171 + if (ClassPath.BOOT == type) {
354.172 + return ClassPathSupport.createClassPath(SourceUtilsTestUtil.getBootClassPath().toArray(new URL[0]));
354.173 + }
354.174 +
354.175 + if (ClassPath.SOURCE == type) {
354.176 + return sourceCP;
354.177 + }
354.178 +
354.179 + if (ClassPath.COMPILE == type) {
354.180 + return ClassPathSupport.createClassPath(new URL[0]);
354.181 + }
354.182 +
354.183 + if (ClassPath.EXECUTE == type) {
354.184 + return ClassPathSupport.createClassPath(new FileObject[] {
354.185 + build
354.186 + });
354.187 + }
354.188 + } catch (Exception e) {
354.189 + e.printStackTrace();
354.190 + }
354.191 + return null;
354.192 + }
354.193 +
354.194 + }
354.195 +}
355.1 --- a/remoting/ide/build.xml Fri Jan 27 13:35:56 2012 +0100
355.2 +++ b/remoting/ide/build.xml Mon Mar 12 21:10:10 2012 +0100
355.3 @@ -2,7 +2,7 @@
355.4 <!-- You may freely edit this file. See harness/README in the NetBeans platform -->
355.5 <!-- for some information on what you could do (e.g. targets to override). -->
355.6 <!-- If you delete this file and reopen the project it will be recreated. -->
355.7 -<project name="ide" basedir=".">
355.8 +<project name="remoting-ide" basedir=".">
355.9 <description>Builds the module suite ide.</description>
355.10 <import file="nbproject/build-impl.xml"/>
355.11 </project>
356.1 --- a/remoting/ide/nbproject/build-impl.xml Fri Jan 27 13:35:56 2012 +0100
356.2 +++ b/remoting/ide/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
356.3 @@ -3,7 +3,7 @@
356.4 *** GENERATED FROM project.xml - DO NOT EDIT ***
356.5 *** EDIT ../build.xml INSTEAD ***
356.6 -->
356.7 -<project name="ide-impl" basedir=".." xmlns:sproject="http://www.netbeans.org/ns/nb-module-suite-project/1">
356.8 +<project name="remoting-ide-impl" basedir=".." xmlns:sproject="http://www.netbeans.org/ns/nb-module-suite-project/1">
356.9 <fail message="Please build using Ant 1.7.1 or higher.">
356.10 <condition>
356.11 <not>
357.1 --- a/remoting/ide/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
357.2 +++ b/remoting/ide/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
357.3 @@ -3,9 +3,9 @@
357.4 build.xml.stylesheet.CRC32=eaf9f76a@1.47
357.5 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
357.6 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
357.7 -nbproject/build-impl.xml.data.CRC32=891734f5
357.8 -nbproject/build-impl.xml.script.CRC32=f4643aa8
357.9 -nbproject/build-impl.xml.stylesheet.CRC32=0f381476@2.46
357.10 -nbproject/platform.xml.data.CRC32=891734f5
357.11 +nbproject/build-impl.xml.data.CRC32=fa6e1472
357.12 +nbproject/build-impl.xml.script.CRC32=c2d6d7d2
357.13 +nbproject/build-impl.xml.stylesheet.CRC32=0f381476@2.49
357.14 +nbproject/platform.xml.data.CRC32=fa6e1472
357.15 nbproject/platform.xml.script.CRC32=db9e1f43
357.16 -nbproject/platform.xml.stylesheet.CRC32=df8ac4dd@2.46
357.17 +nbproject/platform.xml.stylesheet.CRC32=df8ac4dd@2.49
358.1 --- a/remoting/ide/nbproject/platform.properties Fri Jan 27 13:35:56 2012 +0100
358.2 +++ b/remoting/ide/nbproject/platform.properties Mon Mar 12 21:10:10 2012 +0100
358.3 @@ -10,5 +10,7 @@
358.4 ${nbplatform.active.dir}/platform:\
358.5 ${nbplatform.active.dir}/profiler:\
358.6 ${nbplatform.active.dir}/websvccommon:\
358.7 - ../../borrowedtests/build/cluster
358.8 + ../common/build/cluster
358.9 +extcluster.../common/build/cluster.javadoc=
358.10 +extcluster.../common/build/cluster.sources=../common
358.11 nbplatform.active=default
359.1 --- a/remoting/ide/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
359.2 +++ b/remoting/ide/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
359.3 @@ -3,7 +3,7 @@
359.4 <type>org.netbeans.modules.apisupport.project.suite</type>
359.5 <configuration>
359.6 <data xmlns="http://www.netbeans.org/ns/nb-module-suite-project/1">
359.7 - <name>ide</name>
359.8 + <name>remoting-ide</name>
359.9 </data>
359.10 </configuration>
359.11 </project>
360.1 --- a/remoting/ide/usages/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
360.2 +++ b/remoting/ide/usages/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
360.3 @@ -1,8 +1,8 @@
360.4 -build.xml.data.CRC32=46c67808
360.5 +build.xml.data.CRC32=e216ee19
360.6 build.xml.script.CRC32=58a6b47a
360.7 -build.xml.stylesheet.CRC32=a56c6a5b@2.46
360.8 +build.xml.stylesheet.CRC32=a56c6a5b@2.49
360.9 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
360.10 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
360.11 -nbproject/build-impl.xml.data.CRC32=46c67808
360.12 +nbproject/build-impl.xml.data.CRC32=e216ee19
360.13 nbproject/build-impl.xml.script.CRC32=583fd407
360.14 -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.46
360.15 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.49
361.1 --- a/remoting/ide/usages/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
361.2 +++ b/remoting/ide/usages/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
361.3 @@ -7,6 +7,15 @@
361.4 <suite-component/>
361.5 <module-dependencies>
361.6 <dependency>
361.7 + <code-name-base>org.netbeans.api.annotations.common</code-name-base>
361.8 + <build-prerequisite/>
361.9 + <compile-dependency/>
361.10 + <run-dependency>
361.11 + <release-version>1</release-version>
361.12 + <specification-version>1.13</specification-version>
361.13 + </run-dependency>
361.14 + </dependency>
361.15 + <dependency>
361.16 <code-name-base>org.netbeans.api.java.classpath</code-name-base>
361.17 <build-prerequisite/>
361.18 <compile-dependency/>
361.19 @@ -42,6 +51,14 @@
361.20 </run-dependency>
361.21 </dependency>
361.22 <dependency>
361.23 + <code-name-base>org.netbeans.modules.jackpot30.common</code-name-base>
361.24 + <build-prerequisite/>
361.25 + <compile-dependency/>
361.26 + <run-dependency>
361.27 + <specification-version>1.0</specification-version>
361.28 + </run-dependency>
361.29 + </dependency>
361.30 + <dependency>
361.31 <code-name-base>org.netbeans.modules.jackpot30.remoting.api</code-name-base>
361.32 <build-prerequisite/>
361.33 <compile-dependency/>
362.1 --- a/remoting/ide/usages/src/org/netbeans/modules/jackpot30/ide/usages/Common.java Fri Jan 27 13:35:56 2012 +0100
362.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
362.3 @@ -1,76 +0,0 @@
362.4 -/*
362.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
362.6 - *
362.7 - * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
362.8 - *
362.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
362.10 - * Other names may be trademarks of their respective owners.
362.11 - *
362.12 - * The contents of this file are subject to the terms of either the GNU
362.13 - * General Public License Version 2 only ("GPL") or the Common
362.14 - * Development and Distribution License("CDDL") (collectively, the
362.15 - * "License"). You may not use this file except in compliance with the
362.16 - * License. You can obtain a copy of the License at
362.17 - * http://www.netbeans.org/cddl-gplv2.html
362.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
362.19 - * specific language governing permissions and limitations under the
362.20 - * License. When distributing the software, include this License Header
362.21 - * Notice in each file and include the License file at
362.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
362.23 - * particular file as subject to the "Classpath" exception as provided
362.24 - * by Oracle in the GPL Version 2 section of the License file that
362.25 - * accompanied this code. If applicable, add the following below the
362.26 - * License Header, with the fields enclosed by brackets [] replaced by
362.27 - * your own identifying information:
362.28 - * "Portions Copyrighted [year] [name of copyright owner]"
362.29 - *
362.30 - * If you wish your version of this file to be governed by only the CDDL
362.31 - * or only the GPL Version 2, indicate your decision by adding
362.32 - * "[Contributor] elects to include this software in this distribution
362.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
362.34 - * single choice of license, a recipient has the option to distribute
362.35 - * your version of this file under either the CDDL, the GPL Version 2 or
362.36 - * to extend the choice of license to its licensees as provided above.
362.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
362.38 - * Version 2 license, then the option applies only if the new code is
362.39 - * made subject to such option by the copyright holder.
362.40 - *
362.41 - * Contributor(s):
362.42 - *
362.43 - * Portions Copyrighted 2011 Sun Microsystems, Inc.
362.44 - */
362.45 -package org.netbeans.modules.jackpot30.ide.usages;
362.46 -
362.47 -import java.util.EnumSet;
362.48 -import java.util.Set;
362.49 -import javax.lang.model.element.ElementKind;
362.50 -import org.netbeans.api.java.source.ElementHandle;
362.51 -import org.netbeans.api.java.source.SourceUtils;
362.52 -
362.53 -/**XXX: Copied between indexing and ide!
362.54 - *
362.55 - * @author lahvac
362.56 - */
362.57 -public class Common {
362.58 -
362.59 - public static final Set<ElementKind> SUPPORTED_KINDS = EnumSet.of(ElementKind.PACKAGE, ElementKind.CLASS,
362.60 - ElementKind.INTERFACE, ElementKind.ENUM, ElementKind.ANNOTATION_TYPE, ElementKind.METHOD,
362.61 - ElementKind.CONSTRUCTOR, ElementKind.INSTANCE_INIT, ElementKind.STATIC_INIT,
362.62 - ElementKind.FIELD, ElementKind.ENUM_CONSTANT);
362.63 -
362.64 - public static String serialize(ElementHandle<?> h) {
362.65 - StringBuilder result = new StringBuilder();
362.66 -
362.67 - result.append(h.getKind());
362.68 -
362.69 - String[] signatures = SourceUtils.getJVMSignature(h);
362.70 -
362.71 - for (String sig : signatures) {
362.72 - result.append(":");
362.73 - result.append(sig);
362.74 - }
362.75 -
362.76 - return result.toString();
362.77 - }
362.78 -
362.79 -}
363.1 --- a/remoting/ide/usages/src/org/netbeans/modules/jackpot30/ide/usages/RemoteUsages.java Fri Jan 27 13:35:56 2012 +0100
363.2 +++ b/remoting/ide/usages/src/org/netbeans/modules/jackpot30/ide/usages/RemoteUsages.java Mon Mar 12 21:10:10 2012 +0100
363.3 @@ -81,16 +81,17 @@
363.4 import org.netbeans.api.java.source.ui.ElementHeaders;
363.5 import org.netbeans.api.java.source.ui.ScanDialog;
363.6 import org.netbeans.modules.editor.NbEditorUtilities;
363.7 +import org.netbeans.modules.jackpot30.common.api.JavaUtils;
363.8 import org.netbeans.modules.jackpot30.remoting.api.RemoteIndex;
363.9 import org.netbeans.modules.jackpot30.remoting.api.WebUtilities;
363.10 import org.openide.DialogDescriptor;
363.11 import org.openide.DialogDisplayer;
363.12 import org.openide.NotifyDescriptor;
363.13 import org.openide.NotifyDescriptor.Message;
363.14 -import org.openide.awt.ActionRegistration;
363.15 +import org.openide.awt.ActionID;
363.16 import org.openide.awt.ActionReference;
363.17 import org.openide.awt.ActionReferences;
363.18 -import org.openide.awt.ActionID;
363.19 +import org.openide.awt.ActionRegistration;
363.20 import org.openide.filesystems.FileObject;
363.21 import org.openide.filesystems.URLMapper;
363.22 import org.openide.nodes.Node;
363.23 @@ -169,7 +170,7 @@
363.24 TreePath tp = parameter.getTreeUtilities().pathFor(pos);
363.25 Element el = parameter.getTrees().getElement(tp);
363.26
363.27 - if (el != null && Common.SUPPORTED_KINDS.contains(el.getKind())) {
363.28 + if (el != null && JavaUtils.SUPPORTED_KINDS.contains(el.getKind())) {
363.29 handle[0] = new ElementDescription(parameter, el);
363.30 }
363.31 }
363.32 @@ -291,7 +292,7 @@
363.33
363.34 @Override public void run() {
363.35 try {
363.36 - final String serialized = Common.serialize(toSearch);
363.37 + final String serialized = JavaUtils.serialize(toSearch);
363.38
363.39 Set<FileObject> resultSet = new HashSet<FileObject>();
363.40 List<FileObject> result = new ArrayList<FileObject>();
364.1 --- a/remoting/server/tests/data/group1/prj1/nbproject/build-impl.xml Fri Jan 27 13:35:56 2012 +0100
364.2 +++ b/remoting/server/tests/data/group1/prj1/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
364.3 @@ -156,6 +156,7 @@
364.4 </and>
364.5 </condition>
364.6 <property name="run.jvmargs" value=""/>
364.7 + <property name="run.jvmargs.ide" value=""/>
364.8 <property name="javac.compilerargs" value=""/>
364.9 <property name="work.dir" value="${basedir}"/>
364.10 <condition property="no.deps">
364.11 @@ -357,6 +358,7 @@
364.12 <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
364.13 <jvmarg value="-ea"/>
364.14 <jvmarg line="${run.jvmargs}"/>
364.15 + <jvmarg line="${run.jvmargs.ide}"/>
364.16 </junit>
364.17 </sequential>
364.18 </macrodef>
364.19 @@ -385,6 +387,7 @@
364.20 <property environment="env"/>
364.21 <resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
364.22 <java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
364.23 + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
364.24 <jvmarg value="${profiler.info.jvmargs.agent}"/>
364.25 <jvmarg line="${profiler.info.jvmargs}"/>
364.26 <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
364.27 @@ -462,6 +465,7 @@
364.28 <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
364.29 <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
364.30 <jvmarg line="${run.jvmargs}"/>
364.31 + <jvmarg line="${run.jvmargs.ide}"/>
364.32 <classpath>
364.33 <path path="@{classpath}"/>
364.34 </classpath>
364.35 @@ -485,6 +489,7 @@
364.36 <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
364.37 <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
364.38 <jvmarg line="${run.jvmargs}"/>
364.39 + <jvmarg line="${run.jvmargs.ide}"/>
364.40 <classpath>
364.41 <path path="@{classpath}"/>
364.42 </classpath>
364.43 @@ -840,6 +845,14 @@
364.44 -->
364.45 <target depends="init" if="have.sources" name="-javadoc-build">
364.46 <mkdir dir="${dist.javadoc.dir}"/>
364.47 + <condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}">
364.48 + <and>
364.49 + <isset property="endorsed.classpath.cmd.line.arg"/>
364.50 + <not>
364.51 + <equals arg1="${endorsed.classpath.cmd.line.arg}" arg2=""/>
364.52 + </not>
364.53 + </and>
364.54 + </condition>
364.55 <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
364.56 <classpath>
364.57 <path path="${javac.classpath}"/>
364.58 @@ -851,6 +864,7 @@
364.59 <include name="**/*.java"/>
364.60 <exclude name="*.java"/>
364.61 </fileset>
364.62 + <arg line="${javadoc.endorsed.classpath.cmd.line.arg}"/>
364.63 </javadoc>
364.64 <copy todir="${dist.javadoc.dir}">
364.65 <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
364.66 @@ -1027,9 +1041,12 @@
364.67 <target name="-check-call-dep">
364.68 <property file="${call.built.properties}" prefix="already.built."/>
364.69 <condition property="should.call.dep">
364.70 - <not>
364.71 - <isset property="already.built.${call.subproject}"/>
364.72 - </not>
364.73 + <and>
364.74 + <not>
364.75 + <isset property="already.built.${call.subproject}"/>
364.76 + </not>
364.77 + <available file="${call.script}"/>
364.78 + </and>
364.79 </condition>
364.80 </target>
364.81 <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
365.1 --- a/remoting/server/tests/data/group1/prj1/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
365.2 +++ b/remoting/server/tests/data/group1/prj1/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
365.3 @@ -4,5 +4,5 @@
365.4 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
365.5 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
365.6 nbproject/build-impl.xml.data.CRC32=9fba8b40
365.7 -nbproject/build-impl.xml.script.CRC32=e9af8aba
365.8 -nbproject/build-impl.xml.stylesheet.CRC32=cfcde7f8@1.45.0.45
365.9 +nbproject/build-impl.xml.script.CRC32=cbf5f41e
365.10 +nbproject/build-impl.xml.stylesheet.CRC32=96b566c0@1.51.0.46
366.1 --- a/remoting/server/web/base.web.api/nbproject/build-impl.xml Fri Jan 27 13:35:56 2012 +0100
366.2 +++ b/remoting/server/web/base.web.api/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
366.3 @@ -43,7 +43,7 @@
366.4 <property file="nbproject/private/private.properties"/>
366.5 </target>
366.6 <target name="-pre-init-libraries">
366.7 - <property location="../../../../server/lib/nblibraries.properties" name="libraries.path"/>
366.8 + <property location="../../../../lib/nblibraries.properties" name="libraries.path"/>
366.9 <dirname file="${libraries.path}" property="libraries.dir.nativedirsep"/>
366.10 <pathconvert dirsep="/" property="libraries.dir">
366.11 <path path="${libraries.dir.nativedirsep}"/>
366.12 @@ -181,6 +181,7 @@
366.13 </and>
366.14 </condition>
366.15 <property name="run.jvmargs" value=""/>
366.16 + <property name="run.jvmargs.ide" value=""/>
366.17 <property name="javac.compilerargs" value=""/>
366.18 <property name="work.dir" value="${basedir}"/>
366.19 <condition property="no.deps">
366.20 @@ -382,6 +383,7 @@
366.21 <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
366.22 <jvmarg value="-ea"/>
366.23 <jvmarg line="${run.jvmargs}"/>
366.24 + <jvmarg line="${run.jvmargs.ide}"/>
366.25 </junit>
366.26 </sequential>
366.27 </macrodef>
366.28 @@ -488,6 +490,7 @@
366.29 <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
366.30 <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
366.31 <jvmarg line="${run.jvmargs}"/>
366.32 + <jvmarg line="${run.jvmargs.ide}"/>
366.33 <classpath>
366.34 <path path="@{classpath}"/>
366.35 </classpath>
366.36 @@ -511,6 +514,7 @@
366.37 <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
366.38 <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
366.39 <jvmarg line="${run.jvmargs}"/>
366.40 + <jvmarg line="${run.jvmargs.ide}"/>
366.41 <classpath>
366.42 <path path="@{classpath}"/>
366.43 </classpath>
366.44 @@ -1062,9 +1066,12 @@
366.45 <target name="-check-call-dep">
366.46 <property file="${call.built.properties}" prefix="already.built."/>
366.47 <condition property="should.call.dep">
366.48 - <not>
366.49 - <isset property="already.built.${call.subproject}"/>
366.50 - </not>
366.51 + <and>
366.52 + <not>
366.53 + <isset property="already.built.${call.subproject}"/>
366.54 + </not>
366.55 + <available file="${call.script}"/>
366.56 + </and>
366.57 </condition>
366.58 </target>
366.59 <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
367.1 --- a/remoting/server/web/base.web.api/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
367.2 +++ b/remoting/server/web/base.web.api/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
367.3 @@ -1,8 +1,8 @@
367.4 -build.xml.data.CRC32=274e0636
367.5 +build.xml.data.CRC32=8d18f2d6
367.6 build.xml.script.CRC32=f51e627e
367.7 -build.xml.stylesheet.CRC32=28e38971@1.45.0.45
367.8 +build.xml.stylesheet.CRC32=28e38971@1.51.0.46
367.9 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
367.10 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
367.11 -nbproject/build-impl.xml.data.CRC32=274e0636
367.12 -nbproject/build-impl.xml.script.CRC32=bea47b1c
367.13 -nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.48.0.46
367.14 +nbproject/build-impl.xml.data.CRC32=8d18f2d6
367.15 +nbproject/build-impl.xml.script.CRC32=53f8b1ba
367.16 +nbproject/build-impl.xml.stylesheet.CRC32=96b566c0@1.51.0.46
368.1 --- a/remoting/server/web/base.web.api/nbproject/project.properties Fri Jan 27 13:35:56 2012 +0100
368.2 +++ b/remoting/server/web/base.web.api/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
368.3 @@ -1,5 +1,6 @@
368.4 annotation.processing.enabled=true
368.5 annotation.processing.enabled.in.editor=false
368.6 +annotation.processing.processors.list=
368.7 annotation.processing.run.all.processors=true
368.8 annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
368.9 application.title=base.web.api
368.10 @@ -26,11 +27,11 @@
368.11 dist.javadoc.dir=${dist.dir}/javadoc
368.12 endorsed.classpath=
368.13 excludes=
368.14 -file.reference.org-netbeans-modules-java-source.jar=../../../../server/lib/org-netbeans-modules-java-source.jar
368.15 -file.reference.org-netbeans-modules-parsing-api.jar=../../../../server/lib/org-netbeans-modules-parsing-api.jar
368.16 -file.reference.org-netbeans-modules-parsing-lucene.jar=../../../../server/lib/org-netbeans-modules-parsing-lucene.jar
368.17 -file.reference.org-openide-filesystems.jar=../../../../server/lib/org-openide-filesystems.jar
368.18 -file.reference.org-openide-util-lookup.jar=../../../../server/lib/org-openide-util-lookup.jar
368.19 +file.reference.org-netbeans-modules-java-source.jar=../../../../lib/org-netbeans-modules-java-source.jar
368.20 +file.reference.org-netbeans-modules-parsing-api.jar=../../../../lib/org-netbeans-modules-parsing-api.jar
368.21 +file.reference.org-netbeans-modules-parsing-lucene.jar=../../../../lib/org-netbeans-modules-parsing-lucene.jar
368.22 +file.reference.org-openide-filesystems.jar=../../../../lib/org-openide-filesystems.jar
368.23 +file.reference.org-openide-util-lookup.jar=../../../../lib/org-openide-util-lookup.jar
368.24 file.reference.util-commons.jar=../../../ide/api/external/util-commons.jar
368.25 file.reference.util-pojson.jar=../../../ide/api/external/util-pojson.jar
368.26 includes=**
369.1 --- a/remoting/server/web/base.web.api/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
369.2 +++ b/remoting/server/web/base.web.api/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
369.3 @@ -12,7 +12,7 @@
369.4 </test-roots>
369.5 </data>
369.6 <libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
369.7 - <definitions>../../../../server/lib/nblibraries.properties</definitions>
369.8 + <definitions>../../../../lib/nblibraries.properties</definitions>
369.9 </libraries>
369.10 </configuration>
369.11 </project>
370.1 --- a/remoting/server/web/nbindex.web.api/nbproject/build-impl.xml Fri Jan 27 13:35:56 2012 +0100
370.2 +++ b/remoting/server/web/nbindex.web.api/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
370.3 @@ -43,7 +43,7 @@
370.4 <property file="nbproject/private/private.properties"/>
370.5 </target>
370.6 <target name="-pre-init-libraries">
370.7 - <property location="../../../../server/lib/nblibraries.properties" name="libraries.path"/>
370.8 + <property location="../../../../lib/nblibraries.properties" name="libraries.path"/>
370.9 <dirname file="${libraries.path}" property="libraries.dir.nativedirsep"/>
370.10 <pathconvert dirsep="/" property="libraries.dir">
370.11 <path path="${libraries.dir.nativedirsep}"/>
370.12 @@ -181,6 +181,7 @@
370.13 </and>
370.14 </condition>
370.15 <property name="run.jvmargs" value=""/>
370.16 + <property name="run.jvmargs.ide" value=""/>
370.17 <property name="javac.compilerargs" value=""/>
370.18 <property name="work.dir" value="${basedir}"/>
370.19 <condition property="no.deps">
370.20 @@ -382,6 +383,7 @@
370.21 <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
370.22 <jvmarg value="-ea"/>
370.23 <jvmarg line="${run.jvmargs}"/>
370.24 + <jvmarg line="${run.jvmargs.ide}"/>
370.25 </junit>
370.26 </sequential>
370.27 </macrodef>
370.28 @@ -488,6 +490,7 @@
370.29 <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
370.30 <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
370.31 <jvmarg line="${run.jvmargs}"/>
370.32 + <jvmarg line="${run.jvmargs.ide}"/>
370.33 <classpath>
370.34 <path path="@{classpath}"/>
370.35 </classpath>
370.36 @@ -511,6 +514,7 @@
370.37 <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
370.38 <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
370.39 <jvmarg line="${run.jvmargs}"/>
370.40 + <jvmarg line="${run.jvmargs.ide}"/>
370.41 <classpath>
370.42 <path path="@{classpath}"/>
370.43 </classpath>
370.44 @@ -1076,9 +1080,12 @@
370.45 <target name="-check-call-dep">
370.46 <property file="${call.built.properties}" prefix="already.built."/>
370.47 <condition property="should.call.dep">
370.48 - <not>
370.49 - <isset property="already.built.${call.subproject}"/>
370.50 - </not>
370.51 + <and>
370.52 + <not>
370.53 + <isset property="already.built.${call.subproject}"/>
370.54 + </not>
370.55 + <available file="${call.script}"/>
370.56 + </and>
370.57 </condition>
370.58 </target>
370.59 <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
371.1 --- a/remoting/server/web/nbindex.web.api/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
371.2 +++ b/remoting/server/web/nbindex.web.api/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
371.3 @@ -1,8 +1,8 @@
371.4 -build.xml.data.CRC32=a5bf9572
371.5 +build.xml.data.CRC32=0e5c43eb
371.6 build.xml.script.CRC32=db0f33ed
371.7 -build.xml.stylesheet.CRC32=28e38971@1.46.0.46
371.8 +build.xml.stylesheet.CRC32=28e38971@1.51.0.46
371.9 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
371.10 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
371.11 -nbproject/build-impl.xml.data.CRC32=a5bf9572
371.12 -nbproject/build-impl.xml.script.CRC32=112a5b9c
371.13 -nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.48.0.46
371.14 +nbproject/build-impl.xml.data.CRC32=0e5c43eb
371.15 +nbproject/build-impl.xml.script.CRC32=b73dc5e9
371.16 +nbproject/build-impl.xml.stylesheet.CRC32=96b566c0@1.51.0.46
372.1 --- a/remoting/server/web/nbindex.web.api/nbproject/project.properties Fri Jan 27 13:35:56 2012 +0100
372.2 +++ b/remoting/server/web/nbindex.web.api/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
372.3 @@ -25,10 +25,10 @@
372.4 dist.jar=${dist.dir}/nbindex.web.api.jar
372.5 dist.javadoc.dir=${dist.dir}/javadoc
372.6 excludes=
372.7 -file.reference.org-netbeans-modules-parsing-api.jar=../../../../server/lib/org-netbeans-modules-parsing-api.jar
372.8 -file.reference.org-netbeans-modules-parsing-lucene.jar=../../../../server/lib/org-netbeans-modules-parsing-lucene.jar
372.9 -file.reference.org-openide-filesystems.jar=../../../../server/lib/org-openide-filesystems.jar
372.10 -file.reference.org-openide-util.jar=../../../../server/lib/org-openide-util.jar
372.11 +file.reference.org-netbeans-modules-parsing-api.jar=../../../../lib/org-netbeans-modules-parsing-api.jar
372.12 +file.reference.org-netbeans-modules-parsing-lucene.jar=../../../../lib/org-netbeans-modules-parsing-lucene.jar
372.13 +file.reference.org-openide-filesystems.jar=../../../../lib/org-openide-filesystems.jar
372.14 +file.reference.org-openide-util.jar=../../../../lib/org-openide-util.jar
372.15 file.reference.util-commons.jar=../../../ide/api/external/util-commons.jar
372.16 file.reference.util-pojson.jar=../../../ide/api/external/util-pojson.jar
372.17 includes=**
373.1 --- a/remoting/server/web/nbindex.web.api/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
373.2 +++ b/remoting/server/web/nbindex.web.api/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
373.3 @@ -12,7 +12,7 @@
373.4 </test-roots>
373.5 </data>
373.6 <libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
373.7 - <definitions>../../../../server/lib/nblibraries.properties</definitions>
373.8 + <definitions>../../../../lib/nblibraries.properties</definitions>
373.9 </libraries>
373.10 <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
373.11 <reference>
374.1 --- a/remoting/server/web/source.web.api/nbproject/build-impl.xml Fri Jan 27 13:35:56 2012 +0100
374.2 +++ b/remoting/server/web/source.web.api/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
374.3 @@ -43,7 +43,7 @@
374.4 <property file="nbproject/private/private.properties"/>
374.5 </target>
374.6 <target name="-pre-init-libraries">
374.7 - <property location="../../../../server/lib/nblibraries.properties" name="libraries.path"/>
374.8 + <property location="../../../../lib/nblibraries.properties" name="libraries.path"/>
374.9 <dirname file="${libraries.path}" property="libraries.dir.nativedirsep"/>
374.10 <pathconvert dirsep="/" property="libraries.dir">
374.11 <path path="${libraries.dir.nativedirsep}"/>
374.12 @@ -181,6 +181,7 @@
374.13 </and>
374.14 </condition>
374.15 <property name="run.jvmargs" value=""/>
374.16 + <property name="run.jvmargs.ide" value=""/>
374.17 <property name="javac.compilerargs" value=""/>
374.18 <property name="work.dir" value="${basedir}"/>
374.19 <condition property="no.deps">
374.20 @@ -382,6 +383,7 @@
374.21 <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
374.22 <jvmarg value="-ea"/>
374.23 <jvmarg line="${run.jvmargs}"/>
374.24 + <jvmarg line="${run.jvmargs.ide}"/>
374.25 </junit>
374.26 </sequential>
374.27 </macrodef>
374.28 @@ -488,6 +490,7 @@
374.29 <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
374.30 <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
374.31 <jvmarg line="${run.jvmargs}"/>
374.32 + <jvmarg line="${run.jvmargs.ide}"/>
374.33 <classpath>
374.34 <path path="@{classpath}"/>
374.35 </classpath>
374.36 @@ -511,6 +514,7 @@
374.37 <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
374.38 <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
374.39 <jvmarg line="${run.jvmargs}"/>
374.40 + <jvmarg line="${run.jvmargs.ide}"/>
374.41 <classpath>
374.42 <path path="@{classpath}"/>
374.43 </classpath>
374.44 @@ -1076,9 +1080,12 @@
374.45 <target name="-check-call-dep">
374.46 <property file="${call.built.properties}" prefix="already.built."/>
374.47 <condition property="should.call.dep">
374.48 - <not>
374.49 - <isset property="already.built.${call.subproject}"/>
374.50 - </not>
374.51 + <and>
374.52 + <not>
374.53 + <isset property="already.built.${call.subproject}"/>
374.54 + </not>
374.55 + <available file="${call.script}"/>
374.56 + </and>
374.57 </condition>
374.58 </target>
374.59 <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
375.1 --- a/remoting/server/web/source.web.api/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
375.2 +++ b/remoting/server/web/source.web.api/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
375.3 @@ -1,8 +1,8 @@
375.4 -build.xml.data.CRC32=6ff1c131
375.5 +build.xml.data.CRC32=52865c72
375.6 build.xml.script.CRC32=d7df2170
375.7 -build.xml.stylesheet.CRC32=28e38971@1.45.0.45
375.8 +build.xml.stylesheet.CRC32=28e38971@1.51.0.46
375.9 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
375.10 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
375.11 -nbproject/build-impl.xml.data.CRC32=6ff1c131
375.12 -nbproject/build-impl.xml.script.CRC32=e8b2cee9
375.13 -nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.48.0.46
375.14 +nbproject/build-impl.xml.data.CRC32=52865c72
375.15 +nbproject/build-impl.xml.script.CRC32=0980b7a4
375.16 +nbproject/build-impl.xml.stylesheet.CRC32=96b566c0@1.51.0.46
376.1 --- a/remoting/server/web/source.web.api/nbproject/project.properties Fri Jan 27 13:35:56 2012 +0100
376.2 +++ b/remoting/server/web/source.web.api/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
376.3 @@ -25,9 +25,9 @@
376.4 dist.jar=${dist.dir}/source.web.api.jar
376.5 dist.javadoc.dir=${dist.dir}/javadoc
376.6 excludes=
376.7 -file.reference.org-netbeans-modules-parsing-api.jar=../../../../server/lib/org-netbeans-modules-parsing-api.jar
376.8 -file.reference.org-netbeans-modules-parsing-lucene.jar=../../../../server/lib/org-netbeans-modules-parsing-lucene.jar
376.9 -file.reference.org-openide-filesystems.jar=../../../../server/lib/org-openide-filesystems.jar
376.10 +file.reference.org-netbeans-modules-parsing-api.jar=../../../../lib/org-netbeans-modules-parsing-api.jar
376.11 +file.reference.org-netbeans-modules-parsing-lucene.jar=../../../../lib/org-netbeans-modules-parsing-lucene.jar
376.12 +file.reference.org-openide-filesystems.jar=../../../../lib/org-openide-filesystems.jar
376.13 includes=**
376.14 jar.compress=false
376.15 javac.classpath=\
377.1 --- a/remoting/server/web/source.web.api/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
377.2 +++ b/remoting/server/web/source.web.api/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
377.3 @@ -12,7 +12,7 @@
377.4 </test-roots>
377.5 </data>
377.6 <libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
377.7 - <definitions>../../../../server/lib/nblibraries.properties</definitions>
377.8 + <definitions>../../../../lib/nblibraries.properties</definitions>
377.9 </libraries>
377.10 <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
377.11 <reference>
378.1 --- a/remoting/server/web/type.web.api/nbproject/build-impl.xml Fri Jan 27 13:35:56 2012 +0100
378.2 +++ b/remoting/server/web/type.web.api/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
378.3 @@ -43,7 +43,7 @@
378.4 <property file="nbproject/private/private.properties"/>
378.5 </target>
378.6 <target name="-pre-init-libraries">
378.7 - <property location="../../../../server/lib/nblibraries.properties" name="libraries.path"/>
378.8 + <property location="../../../../lib/nblibraries.properties" name="libraries.path"/>
378.9 <dirname file="${libraries.path}" property="libraries.dir.nativedirsep"/>
378.10 <pathconvert dirsep="/" property="libraries.dir">
378.11 <path path="${libraries.dir.nativedirsep}"/>
378.12 @@ -181,6 +181,7 @@
378.13 </and>
378.14 </condition>
378.15 <property name="run.jvmargs" value=""/>
378.16 + <property name="run.jvmargs.ide" value=""/>
378.17 <property name="javac.compilerargs" value=""/>
378.18 <property name="work.dir" value="${basedir}"/>
378.19 <condition property="no.deps">
378.20 @@ -382,6 +383,7 @@
378.21 <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
378.22 <jvmarg value="-ea"/>
378.23 <jvmarg line="${run.jvmargs}"/>
378.24 + <jvmarg line="${run.jvmargs.ide}"/>
378.25 </junit>
378.26 </sequential>
378.27 </macrodef>
378.28 @@ -488,6 +490,7 @@
378.29 <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
378.30 <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
378.31 <jvmarg line="${run.jvmargs}"/>
378.32 + <jvmarg line="${run.jvmargs.ide}"/>
378.33 <classpath>
378.34 <path path="@{classpath}"/>
378.35 </classpath>
378.36 @@ -511,6 +514,7 @@
378.37 <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
378.38 <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
378.39 <jvmarg line="${run.jvmargs}"/>
378.40 + <jvmarg line="${run.jvmargs.ide}"/>
378.41 <classpath>
378.42 <path path="@{classpath}"/>
378.43 </classpath>
378.44 @@ -1076,9 +1080,12 @@
378.45 <target name="-check-call-dep">
378.46 <property file="${call.built.properties}" prefix="already.built."/>
378.47 <condition property="should.call.dep">
378.48 - <not>
378.49 - <isset property="already.built.${call.subproject}"/>
378.50 - </not>
378.51 + <and>
378.52 + <not>
378.53 + <isset property="already.built.${call.subproject}"/>
378.54 + </not>
378.55 + <available file="${call.script}"/>
378.56 + </and>
378.57 </condition>
378.58 </target>
378.59 <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
379.1 --- a/remoting/server/web/type.web.api/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
379.2 +++ b/remoting/server/web/type.web.api/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
379.3 @@ -1,8 +1,8 @@
379.4 -build.xml.data.CRC32=9ceb8e45
379.5 +build.xml.data.CRC32=7d71200f
379.6 build.xml.script.CRC32=583d72ad
379.7 -build.xml.stylesheet.CRC32=28e38971@1.45.0.45
379.8 +build.xml.stylesheet.CRC32=28e38971@1.51.0.46
379.9 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
379.10 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
379.11 -nbproject/build-impl.xml.data.CRC32=9ceb8e45
379.12 -nbproject/build-impl.xml.script.CRC32=c2ece9fb
379.13 -nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.48.0.46
379.14 +nbproject/build-impl.xml.data.CRC32=7d71200f
379.15 +nbproject/build-impl.xml.script.CRC32=3fd5bf71
379.16 +nbproject/build-impl.xml.stylesheet.CRC32=96b566c0@1.51.0.46
380.1 --- a/remoting/server/web/type.web.api/nbproject/project.properties Fri Jan 27 13:35:56 2012 +0100
380.2 +++ b/remoting/server/web/type.web.api/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
380.3 @@ -26,11 +26,11 @@
380.4 dist.javadoc.dir=${dist.dir}/javadoc
380.5 endorsed.classpath=
380.6 excludes=
380.7 -file.reference.org-netbeans-api-java-classpath.jar=../../../../server/lib/org-netbeans-api-java-classpath.jar
380.8 -file.reference.org-netbeans-modules-java-source.jar=../../../../server/lib/org-netbeans-modules-java-source.jar
380.9 -file.reference.org-netbeans-modules-jumpto.jar=../../../../server/lib/org-netbeans-modules-jumpto.jar
380.10 -file.reference.org-netbeans-modules-parsing-lucene.jar=../../../../server/lib/org-netbeans-modules-parsing-lucene.jar
380.11 -file.reference.org-openide-filesystems.jar=../../../../server/lib/org-openide-filesystems.jar
380.12 +file.reference.org-netbeans-api-java-classpath.jar=../../../../lib/org-netbeans-api-java-classpath.jar
380.13 +file.reference.org-netbeans-modules-java-source.jar=../../../../lib/org-netbeans-modules-java-source.jar
380.14 +file.reference.org-netbeans-modules-jumpto.jar=../../../../lib/org-netbeans-modules-jumpto.jar
380.15 +file.reference.org-netbeans-modules-parsing-lucene.jar=../../../../lib/org-netbeans-modules-parsing-lucene.jar
380.16 +file.reference.org-openide-filesystems.jar=../../../../lib/org-openide-filesystems.jar
380.17 file.reference.util-commons.jar-1=../../../ide/api/external/util-commons.jar
380.18 file.reference.util-pojson.jar-1=../../../ide/api/external/util-pojson.jar
380.19 includes=**
381.1 --- a/remoting/server/web/type.web.api/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
381.2 +++ b/remoting/server/web/type.web.api/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
381.3 @@ -12,7 +12,7 @@
381.4 </test-roots>
381.5 </data>
381.6 <libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
381.7 - <definitions>../../../../server/lib/nblibraries.properties</definitions>
381.8 + <definitions>../../../../lib/nblibraries.properties</definitions>
381.9 </libraries>
381.10 <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
381.11 <reference>
382.1 --- a/remoting/server/web/usages.web.api/nbproject/build-impl.xml Fri Jan 27 13:35:56 2012 +0100
382.2 +++ b/remoting/server/web/usages.web.api/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
382.3 @@ -43,7 +43,7 @@
382.4 <property file="nbproject/private/private.properties"/>
382.5 </target>
382.6 <target name="-pre-init-libraries">
382.7 - <property location="../../../../server/lib/nblibraries.properties" name="libraries.path"/>
382.8 + <property location="../../../../lib/nblibraries.properties" name="libraries.path"/>
382.9 <dirname file="${libraries.path}" property="libraries.dir.nativedirsep"/>
382.10 <pathconvert dirsep="/" property="libraries.dir">
382.11 <path path="${libraries.dir.nativedirsep}"/>
382.12 @@ -181,6 +181,7 @@
382.13 </and>
382.14 </condition>
382.15 <property name="run.jvmargs" value=""/>
382.16 + <property name="run.jvmargs.ide" value=""/>
382.17 <property name="javac.compilerargs" value=""/>
382.18 <property name="work.dir" value="${basedir}"/>
382.19 <condition property="no.deps">
382.20 @@ -382,6 +383,7 @@
382.21 <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
382.22 <jvmarg value="-ea"/>
382.23 <jvmarg line="${run.jvmargs}"/>
382.24 + <jvmarg line="${run.jvmargs.ide}"/>
382.25 </junit>
382.26 </sequential>
382.27 </macrodef>
382.28 @@ -488,6 +490,7 @@
382.29 <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
382.30 <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
382.31 <jvmarg line="${run.jvmargs}"/>
382.32 + <jvmarg line="${run.jvmargs.ide}"/>
382.33 <classpath>
382.34 <path path="@{classpath}"/>
382.35 </classpath>
382.36 @@ -511,6 +514,7 @@
382.37 <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
382.38 <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
382.39 <jvmarg line="${run.jvmargs}"/>
382.40 + <jvmarg line="${run.jvmargs.ide}"/>
382.41 <classpath>
382.42 <path path="@{classpath}"/>
382.43 </classpath>
382.44 @@ -1076,9 +1080,12 @@
382.45 <target name="-check-call-dep">
382.46 <property file="${call.built.properties}" prefix="already.built."/>
382.47 <condition property="should.call.dep">
382.48 - <not>
382.49 - <isset property="already.built.${call.subproject}"/>
382.50 - </not>
382.51 + <and>
382.52 + <not>
382.53 + <isset property="already.built.${call.subproject}"/>
382.54 + </not>
382.55 + <available file="${call.script}"/>
382.56 + </and>
382.57 </condition>
382.58 </target>
382.59 <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
383.1 --- a/remoting/server/web/usages.web.api/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
383.2 +++ b/remoting/server/web/usages.web.api/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
383.3 @@ -1,8 +1,8 @@
383.4 -build.xml.data.CRC32=9115199c
383.5 +build.xml.data.CRC32=0ab46c18
383.6 build.xml.script.CRC32=3bd67ab1
383.7 -build.xml.stylesheet.CRC32=28e38971@1.45.0.45
383.8 +build.xml.stylesheet.CRC32=28e38971@1.51.0.46
383.9 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
383.10 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
383.11 -nbproject/build-impl.xml.data.CRC32=9115199c
383.12 -nbproject/build-impl.xml.script.CRC32=1420fc13
383.13 -nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.48.0.46
383.14 +nbproject/build-impl.xml.data.CRC32=0ab46c18
383.15 +nbproject/build-impl.xml.script.CRC32=b8043472
383.16 +nbproject/build-impl.xml.stylesheet.CRC32=96b566c0@1.51.0.46
384.1 --- a/remoting/server/web/usages.web.api/nbproject/project.properties Fri Jan 27 13:35:56 2012 +0100
384.2 +++ b/remoting/server/web/usages.web.api/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
384.3 @@ -25,9 +25,9 @@
384.4 dist.jar=${dist.dir}/usages.web.api.jar
384.5 dist.javadoc.dir=${dist.dir}/javadoc
384.6 excludes=
384.7 -file.reference.org-netbeans-modules-parsing-api.jar=../../../../server/lib/org-netbeans-modules-parsing-api.jar
384.8 -file.reference.org-netbeans-modules-parsing-lucene.jar=../../../../server/lib/org-netbeans-modules-parsing-lucene.jar
384.9 -file.reference.org-openide-filesystems.jar=../../../../server/lib/org-openide-filesystems.jar
384.10 +file.reference.org-netbeans-modules-parsing-api.jar=../../../../lib/org-netbeans-modules-parsing-api.jar
384.11 +file.reference.org-netbeans-modules-parsing-lucene.jar=../../../../lib/org-netbeans-modules-parsing-lucene.jar
384.12 +file.reference.org-openide-filesystems.jar=../../../../lib/org-openide-filesystems.jar
384.13 file.reference.util-commons.jar=../../../ide/api/external/util-commons.jar
384.14 file.reference.util-pojson.jar=../../../ide/api/external/util-pojson.jar
384.15 includes=**
385.1 --- a/remoting/server/web/usages.web.api/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
385.2 +++ b/remoting/server/web/usages.web.api/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
385.3 @@ -12,7 +12,7 @@
385.4 </test-roots>
385.5 </data>
385.6 <libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
385.7 - <definitions>../../../../server/lib/nblibraries.properties</definitions>
385.8 + <definitions>../../../../lib/nblibraries.properties</definitions>
385.9 </libraries>
385.10 <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
385.11 <reference>
386.1 --- a/remoting/server/web/web.main/build.xml Fri Jan 27 13:35:56 2012 +0100
386.2 +++ b/remoting/server/web/web.main/build.xml Mon Mar 12 21:10:10 2012 +0100
386.3 @@ -71,4 +71,5 @@
386.4 nbproject/build-impl.xml file.
386.5
386.6 -->
386.7 + <target name="build" depends="jar" />
386.8 </project>
387.1 --- a/remoting/server/web/web.main/nbproject/build-impl.xml Fri Jan 27 13:35:56 2012 +0100
387.2 +++ b/remoting/server/web/web.main/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
387.3 @@ -43,7 +43,7 @@
387.4 <property file="nbproject/private/private.properties"/>
387.5 </target>
387.6 <target name="-pre-init-libraries">
387.7 - <property location="../../../../server/lib/nblibraries.properties" name="libraries.path"/>
387.8 + <property location="../../../../lib/nblibraries.properties" name="libraries.path"/>
387.9 <dirname file="${libraries.path}" property="libraries.dir.nativedirsep"/>
387.10 <pathconvert dirsep="/" property="libraries.dir">
387.11 <path path="${libraries.dir.nativedirsep}"/>
387.12 @@ -181,6 +181,7 @@
387.13 </and>
387.14 </condition>
387.15 <property name="run.jvmargs" value=""/>
387.16 + <property name="run.jvmargs.ide" value=""/>
387.17 <property name="javac.compilerargs" value=""/>
387.18 <property name="work.dir" value="${basedir}"/>
387.19 <condition property="no.deps">
387.20 @@ -382,6 +383,7 @@
387.21 <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
387.22 <jvmarg value="-ea"/>
387.23 <jvmarg line="${run.jvmargs}"/>
387.24 + <jvmarg line="${run.jvmargs.ide}"/>
387.25 </junit>
387.26 </sequential>
387.27 </macrodef>
387.28 @@ -488,6 +490,7 @@
387.29 <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
387.30 <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
387.31 <jvmarg line="${run.jvmargs}"/>
387.32 + <jvmarg line="${run.jvmargs.ide}"/>
387.33 <classpath>
387.34 <path path="@{classpath}"/>
387.35 </classpath>
387.36 @@ -511,6 +514,7 @@
387.37 <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
387.38 <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
387.39 <jvmarg line="${run.jvmargs}"/>
387.40 + <jvmarg line="${run.jvmargs.ide}"/>
387.41 <classpath>
387.42 <path path="@{classpath}"/>
387.43 </classpath>
387.44 @@ -1132,9 +1136,12 @@
387.45 <target name="-check-call-dep">
387.46 <property file="${call.built.properties}" prefix="already.built."/>
387.47 <condition property="should.call.dep">
387.48 - <not>
387.49 - <isset property="already.built.${call.subproject}"/>
387.50 - </not>
387.51 + <and>
387.52 + <not>
387.53 + <isset property="already.built.${call.subproject}"/>
387.54 + </not>
387.55 + <available file="${call.script}"/>
387.56 + </and>
387.57 </condition>
387.58 </target>
387.59 <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
388.1 --- a/remoting/server/web/web.main/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
388.2 +++ b/remoting/server/web/web.main/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
388.3 @@ -3,6 +3,6 @@
388.4 build.xml.stylesheet.CRC32=28e38971@1.46.0.46
388.5 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
388.6 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
388.7 -nbproject/build-impl.xml.data.CRC32=f536def6
388.8 -nbproject/build-impl.xml.script.CRC32=49b6ec04
388.9 -nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.48.0.46
388.10 +nbproject/build-impl.xml.data.CRC32=e98004c7
388.11 +nbproject/build-impl.xml.script.CRC32=7c935a2a
388.12 +nbproject/build-impl.xml.stylesheet.CRC32=96b566c0@1.51.0.46
389.1 --- a/remoting/server/web/web.main/nbproject/project.properties Fri Jan 27 13:35:56 2012 +0100
389.2 +++ b/remoting/server/web/web.main/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
389.3 @@ -1,5 +1,6 @@
389.4 annotation.processing.enabled=true
389.5 annotation.processing.enabled.in.editor=false
389.6 +annotation.processing.processors.list=
389.7 annotation.processing.run.all.processors=true
389.8 annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
389.9 application.title=web.main
389.10 @@ -26,20 +27,19 @@
389.11 dist.javadoc.dir=${dist.dir}/javadoc
389.12 endorsed.classpath=
389.13 excludes=
389.14 -file.reference.org-netbeans-api-java-classpath.jar=../../../../server/lib/org-netbeans-api-java-classpath.jar
389.15 -file.reference.org-netbeans-modules-java-hints.jar=../../../../server/lib/org-netbeans-modules-java-hints.jar
389.16 -file.reference.org-netbeans-modules-java-project.jar=../../../../server/lib/org-netbeans-modules-java-project.jar
389.17 -file.reference.org-netbeans-modules-java-source.jar=../../../../server/lib/org-netbeans-modules-java-source.jar
389.18 -file.reference.org-netbeans-modules-jumpto.jar=../../../../server/lib/org-netbeans-modules-jumpto.jar
389.19 -file.reference.org-netbeans-modules-masterfs.jar=../../../../server/lib/org-netbeans-modules-masterfs.jar
389.20 -file.reference.org-netbeans-modules-parsing-api.jar=../../../../server/lib/org-netbeans-modules-parsing-api.jar
389.21 -file.reference.org-netbeans-modules-parsing-lucene.jar=../../../../server/lib/org-netbeans-modules-parsing-lucene.jar
389.22 -file.reference.org-netbeans-modules-projectapi.jar=../../../../server/lib/org-netbeans-modules-projectapi.jar
389.23 -file.reference.org-netbeans-modules-sendopts.jar=../../../../server/lib/org-netbeans-modules-sendopts.jar
389.24 -file.reference.org-netbeans-spi-editor-hints.jar=../../../../server/lib/org-netbeans-spi-editor-hints.jar
389.25 -file.reference.org-openide-filesystems.jar=../../../../server/lib/org-openide-filesystems.jar
389.26 -file.reference.org-openide-util-lookup.jar=../../../../server/lib/org-openide-util-lookup.jar
389.27 -file.reference.org-openide-util.jar=../../../../server/lib/org-openide-util.jar
389.28 +file.reference.org-netbeans-api-java-classpath.jar=../../../../lib/org-netbeans-api-java-classpath.jar
389.29 +file.reference.org-netbeans-modules-java-hints.jar=../../../../lib/org-netbeans-modules-java-hints.jar
389.30 +file.reference.org-netbeans-modules-java-project.jar=../../../../lib/org-netbeans-modules-java-project.jar
389.31 +file.reference.org-netbeans-modules-java-source.jar=../../../../lib/org-netbeans-modules-java-source.jar
389.32 +file.reference.org-netbeans-modules-jumpto.jar=../../../../lib/org-netbeans-modules-jumpto.jar
389.33 +file.reference.org-netbeans-modules-masterfs.jar=../../../../lib/org-netbeans-modules-masterfs.jar
389.34 +file.reference.org-netbeans-modules-parsing-api.jar=../../../../lib/org-netbeans-modules-parsing-api.jar
389.35 +file.reference.org-netbeans-modules-parsing-lucene.jar=../../../../lib/org-netbeans-modules-parsing-lucene.jar
389.36 +file.reference.org-netbeans-modules-projectapi.jar=../../../../lib/org-netbeans-modules-projectapi.jar
389.37 +file.reference.org-netbeans-spi-editor-hints.jar=../../../../lib/org-netbeans-spi-editor-hints.jar
389.38 +file.reference.org-openide-filesystems.jar=../../../../lib/org-openide-filesystems.jar
389.39 +file.reference.org-openide-util-lookup.jar=../../../../lib/org-openide-util-lookup.jar
389.40 +file.reference.org-openide-util.jar=../../../../lib/org-openide-util.jar
389.41 file.reference.util-commons.jar=../../../ide/api/external/util-commons.jar
389.42 file.reference.util-pojson.jar=../../../ide/api/external/util-pojson.jar
389.43 includes=**
389.44 @@ -60,7 +60,6 @@
389.45 ${file.reference.org-netbeans-modules-parsing-api.jar}:\
389.46 ${file.reference.org-netbeans-modules-parsing-lucene.jar}:\
389.47 ${file.reference.org-netbeans-modules-projectapi.jar}:\
389.48 - ${file.reference.org-netbeans-modules-sendopts.jar}:\
389.49 ${file.reference.org-netbeans-spi-editor-hints.jar}:\
389.50 ${file.reference.org-openide-filesystems.jar}:\
389.51 ${file.reference.org-openide-util-lookup.jar}:\
390.1 --- a/remoting/server/web/web.main/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
390.2 +++ b/remoting/server/web/web.main/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
390.3 @@ -12,7 +12,7 @@
390.4 </test-roots>
390.5 </data>
390.6 <libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
390.7 - <definitions>../../../../server/lib/nblibraries.properties</definitions>
390.8 + <definitions>../../../../lib/nblibraries.properties</definitions>
390.9 </libraries>
390.10 <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
390.11 <reference>
391.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
391.2 +++ b/sandbox/old-modules/api/build.xml Mon Mar 12 21:10:10 2012 +0100
391.3 @@ -0,0 +1,23 @@
391.4 +<?xml version="1.0" encoding="UTF-8"?>
391.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
391.6 +<!-- for some information on what you could do (e.g. targets to override). -->
391.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
391.8 +<project name="org.netbeans.modules.jackpot30.api" default="netbeans" basedir=".">
391.9 + <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.api.</description>
391.10 + <import file="nbproject/build-impl.xml"/>
391.11 + <import file="${suite.dir}/findbugs-import.xml"/>
391.12 +
391.13 + <!-- Mac -->
391.14 + <pathconvert property="retouche.javac">
391.15 + <fileset dir="${nbplatform.active.dir}">
391.16 + <filename name="java*/modules/ext/javac*.jar"/>
391.17 + </fileset>
391.18 + <fileset dir="${java.home}/../Classes" erroronmissingdir="false">
391.19 + <include name="*.jar"/>
391.20 + </fileset>
391.21 + </pathconvert>
391.22 + <echo message="${retouche.javac}"/>
391.23 + <condition property="bootclasspath.mac" value="${retouche.javac}">
391.24 + <os family="mac"/>
391.25 + </condition>
391.26 +</project>
392.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
392.2 +++ b/sandbox/old-modules/api/manifest.mf Mon Mar 12 21:10:10 2012 +0100
392.3 @@ -0,0 +1,7 @@
392.4 +Manifest-Version: 1.0
392.5 +AutoUpdate-Show-In-Client: false
392.6 +OpenIDE-Module: org.netbeans.modules.jackpot30.api
392.7 +OpenIDE-Module-Implementation-Version: 1
392.8 +OpenIDE-Module-Layer: org/netbeans/modules/jackpot30/impl/resources/layer.xml
392.9 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/impl/resources/Bundle.properties
392.10 +
393.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
393.2 +++ b/sandbox/old-modules/api/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
393.3 @@ -0,0 +1,45 @@
393.4 +<?xml version="1.0" encoding="UTF-8"?>
393.5 +<!--
393.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
393.7 +*** EDIT ../build.xml INSTEAD ***
393.8 +-->
393.9 +<project name="org.netbeans.modules.jackpot30.api-impl" basedir="..">
393.10 + <fail message="Please build using Ant 1.7.1 or higher.">
393.11 + <condition>
393.12 + <not>
393.13 + <antversion atleast="1.7.1"/>
393.14 + </not>
393.15 + </condition>
393.16 + </fail>
393.17 + <property file="nbproject/private/suite-private.properties"/>
393.18 + <property file="nbproject/suite.properties"/>
393.19 + <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
393.20 + <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
393.21 + <property file="${suite.dir}/nbproject/platform.properties"/>
393.22 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
393.23 + <attribute name="name"/>
393.24 + <attribute name="value"/>
393.25 + <sequential>
393.26 + <property name="@{name}" value="${@{value}}"/>
393.27 + </sequential>
393.28 + </macrodef>
393.29 + <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
393.30 + <attribute name="property"/>
393.31 + <attribute name="value"/>
393.32 + <sequential>
393.33 + <property name="@{property}" value="@{value}"/>
393.34 + </sequential>
393.35 + </macrodef>
393.36 + <property file="${user.properties.file}"/>
393.37 + <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
393.38 + <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
393.39 + <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
393.40 + <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
393.41 + <condition>
393.42 + <not>
393.43 + <contains string="${cluster.path.evaluated}" substring="platform"/>
393.44 + </not>
393.45 + </condition>
393.46 + </fail>
393.47 + <import file="${harness.dir}/build.xml"/>
393.48 +</project>
394.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
394.2 +++ b/sandbox/old-modules/api/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
394.3 @@ -0,0 +1,8 @@
394.4 +build.xml.data.CRC32=f9c1509c
394.5 +build.xml.script.CRC32=0abcaef9
394.6 +build.xml.stylesheet.CRC32=79c3b980@1.28.0.7
394.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
394.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
394.9 +nbproject/build-impl.xml.data.CRC32=6500fcd0
394.10 +nbproject/build-impl.xml.script.CRC32=c4574e66
394.11 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.49
395.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
395.2 +++ b/sandbox/old-modules/api/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
395.3 @@ -0,0 +1,3 @@
395.4 +javac.source=1.5
395.5 +javac.compilerargs=-Xlint -Xlint:-serial
395.6 +spec.version.base=1.16.0
396.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
396.2 +++ b/sandbox/old-modules/api/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
396.3 @@ -0,0 +1,437 @@
396.4 +<?xml version="1.0" encoding="UTF-8"?>
396.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
396.6 + <type>org.netbeans.modules.apisupport.project</type>
396.7 + <configuration>
396.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
396.9 + <code-name-base>org.netbeans.modules.jackpot30.api</code-name-base>
396.10 + <suite-component/>
396.11 + <module-dependencies>
396.12 + <dependency>
396.13 + <code-name-base>org.jdesktop.layout</code-name-base>
396.14 + <build-prerequisite/>
396.15 + <compile-dependency/>
396.16 + <run-dependency>
396.17 + <release-version>1</release-version>
396.18 + <specification-version>1.7.0.103</specification-version>
396.19 + </run-dependency>
396.20 + </dependency>
396.21 + <dependency>
396.22 + <code-name-base>org.netbeans.api.annotations.common</code-name-base>
396.23 + <build-prerequisite/>
396.24 + <compile-dependency/>
396.25 + <run-dependency>
396.26 + <release-version>1</release-version>
396.27 + <specification-version>1.0</specification-version>
396.28 + </run-dependency>
396.29 + </dependency>
396.30 + <dependency>
396.31 + <code-name-base>org.netbeans.api.java.classpath</code-name-base>
396.32 + <build-prerequisite/>
396.33 + <compile-dependency/>
396.34 + <run-dependency>
396.35 + <release-version>1</release-version>
396.36 + <specification-version>1.19</specification-version>
396.37 + </run-dependency>
396.38 + </dependency>
396.39 + <dependency>
396.40 + <code-name-base>org.netbeans.api.progress</code-name-base>
396.41 + <build-prerequisite/>
396.42 + <compile-dependency/>
396.43 + <run-dependency>
396.44 + <release-version>1</release-version>
396.45 + <specification-version>1.13.0.1</specification-version>
396.46 + </run-dependency>
396.47 + </dependency>
396.48 + <dependency>
396.49 + <code-name-base>org.netbeans.libs.javacapi</code-name-base>
396.50 + <build-prerequisite/>
396.51 + <compile-dependency/>
396.52 + <run-dependency>
396.53 + <specification-version>7.5.0.3</specification-version>
396.54 + </run-dependency>
396.55 + </dependency>
396.56 + <dependency>
396.57 + <code-name-base>org.netbeans.libs.javacimpl</code-name-base>
396.58 + <build-prerequisite/>
396.59 + <compile-dependency/>
396.60 + <run-dependency>
396.61 + <release-version>1</release-version>
396.62 + <implementation-version/>
396.63 + </run-dependency>
396.64 + </dependency>
396.65 + <dependency>
396.66 + <code-name-base>org.netbeans.libs.lucene</code-name-base>
396.67 + <build-prerequisite/>
396.68 + <compile-dependency/>
396.69 + <run-dependency>
396.70 + <release-version>1-3</release-version>
396.71 + <specification-version>2.13</specification-version>
396.72 + </run-dependency>
396.73 + </dependency>
396.74 + <dependency>
396.75 + <code-name-base>org.netbeans.modules.diff</code-name-base>
396.76 + <build-prerequisite/>
396.77 + <compile-dependency/>
396.78 + <run-dependency>
396.79 + <release-version>1</release-version>
396.80 + <implementation-version/>
396.81 + </run-dependency>
396.82 + </dependency>
396.83 + <dependency>
396.84 + <code-name-base>org.netbeans.modules.editor</code-name-base>
396.85 + <build-prerequisite/>
396.86 + <compile-dependency/>
396.87 + <run-dependency>
396.88 + <release-version>3</release-version>
396.89 + <specification-version>1.56.0.5.13.6</specification-version>
396.90 + </run-dependency>
396.91 + </dependency>
396.92 + <dependency>
396.93 + <code-name-base>org.netbeans.modules.editor.lib</code-name-base>
396.94 + <build-prerequisite/>
396.95 + <compile-dependency/>
396.96 + <run-dependency>
396.97 + <release-version>1-3</release-version>
396.98 + <specification-version>1.38.0.9.2</specification-version>
396.99 + </run-dependency>
396.100 + </dependency>
396.101 + <dependency>
396.102 + <code-name-base>org.netbeans.modules.editor.lib2</code-name-base>
396.103 + <build-prerequisite/>
396.104 + <compile-dependency/>
396.105 + <run-dependency>
396.106 + <release-version>1</release-version>
396.107 + <specification-version>1.13.0.2</specification-version>
396.108 + </run-dependency>
396.109 + </dependency>
396.110 + <dependency>
396.111 + <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
396.112 + <build-prerequisite/>
396.113 + <compile-dependency/>
396.114 + <run-dependency>
396.115 + <release-version>1</release-version>
396.116 + <specification-version>1.12</specification-version>
396.117 + </run-dependency>
396.118 + </dependency>
396.119 + <dependency>
396.120 + <code-name-base>org.netbeans.modules.editor.settings</code-name-base>
396.121 + <build-prerequisite/>
396.122 + <compile-dependency/>
396.123 + <run-dependency>
396.124 + <release-version>1</release-version>
396.125 + <specification-version>1.25</specification-version>
396.126 + </run-dependency>
396.127 + </dependency>
396.128 + <dependency>
396.129 + <code-name-base>org.netbeans.modules.jackpot30.remoting.api</code-name-base>
396.130 + <build-prerequisite/>
396.131 + <compile-dependency/>
396.132 + <run-dependency>
396.133 + <specification-version>1.0</specification-version>
396.134 + </run-dependency>
396.135 + </dependency>
396.136 + <dependency>
396.137 + <code-name-base>org.netbeans.modules.java.editor</code-name-base>
396.138 + <build-prerequisite/>
396.139 + <compile-dependency/>
396.140 + <run-dependency>
396.141 + <release-version>1</release-version>
396.142 + <implementation-version/>
396.143 + </run-dependency>
396.144 + </dependency>
396.145 + <dependency>
396.146 + <code-name-base>org.netbeans.modules.java.hints</code-name-base>
396.147 + <build-prerequisite/>
396.148 + <compile-dependency/>
396.149 + <run-dependency>
396.150 + <release-version>1</release-version>
396.151 + <implementation-version/>
396.152 + </run-dependency>
396.153 + </dependency>
396.154 + <dependency>
396.155 + <code-name-base>org.netbeans.modules.java.lexer</code-name-base>
396.156 + <build-prerequisite/>
396.157 + <compile-dependency/>
396.158 + <run-dependency>
396.159 + <release-version>1</release-version>
396.160 + <specification-version>1.9</specification-version>
396.161 + </run-dependency>
396.162 + </dependency>
396.163 + <dependency>
396.164 + <code-name-base>org.netbeans.modules.java.platform</code-name-base>
396.165 + <build-prerequisite/>
396.166 + <compile-dependency/>
396.167 + <run-dependency>
396.168 + <release-version>1</release-version>
396.169 + <specification-version>1.12</specification-version>
396.170 + </run-dependency>
396.171 + </dependency>
396.172 + <dependency>
396.173 + <code-name-base>org.netbeans.modules.java.preprocessorbridge</code-name-base>
396.174 + <build-prerequisite/>
396.175 + <compile-dependency/>
396.176 + <run-dependency>
396.177 + <implementation-version/>
396.178 + </run-dependency>
396.179 + </dependency>
396.180 + <dependency>
396.181 + <code-name-base>org.netbeans.modules.java.source</code-name-base>
396.182 + <build-prerequisite/>
396.183 + <compile-dependency/>
396.184 + <run-dependency>
396.185 + <implementation-version/>
396.186 + </run-dependency>
396.187 + </dependency>
396.188 + <dependency>
396.189 + <code-name-base>org.netbeans.modules.lexer</code-name-base>
396.190 + <build-prerequisite/>
396.191 + <compile-dependency/>
396.192 + <run-dependency>
396.193 + <release-version>2</release-version>
396.194 + <specification-version>1.34</specification-version>
396.195 + </run-dependency>
396.196 + </dependency>
396.197 + <dependency>
396.198 + <code-name-base>org.netbeans.modules.options.api</code-name-base>
396.199 + <build-prerequisite/>
396.200 + <compile-dependency/>
396.201 + <run-dependency>
396.202 + <release-version>1</release-version>
396.203 + <specification-version>1.20</specification-version>
396.204 + </run-dependency>
396.205 + </dependency>
396.206 + <dependency>
396.207 + <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
396.208 + <build-prerequisite/>
396.209 + <compile-dependency/>
396.210 + <run-dependency>
396.211 + <release-version>1</release-version>
396.212 + <implementation-version/>
396.213 + </run-dependency>
396.214 + </dependency>
396.215 + <dependency>
396.216 + <code-name-base>org.netbeans.modules.projectapi</code-name-base>
396.217 + <build-prerequisite/>
396.218 + <compile-dependency/>
396.219 + <run-dependency>
396.220 + <release-version>1</release-version>
396.221 + <specification-version>1.24</specification-version>
396.222 + </run-dependency>
396.223 + </dependency>
396.224 + <dependency>
396.225 + <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
396.226 + <build-prerequisite/>
396.227 + <compile-dependency/>
396.228 + <run-dependency>
396.229 + <release-version>1</release-version>
396.230 + <specification-version>1.35.0.6</specification-version>
396.231 + </run-dependency>
396.232 + </dependency>
396.233 + <dependency>
396.234 + <code-name-base>org.netbeans.modules.queries</code-name-base>
396.235 + <build-prerequisite/>
396.236 + <compile-dependency/>
396.237 + <run-dependency>
396.238 + <release-version>1</release-version>
396.239 + <specification-version>1.15</specification-version>
396.240 + </run-dependency>
396.241 + </dependency>
396.242 + <dependency>
396.243 + <code-name-base>org.netbeans.modules.refactoring.api</code-name-base>
396.244 + <build-prerequisite/>
396.245 + <compile-dependency/>
396.246 + <run-dependency>
396.247 + <specification-version>1.6</specification-version>
396.248 + </run-dependency>
396.249 + </dependency>
396.250 + <dependency>
396.251 + <code-name-base>org.netbeans.modules.refactoring.java</code-name-base>
396.252 + <build-prerequisite/>
396.253 + <compile-dependency/>
396.254 + <run-dependency>
396.255 + <release-version>1</release-version>
396.256 + <specification-version>1.6</specification-version>
396.257 + </run-dependency>
396.258 + </dependency>
396.259 + <dependency>
396.260 + <code-name-base>org.netbeans.modules.sendopts</code-name-base>
396.261 + <build-prerequisite/>
396.262 + <compile-dependency/>
396.263 + <run-dependency>
396.264 + <release-version>2</release-version>
396.265 + <specification-version>2.4</specification-version>
396.266 + </run-dependency>
396.267 + </dependency>
396.268 + <dependency>
396.269 + <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
396.270 + <build-prerequisite/>
396.271 + <compile-dependency/>
396.272 + <run-dependency>
396.273 + <release-version>0-1</release-version>
396.274 + <specification-version>1.7.0.7.2</specification-version>
396.275 + </run-dependency>
396.276 + </dependency>
396.277 + <dependency>
396.278 + <code-name-base>org.openide.awt</code-name-base>
396.279 + <build-prerequisite/>
396.280 + <compile-dependency/>
396.281 + <run-dependency>
396.282 + <specification-version>7.7.0.1</specification-version>
396.283 + </run-dependency>
396.284 + </dependency>
396.285 + <dependency>
396.286 + <code-name-base>org.openide.dialogs</code-name-base>
396.287 + <build-prerequisite/>
396.288 + <compile-dependency/>
396.289 + <run-dependency>
396.290 + <specification-version>7.10</specification-version>
396.291 + </run-dependency>
396.292 + </dependency>
396.293 + <dependency>
396.294 + <code-name-base>org.openide.filesystems</code-name-base>
396.295 + <build-prerequisite/>
396.296 + <compile-dependency/>
396.297 + <run-dependency>
396.298 + <specification-version>7.21.0.1.1</specification-version>
396.299 + </run-dependency>
396.300 + </dependency>
396.301 + <dependency>
396.302 + <code-name-base>org.openide.loaders</code-name-base>
396.303 + <build-prerequisite/>
396.304 + <compile-dependency/>
396.305 + <run-dependency>
396.306 + <specification-version>7.5</specification-version>
396.307 + </run-dependency>
396.308 + </dependency>
396.309 + <dependency>
396.310 + <code-name-base>org.openide.modules</code-name-base>
396.311 + <build-prerequisite/>
396.312 + <compile-dependency/>
396.313 + <run-dependency>
396.314 + <specification-version>7.10</specification-version>
396.315 + </run-dependency>
396.316 + </dependency>
396.317 + <dependency>
396.318 + <code-name-base>org.openide.nodes</code-name-base>
396.319 + <build-prerequisite/>
396.320 + <compile-dependency/>
396.321 + <run-dependency>
396.322 + <specification-version>7.9.0.1</specification-version>
396.323 + </run-dependency>
396.324 + </dependency>
396.325 + <dependency>
396.326 + <code-name-base>org.openide.text</code-name-base>
396.327 + <build-prerequisite/>
396.328 + <compile-dependency/>
396.329 + <run-dependency>
396.330 + <specification-version>6.22</specification-version>
396.331 + </run-dependency>
396.332 + </dependency>
396.333 + <dependency>
396.334 + <code-name-base>org.openide.util</code-name-base>
396.335 + <build-prerequisite/>
396.336 + <compile-dependency/>
396.337 + <run-dependency>
396.338 + <specification-version>8.0</specification-version>
396.339 + </run-dependency>
396.340 + </dependency>
396.341 + <dependency>
396.342 + <code-name-base>org.openide.util.lookup</code-name-base>
396.343 + <build-prerequisite/>
396.344 + <compile-dependency/>
396.345 + <run-dependency>
396.346 + <specification-version>8.0.0.1</specification-version>
396.347 + </run-dependency>
396.348 + </dependency>
396.349 + <dependency>
396.350 + <code-name-base>org.openide.windows</code-name-base>
396.351 + <build-prerequisite/>
396.352 + <compile-dependency/>
396.353 + <run-dependency>
396.354 + <specification-version>6.27</specification-version>
396.355 + </run-dependency>
396.356 + </dependency>
396.357 + </module-dependencies>
396.358 + <test-dependencies>
396.359 + <test-type>
396.360 + <name>unit</name>
396.361 + <test-dependency>
396.362 + <code-name-base>org.netbeans.bootstrap</code-name-base>
396.363 + </test-dependency>
396.364 + <test-dependency>
396.365 + <code-name-base>org.netbeans.core.startup</code-name-base>
396.366 + </test-dependency>
396.367 + <test-dependency>
396.368 + <code-name-base>org.netbeans.insane</code-name-base>
396.369 + <compile-dependency/>
396.370 + </test-dependency>
396.371 + <test-dependency>
396.372 + <code-name-base>org.netbeans.libs.junit4</code-name-base>
396.373 + <compile-dependency/>
396.374 + </test-dependency>
396.375 + <test-dependency>
396.376 + <code-name-base>org.netbeans.modules.classfile</code-name-base>
396.377 + </test-dependency>
396.378 + <test-dependency>
396.379 + <code-name-base>org.netbeans.modules.defaults</code-name-base>
396.380 + </test-dependency>
396.381 + <test-dependency>
396.382 + <code-name-base>org.netbeans.modules.editor</code-name-base>
396.383 + </test-dependency>
396.384 + <test-dependency>
396.385 + <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
396.386 + </test-dependency>
396.387 + <test-dependency>
396.388 + <code-name-base>org.netbeans.modules.editor.settings</code-name-base>
396.389 + </test-dependency>
396.390 + <test-dependency>
396.391 + <code-name-base>org.netbeans.modules.editor.settings.storage</code-name-base>
396.392 + </test-dependency>
396.393 + <test-dependency>
396.394 + <code-name-base>org.netbeans.modules.editor.util</code-name-base>
396.395 + </test-dependency>
396.396 + <test-dependency>
396.397 + <code-name-base>org.netbeans.modules.jackpot30.common.test</code-name-base>
396.398 + <compile-dependency/>
396.399 + </test-dependency>
396.400 + <test-dependency>
396.401 + <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
396.402 + <recursive/>
396.403 + <compile-dependency/>
396.404 + </test-dependency>
396.405 + <test-dependency>
396.406 + <code-name-base>org.netbeans.modules.java.hints</code-name-base>
396.407 + <compile-dependency/>
396.408 + </test-dependency>
396.409 + <test-dependency>
396.410 + <code-name-base>org.netbeans.modules.java.hints.declarative</code-name-base>
396.411 + </test-dependency>
396.412 + <test-dependency>
396.413 + <code-name-base>org.netbeans.modules.java.lexer</code-name-base>
396.414 + </test-dependency>
396.415 + <test-dependency>
396.416 + <code-name-base>org.netbeans.modules.masterfs</code-name-base>
396.417 + </test-dependency>
396.418 + <test-dependency>
396.419 + <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
396.420 + <compile-dependency/>
396.421 + </test-dependency>
396.422 + <test-dependency>
396.423 + <code-name-base>org.netbeans.modules.progress.ui</code-name-base>
396.424 + </test-dependency>
396.425 + <test-dependency>
396.426 + <code-name-base>org.netbeans.modules.projectui</code-name-base>
396.427 + </test-dependency>
396.428 + <test-dependency>
396.429 + <code-name-base>org.openidex.util</code-name-base>
396.430 + </test-dependency>
396.431 + </test-type>
396.432 + </test-dependencies>
396.433 + <public-packages>
396.434 + <package>org.netbeans.modules.jackpot30.spi</package>
396.435 + <package>org.netbeans.modules.jackpot30.spi.refactoring</package>
396.436 + <package>org.netbeans.modules.jackpot30.spi.support</package>
396.437 + </public-packages>
396.438 + </data>
396.439 + </configuration>
396.440 +</project>
397.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
397.2 +++ b/sandbox/old-modules/api/nbproject/suite.properties Mon Mar 12 21:10:10 2012 +0100
397.3 @@ -0,0 +1,1 @@
397.4 +suite.dir=${basedir}/..
398.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
398.2 +++ b/sandbox/old-modules/api/src/org/netbeans/modules/jackpot30/impl/examples/Bundle.properties Mon Mar 12 21:10:10 2012 +0100
398.3 @@ -0,0 +1,46 @@
398.4 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
398.5 +#
398.6 +# Copyright 2010 Oracle and/or its affiliates. All rights reserved.
398.7 +#
398.8 +# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
398.9 +# Other names may be trademarks of their respective owners.
398.10 +#
398.11 +# The contents of this file are subject to the terms of either the GNU
398.12 +# General Public License Version 2 only ("GPL") or the Common
398.13 +# Development and Distribution License("CDDL") (collectively, the
398.14 +# "License"). You may not use this file except in compliance with the
398.15 +# License. You can obtain a copy of the License at
398.16 +# http://www.netbeans.org/cddl-gplv2.html
398.17 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
398.18 +# specific language governing permissions and limitations under the
398.19 +# License. When distributing the software, include this License Header
398.20 +# Notice in each file and include the License file at
398.21 +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
398.22 +# particular file as subject to the "Classpath" exception as provided
398.23 +# by Oracle in the GPL Version 2 section of the License file that
398.24 +# accompanied this code. If applicable, add the following below the
398.25 +# License Header, with the fields enclosed by brackets [] replaced by
398.26 +# your own identifying information:
398.27 +# "Portions Copyrighted [year] [name of copyright owner]"
398.28 +#
398.29 +# If you wish your version of this file to be governed by only the CDDL
398.30 +# or only the GPL Version 2, indicate your decision by adding
398.31 +# "[Contributor] elects to include this software in this distribution
398.32 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
398.33 +# single choice of license, a recipient has the option to distribute
398.34 +# your version of this file under either the CDDL, the GPL Version 2 or
398.35 +# to extend the choice of license to its licensees as provided above.
398.36 +# However, if you add GPL Version 2 code and therefore, elected the GPL
398.37 +# Version 2 license, then the option applies only if the new code is
398.38 +# made subject to such option by the copyright holder.
398.39 +#
398.40 +# Contributor(s):
398.41 +#
398.42 +# Portions Copyrighted 2010 Sun Microsystems, Inc.
398.43 +
398.44 +double-checked-locking=Double Checked Locking
398.45 +double-checked-locking-verify=Double Checked Locking Strict
398.46 +double-checked-locking-fix=Double Checked Locking
398.47 +new-string=New String Creation
398.48 +lambda-candidate=Find candidates for Lambda expression
398.49 +ExamplesList.pattern.contentType=text/x-javahints
399.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
399.2 +++ b/sandbox/old-modules/api/src/org/netbeans/modules/jackpot30/impl/examples/Example.java Mon Mar 12 21:10:10 2012 +0100
399.3 @@ -0,0 +1,83 @@
399.4 +/*
399.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
399.6 + *
399.7 + * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
399.8 + *
399.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
399.10 + * Other names may be trademarks of their respective owners.
399.11 + *
399.12 + * The contents of this file are subject to the terms of either the GNU
399.13 + * General Public License Version 2 only ("GPL") or the Common
399.14 + * Development and Distribution License("CDDL") (collectively, the
399.15 + * "License"). You may not use this file except in compliance with the
399.16 + * License. You can obtain a copy of the License at
399.17 + * http://www.netbeans.org/cddl-gplv2.html
399.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
399.19 + * specific language governing permissions and limitations under the
399.20 + * License. When distributing the software, include this License Header
399.21 + * Notice in each file and include the License file at
399.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
399.23 + * particular file as subject to the "Classpath" exception as provided
399.24 + * by Oracle in the GPL Version 2 section of the License file that
399.25 + * accompanied this code. If applicable, add the following below the
399.26 + * License Header, with the fields enclosed by brackets [] replaced by
399.27 + * your own identifying information:
399.28 + * "Portions Copyrighted [year] [name of copyright owner]"
399.29 + *
399.30 + * If you wish your version of this file to be governed by only the CDDL
399.31 + * or only the GPL Version 2, indicate your decision by adding
399.32 + * "[Contributor] elects to include this software in this distribution
399.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
399.34 + * single choice of license, a recipient has the option to distribute
399.35 + * your version of this file under either the CDDL, the GPL Version 2 or
399.36 + * to extend the choice of license to its licensees as provided above.
399.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
399.38 + * Version 2 license, then the option applies only if the new code is
399.39 + * made subject to such option by the copyright holder.
399.40 + *
399.41 + * Contributor(s):
399.42 + *
399.43 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
399.44 + */
399.45 +
399.46 +package org.netbeans.modules.jackpot30.impl.examples;
399.47 +
399.48 +import java.util.Set;
399.49 +import org.openide.util.NbBundle;
399.50 +
399.51 +/**
399.52 + *
399.53 + * @author lahvac
399.54 + */
399.55 +public class Example {
399.56 +
399.57 + private final String key;
399.58 + private final String code;
399.59 + private final Set<Option> options;
399.60 +
399.61 + Example(String key, String code, Set<Option> options) {
399.62 + this.key = key;
399.63 + this.code = code;
399.64 + this.options = options;
399.65 + }
399.66 +
399.67 + String getKey() {
399.68 + return key;
399.69 + }
399.70 +
399.71 + public String getDisplayName() {
399.72 + return NbBundle.getMessage(LoadExamples.class, key);
399.73 + }
399.74 +
399.75 + public String getCode() {
399.76 + return code;
399.77 + }
399.78 +
399.79 + public Set<Option> getOptions() {
399.80 + return options;
399.81 + }
399.82 +
399.83 + public enum Option {
399.84 + VERIFY, FIX;
399.85 + }
399.86 +}
400.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
400.2 +++ b/sandbox/old-modules/api/src/org/netbeans/modules/jackpot30/impl/examples/ExamplesList.form Mon Mar 12 21:10:10 2012 +0100
400.3 @@ -0,0 +1,95 @@
400.4 +<?xml version="1.0" encoding="UTF-8" ?>
400.5 +
400.6 +<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
400.7 + <AuxValues>
400.8 + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
400.9 + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
400.10 + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
400.11 + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
400.12 + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
400.13 + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
400.14 + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
400.15 + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
400.16 + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
400.17 + </AuxValues>
400.18 +
400.19 + <Layout>
400.20 + <DimensionLayout dim="0">
400.21 + <Group type="103" groupAlignment="0" attributes="0">
400.22 + <Group type="102" alignment="1" attributes="0">
400.23 + <EmptySpace max="-2" attributes="0"/>
400.24 + <Group type="103" groupAlignment="1" attributes="0">
400.25 + <Component id="jScrollPane2" alignment="0" pref="376" max="32767" attributes="0"/>
400.26 + <Component id="jScrollPane1" alignment="0" pref="376" max="32767" attributes="0"/>
400.27 + <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
400.28 + </Group>
400.29 + <EmptySpace max="-2" attributes="0"/>
400.30 + </Group>
400.31 + </Group>
400.32 + </DimensionLayout>
400.33 + <DimensionLayout dim="1">
400.34 + <Group type="103" groupAlignment="0" attributes="0">
400.35 + <Group type="102" alignment="0" attributes="0">
400.36 + <EmptySpace max="-2" attributes="0"/>
400.37 + <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
400.38 + <EmptySpace max="-2" attributes="0"/>
400.39 + <Component id="jScrollPane1" pref="130" max="32767" attributes="0"/>
400.40 + <EmptySpace max="-2" attributes="0"/>
400.41 + <Component id="jScrollPane2" min="-2" pref="119" max="-2" attributes="0"/>
400.42 + <EmptySpace max="-2" attributes="0"/>
400.43 + </Group>
400.44 + </Group>
400.45 + </DimensionLayout>
400.46 + </Layout>
400.47 + <SubComponents>
400.48 + <Component class="javax.swing.JLabel" name="jLabel1">
400.49 + <Properties>
400.50 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
400.51 + <Connection code="convertor.getHeader()" type="code"/>
400.52 + </Property>
400.53 + </Properties>
400.54 + </Component>
400.55 + <Container class="javax.swing.JScrollPane" name="jScrollPane1">
400.56 + <AuxValues>
400.57 + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
400.58 + </AuxValues>
400.59 +
400.60 + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
400.61 + <SubComponents>
400.62 + <Component class="javax.swing.JList" name="list">
400.63 + <Properties>
400.64 + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
400.65 + <StringArray count="5">
400.66 + <StringItem index="0" value="Item 1"/>
400.67 + <StringItem index="1" value="Item 2"/>
400.68 + <StringItem index="2" value="Item 3"/>
400.69 + <StringItem index="3" value="Item 4"/>
400.70 + <StringItem index="4" value="Item 5"/>
400.71 + </StringArray>
400.72 + </Property>
400.73 + </Properties>
400.74 + <Events>
400.75 + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="listMouseClicked"/>
400.76 + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="listValueChanged"/>
400.77 + </Events>
400.78 + </Component>
400.79 + </SubComponents>
400.80 + </Container>
400.81 + <Container class="javax.swing.JScrollPane" name="jScrollPane2">
400.82 + <AuxValues>
400.83 + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
400.84 + </AuxValues>
400.85 +
400.86 + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
400.87 + <SubComponents>
400.88 + <Component class="javax.swing.JEditorPane" name="pattern">
400.89 + <Properties>
400.90 + <Property name="contentType" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
400.91 + <ResourceString bundle="org/netbeans/modules/jackpot30/impl/examples/Bundle.properties" key="ExamplesList.pattern.contentType" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
400.92 + </Property>
400.93 + </Properties>
400.94 + </Component>
400.95 + </SubComponents>
400.96 + </Container>
400.97 + </SubComponents>
400.98 +</Form>
401.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
401.2 +++ b/sandbox/old-modules/api/src/org/netbeans/modules/jackpot30/impl/examples/ExamplesList.java Mon Mar 12 21:10:10 2012 +0100
401.3 @@ -0,0 +1,223 @@
401.4 +/*
401.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
401.6 + *
401.7 + * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
401.8 + *
401.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
401.10 + * Other names may be trademarks of their respective owners.
401.11 + *
401.12 + * The contents of this file are subject to the terms of either the GNU
401.13 + * General Public License Version 2 only ("GPL") or the Common
401.14 + * Development and Distribution License("CDDL") (collectively, the
401.15 + * "License"). You may not use this file except in compliance with the
401.16 + * License. You can obtain a copy of the License at
401.17 + * http://www.netbeans.org/cddl-gplv2.html
401.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
401.19 + * specific language governing permissions and limitations under the
401.20 + * License. When distributing the software, include this License Header
401.21 + * Notice in each file and include the License file at
401.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
401.23 + * particular file as subject to the "Classpath" exception as provided
401.24 + * by Oracle in the GPL Version 2 section of the License file that
401.25 + * accompanied this code. If applicable, add the following below the
401.26 + * License Header, with the fields enclosed by brackets [] replaced by
401.27 + * your own identifying information:
401.28 + * "Portions Copyrighted [year] [name of copyright owner]"
401.29 + *
401.30 + * If you wish your version of this file to be governed by only the CDDL
401.31 + * or only the GPL Version 2, indicate your decision by adding
401.32 + * "[Contributor] elects to include this software in this distribution
401.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
401.34 + * single choice of license, a recipient has the option to distribute
401.35 + * your version of this file under either the CDDL, the GPL Version 2 or
401.36 + * to extend the choice of license to its licensees as provided above.
401.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
401.38 + * Version 2 license, then the option applies only if the new code is
401.39 + * made subject to such option by the copyright holder.
401.40 + *
401.41 + * Contributor(s):
401.42 + *
401.43 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
401.44 + */
401.45 +package org.netbeans.modules.jackpot30.impl.examples;
401.46 +
401.47 +import java.awt.Component;
401.48 +import java.awt.Dialog;
401.49 +import java.awt.Rectangle;
401.50 +import java.util.Collections;
401.51 +import java.util.Set;
401.52 +import javax.swing.DefaultListCellRenderer;
401.53 +import javax.swing.DefaultListModel;
401.54 +import javax.swing.JList;
401.55 +import javax.swing.text.BadLocationException;
401.56 +import org.netbeans.modules.jackpot30.impl.examples.Example.Option;
401.57 +import org.openide.DialogDescriptor;
401.58 +import org.openide.DialogDisplayer;
401.59 +import org.openide.util.Exceptions;
401.60 +
401.61 +/**
401.62 + *
401.63 + * @author lahvac
401.64 + */
401.65 +public class ExamplesList<T> extends javax.swing.JPanel {
401.66 +
401.67 + private final DialogDescription<T> convertor;
401.68 + private final Class<T> dataClass;
401.69 +
401.70 + public ExamplesList(Iterable<? extends T> data, DialogDescription<T> convertor, Class<T> dataClass, Set<Option> require, Set<Option> forbidden) {
401.71 + this.convertor = convertor;
401.72 + this.dataClass = dataClass;
401.73 +
401.74 + initComponents();
401.75 +
401.76 + DefaultListModel listModel = new DefaultListModel();
401.77 +
401.78 + for (T t : data) {
401.79 + Set<Option> options = convertor.getOptions(t);
401.80 + if (!options.containsAll(require)) continue;
401.81 + if (!Collections.disjoint(options, forbidden)) continue;
401.82 +
401.83 + listModel.addElement(t);
401.84 + }
401.85 +
401.86 + list.setModel(listModel);
401.87 + list.setCellRenderer(new ExamplesRenderer());
401.88 + list.setSelectedIndex(0);
401.89 + }
401.90 +
401.91 + /** This method is called from within the constructor to
401.92 + * initialize the form.
401.93 + * WARNING: Do NOT modify this code. The content of this method is
401.94 + * always regenerated by the Form Editor.
401.95 + */
401.96 + @SuppressWarnings("unchecked")
401.97 + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
401.98 + private void initComponents() {
401.99 +
401.100 + jLabel1 = new javax.swing.JLabel();
401.101 + jScrollPane1 = new javax.swing.JScrollPane();
401.102 + list = new javax.swing.JList();
401.103 + jScrollPane2 = new javax.swing.JScrollPane();
401.104 + pattern = new javax.swing.JEditorPane();
401.105 +
401.106 + jLabel1.setText(convertor.getHeader());
401.107 +
401.108 + list.setModel(new javax.swing.AbstractListModel() {
401.109 + String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
401.110 + public int getSize() { return strings.length; }
401.111 + public Object getElementAt(int i) { return strings[i]; }
401.112 + });
401.113 + list.addMouseListener(new java.awt.event.MouseAdapter() {
401.114 + public void mouseClicked(java.awt.event.MouseEvent evt) {
401.115 + listMouseClicked(evt);
401.116 + }
401.117 + });
401.118 + list.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
401.119 + public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
401.120 + listValueChanged(evt);
401.121 + }
401.122 + });
401.123 + jScrollPane1.setViewportView(list);
401.124 +
401.125 + pattern.setContentType(org.openide.util.NbBundle.getMessage(ExamplesList.class, "ExamplesList.pattern.contentType")); // NOI18N
401.126 + jScrollPane2.setViewportView(pattern);
401.127 +
401.128 + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
401.129 + this.setLayout(layout);
401.130 + layout.setHorizontalGroup(
401.131 + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
401.132 + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
401.133 + .addContainerGap()
401.134 + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
401.135 + .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
401.136 + .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
401.137 + .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING))
401.138 + .addContainerGap())
401.139 + );
401.140 + layout.setVerticalGroup(
401.141 + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
401.142 + .addGroup(layout.createSequentialGroup()
401.143 + .addContainerGap()
401.144 + .addComponent(jLabel1)
401.145 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
401.146 + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE)
401.147 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
401.148 + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
401.149 + .addContainerGap())
401.150 + );
401.151 + }// </editor-fold>//GEN-END:initComponents
401.152 +
401.153 + private void listMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_listMouseClicked
401.154 + if (evt.getClickCount() > 1) {
401.155 + desc.setValue(DialogDescriptor.OK_OPTION);
401.156 + dialog.setVisible(false);
401.157 + }
401.158 + }//GEN-LAST:event_listMouseClicked
401.159 +
401.160 + private void listValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_listValueChanged
401.161 + T ex = dataClass.cast(list.getSelectedValue());
401.162 +
401.163 + pattern.setText(convertor.getCode(ex));
401.164 +
401.165 + try {
401.166 + Rectangle rect = pattern.modelToView(0);
401.167 +
401.168 + if (rect != null) {
401.169 + pattern.scrollRectToVisible(rect);
401.170 + }
401.171 + } catch (BadLocationException ex1) {
401.172 + Exceptions.printStackTrace(ex1);
401.173 + }
401.174 + }//GEN-LAST:event_listValueChanged
401.175 +
401.176 + // Variables declaration - do not modify//GEN-BEGIN:variables
401.177 + private javax.swing.JLabel jLabel1;
401.178 + private javax.swing.JScrollPane jScrollPane1;
401.179 + private javax.swing.JScrollPane jScrollPane2;
401.180 + private javax.swing.JList list;
401.181 + private javax.swing.JEditorPane pattern;
401.182 + // End of variables declaration//GEN-END:variables
401.183 +
401.184 + private DialogDescriptor desc;
401.185 + private Dialog dialog;
401.186 +
401.187 + public void setDialog(DialogDescriptor desc, Dialog dialog) {
401.188 + this.desc = desc;
401.189 + this.dialog = dialog;
401.190 + }
401.191 +
401.192 + public T getSelectedExample() {
401.193 + return dataClass.cast(list.getSelectedValue());
401.194 + }
401.195 +
401.196 + private class ExamplesRenderer extends DefaultListCellRenderer {
401.197 + @Override
401.198 + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
401.199 + value = convertor.getDisplayName(dataClass.cast(value));
401.200 + return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
401.201 + }
401.202 + }
401.203 +
401.204 + public static <T> T chooseExample(Iterable<? extends T> examplesList, DialogDescription<T> convertor, Class<T> dataClass, Set<Option> require, Set<Option> forbidden) {
401.205 + ExamplesList<T> examples = new ExamplesList<T>(examplesList, convertor, dataClass, require, forbidden);
401.206 + DialogDescriptor dd = new DialogDescriptor(examples, convertor.getCaption(), true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, null);
401.207 + Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
401.208 +
401.209 + examples.setDialog(dd, dialog);
401.210 + dialog.setVisible(true);
401.211 +
401.212 + if (dd.getValue() == DialogDescriptor.OK_OPTION) {
401.213 + return examples.getSelectedExample();
401.214 + }
401.215 +
401.216 + return null;
401.217 + }
401.218 +
401.219 + public interface DialogDescription<T> {
401.220 + public String getCaption();
401.221 + public String getHeader();
401.222 + public String getDisplayName(T t);
401.223 + public String getCode(T t);
401.224 + public Set<Option> getOptions(T t);
401.225 + }
401.226 +}
402.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
402.2 +++ b/sandbox/old-modules/api/src/org/netbeans/modules/jackpot30/impl/examples/LoadExamples.java Mon Mar 12 21:10:10 2012 +0100
402.3 @@ -0,0 +1,135 @@
402.4 +/*
402.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
402.6 + *
402.7 + * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
402.8 + *
402.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
402.10 + * Other names may be trademarks of their respective owners.
402.11 + *
402.12 + * The contents of this file are subject to the terms of either the GNU
402.13 + * General Public License Version 2 only ("GPL") or the Common
402.14 + * Development and Distribution License("CDDL") (collectively, the
402.15 + * "License"). You may not use this file except in compliance with the
402.16 + * License. You can obtain a copy of the License at
402.17 + * http://www.netbeans.org/cddl-gplv2.html
402.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
402.19 + * specific language governing permissions and limitations under the
402.20 + * License. When distributing the software, include this License Header
402.21 + * Notice in each file and include the License file at
402.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
402.23 + * particular file as subject to the "Classpath" exception as provided
402.24 + * by Oracle in the GPL Version 2 section of the License file that
402.25 + * accompanied this code. If applicable, add the following below the
402.26 + * License Header, with the fields enclosed by brackets [] replaced by
402.27 + * your own identifying information:
402.28 + * "Portions Copyrighted [year] [name of copyright owner]"
402.29 + *
402.30 + * If you wish your version of this file to be governed by only the CDDL
402.31 + * or only the GPL Version 2, indicate your decision by adding
402.32 + * "[Contributor] elects to include this software in this distribution
402.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
402.34 + * single choice of license, a recipient has the option to distribute
402.35 + * your version of this file under either the CDDL, the GPL Version 2 or
402.36 + * to extend the choice of license to its licensees as provided above.
402.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
402.38 + * Version 2 license, then the option applies only if the new code is
402.39 + * made subject to such option by the copyright holder.
402.40 + *
402.41 + * Contributor(s):
402.42 + *
402.43 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
402.44 + */
402.45 +
402.46 +package org.netbeans.modules.jackpot30.impl.examples;
402.47 +
402.48 +import java.io.File;
402.49 +import java.io.IOException;
402.50 +import java.io.InputStream;
402.51 +import java.util.Collections;
402.52 +import java.util.EnumSet;
402.53 +import java.util.LinkedList;
402.54 +import java.util.List;
402.55 +import java.util.Set;
402.56 +import java.util.regex.Pattern;
402.57 +import org.netbeans.modules.jackpot30.impl.examples.Example.Option;
402.58 +import org.openide.filesystems.FileUtil;
402.59 +import org.openide.modules.InstalledFileLocator;
402.60 +import org.openide.util.Exceptions;
402.61 +
402.62 +/**
402.63 + *
402.64 + * @author lahvac
402.65 + */
402.66 +public class LoadExamples {
402.67 +
402.68 + public static Iterable<? extends Example> loadExamples() {
402.69 + return loadExamples("examples.list");
402.70 + }
402.71 +
402.72 + private static final Pattern EXAMPLE_SPLIT = Pattern.compile("^%%", Pattern.MULTILINE);
402.73 +
402.74 + static Iterable<? extends Example> loadExamples(String examplesListName) {
402.75 + String examplesList = loadToString(examplesListName);
402.76 +
402.77 + if (examplesList == null) return Collections.emptyList();
402.78 +
402.79 + List<Example> examples = new LinkedList<Example>();
402.80 +
402.81 + for (String exampleName : examplesList.split("\n")) {
402.82 + if (exampleName.isEmpty()) continue;
402.83 +
402.84 + String exampleCode = loadToString(exampleName);
402.85 +
402.86 + for (String oneExample : EXAMPLE_SPLIT.split(exampleCode)) {
402.87 + if (oneExample.isEmpty()) continue;
402.88 +
402.89 + String[] parts = oneExample.split("\n", 2);
402.90 + String key = null;
402.91 + Set<Option> options = EnumSet.noneOf(Option.class);
402.92 +
402.93 + for (String option : parts[0].split(",")) {
402.94 + if (option.startsWith("example=")) {
402.95 + key = option.substring("example=".length());
402.96 + continue;
402.97 + }
402.98 +
402.99 + options.add(Option.valueOf(option.toUpperCase()));
402.100 + }
402.101 +
402.102 + examples.add(new Example(key, parts[1], options));
402.103 + }
402.104 + }
402.105 +
402.106 + return examples;
402.107 + }
402.108 +
402.109 + private static String loadToString(String name) {
402.110 + InputStream examplesList = null;
402.111 +
402.112 + try {
402.113 + examplesList = LoadExamples.class.getResourceAsStream(name);
402.114 +
402.115 + if (examplesList == null) return null;
402.116 +
402.117 + StringBuilder result = new StringBuilder();
402.118 + int read;
402.119 +
402.120 + while ((read = examplesList.read()) != (-1)) {
402.121 + result.append((char) read);
402.122 + }
402.123 +
402.124 + return result.toString();
402.125 + } catch (IOException ex) {
402.126 + Exceptions.printStackTrace(ex);
402.127 + return null;
402.128 + } finally {
402.129 + if (examplesList != null) {
402.130 + try {
402.131 + examplesList.close();
402.132 + } catch (IOException ex) {
402.133 + Exceptions.printStackTrace(ex);
402.134 + }
402.135 + }
402.136 + }
402.137 + }
402.138 +}
403.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
403.2 +++ b/sandbox/old-modules/api/src/org/netbeans/modules/jackpot30/impl/examples/double-checked-locking.example Mon Mar 12 21:10:10 2012 +0100
403.3 @@ -0,0 +1,33 @@
403.4 +%%example=double-checked-locking
403.5 +if ($var == null) {
403.6 + $preinit$;
403.7 + synchronized ($lock) {
403.8 + if ($var == null) {
403.9 + $s2$;
403.10 + }
403.11 + }
403.12 +}
403.13 +%%example=double-checked-locking-verify,verify
403.14 +if ($var == null) {
403.15 + $preinit$;
403.16 + synchronized ($lock) {
403.17 + if ($var == null) {
403.18 + $s2$;
403.19 + }
403.20 + }
403.21 +} :: !hasModifier($var, Modifier.VOLATILE);;
403.22 +%%example=double-checked-locking-fix,verify,fix
403.23 +if ($var == null) {
403.24 + $preinit$;
403.25 + synchronized ($lock) {
403.26 + if ($var == null) {
403.27 + $s2$;
403.28 + }
403.29 + }
403.30 +} :: !hasModifier($var, Modifier.VOLATILE)
403.31 +=>
403.32 +synchronized ($lock) {
403.33 + if ($var == null) {
403.34 + $s2$;
403.35 + }
403.36 +};;
404.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
404.2 +++ b/sandbox/old-modules/api/src/org/netbeans/modules/jackpot30/impl/examples/examples.list Mon Mar 12 21:10:10 2012 +0100
404.3 @@ -0,0 +1,3 @@
404.4 +double-checked-locking.example
404.5 +new-string.example
404.6 +lambda-candidate.example
405.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
405.2 +++ b/sandbox/old-modules/api/src/org/netbeans/modules/jackpot30/impl/examples/lambda-candidate.example Mon Mar 12 21:10:10 2012 +0100
405.3 @@ -0,0 +1,6 @@
405.4 +%%example=lambda-candidate
405.5 +new $type() {
405.6 + $mods$ $resultType $methodName($args$) {
405.7 + $statements$;
405.8 + }
405.9 +}
406.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
406.2 +++ b/sandbox/old-modules/api/src/org/netbeans/modules/jackpot30/impl/examples/new-string.example Mon Mar 12 21:10:10 2012 +0100
406.3 @@ -0,0 +1,5 @@
406.4 +%%example=new-string,verify
406.5 +new String($orig) :: $orig instanceof String && !matchesAny($orig, "$o.substring($s)", "$o.substring($s, $e)");;
406.6 +%%example=new-string,verify,fix
406.7 +new String($orig) :: $orig instanceof String && !matchesAny($orig, "$o.substring($s)", "$o.substring($s, $e)")
406.8 +=> $orig;;
407.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
407.2 +++ b/sandbox/old-modules/api/src/org/netbeans/modules/jackpot30/impl/hints/ExplicitFindDuplicates.java Mon Mar 12 21:10:10 2012 +0100
407.3 @@ -0,0 +1,379 @@
407.4 +/*
407.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
407.6 + *
407.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
407.8 + *
407.9 + * The contents of this file are subject to the terms of either the GNU
407.10 + * General Public License Version 2 only ("GPL") or the Common
407.11 + * Development and Distribution License("CDDL") (collectively, the
407.12 + * "License"). You may not use this file except in compliance with the
407.13 + * License. You can obtain a copy of the License at
407.14 + * http://www.netbeans.org/cddl-gplv2.html
407.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
407.16 + * specific language governing permissions and limitations under the
407.17 + * License. When distributing the software, include this License Header
407.18 + * Notice in each file and include the License file at
407.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
407.20 + * particular file as subject to the "Classpath" exception as provided
407.21 + * by Sun in the GPL Version 2 section of the License file that
407.22 + * accompanied this code. If applicable, add the following below the
407.23 + * License Header, with the fields enclosed by brackets [] replaced by
407.24 + * your own identifying information:
407.25 + * "Portions Copyrighted [year] [name of copyright owner]"
407.26 + *
407.27 + * If you wish your version of this file to be governed by only the CDDL
407.28 + * or only the GPL Version 2, indicate your decision by adding
407.29 + * "[Contributor] elects to include this software in this distribution
407.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
407.31 + * single choice of license, a recipient has the option to distribute
407.32 + * your version of this file under either the CDDL, the GPL Version 2 or
407.33 + * to extend the choice of license to its licensees as provided above.
407.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
407.35 + * Version 2 license, then the option applies only if the new code is
407.36 + * made subject to such option by the copyright holder.
407.37 + *
407.38 + * Contributor(s):
407.39 + *
407.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
407.41 + */
407.42 +
407.43 +package org.netbeans.modules.jackpot30.impl.hints;
407.44 +
407.45 +import com.sun.source.tree.BlockTree;
407.46 +import com.sun.source.tree.ExpressionTree;
407.47 +import com.sun.source.tree.NewClassTree;
407.48 +import com.sun.source.tree.StatementTree;
407.49 +import com.sun.source.tree.Tree;
407.50 +import com.sun.source.tree.Tree.Kind;
407.51 +import com.sun.source.tree.VariableTree;
407.52 +import com.sun.source.util.TreePath;
407.53 +import java.util.Collection;
407.54 +import java.util.Collections;
407.55 +import java.util.EnumSet;
407.56 +import java.util.Set;
407.57 +import javax.lang.model.type.ErrorType;
407.58 +import javax.lang.model.type.TypeKind;
407.59 +import javax.lang.model.type.TypeMirror;
407.60 +import javax.swing.SwingUtilities;
407.61 +import org.netbeans.api.java.lexer.JavaTokenId;
407.62 +import org.netbeans.api.java.source.CancellableTask;
407.63 +import org.netbeans.api.java.source.CompilationController;
407.64 +import org.netbeans.api.java.source.CompilationInfo;
407.65 +import org.netbeans.api.java.source.JavaSource;
407.66 +import org.netbeans.api.java.source.JavaSource.Phase;
407.67 +import org.netbeans.api.java.source.JavaSource.Priority;
407.68 +import org.netbeans.api.java.source.JavaSourceTaskFactory;
407.69 +import org.netbeans.api.java.source.Task;
407.70 +import org.netbeans.api.java.source.TreePathHandle;
407.71 +import org.netbeans.api.java.source.support.CaretAwareJavaSourceTaskFactory;
407.72 +import org.netbeans.api.java.source.support.SelectionAwareJavaSourceTaskFactory;
407.73 +import org.netbeans.api.lexer.TokenSequence;
407.74 +import org.netbeans.modules.jackpot30.impl.refactoring.FindDuplicatesRefactoringUI;
407.75 +import org.netbeans.modules.java.hints.jackpot.impl.Utilities;
407.76 +import org.netbeans.modules.java.hints.jackpot.impl.batch.Scopes;
407.77 +import org.netbeans.modules.refactoring.spi.ui.UI;
407.78 +import org.netbeans.spi.editor.hints.ChangeInfo;
407.79 +import org.netbeans.spi.editor.hints.ErrorDescription;
407.80 +import org.netbeans.spi.editor.hints.ErrorDescriptionFactory;
407.81 +import org.netbeans.spi.editor.hints.Fix;
407.82 +import org.netbeans.spi.editor.hints.HintsController;
407.83 +import org.netbeans.spi.editor.hints.Severity;
407.84 +import org.openide.filesystems.FileObject;
407.85 +import org.openide.util.lookup.ServiceProvider;
407.86 +
407.87 +/**
407.88 + *
407.89 + * @author lahvac
407.90 + */
407.91 +public class ExplicitFindDuplicates implements CancellableTask<CompilationInfo> {
407.92 +
407.93 + public void run(CompilationInfo info) throws Exception {
407.94 + Collection<? extends ErrorDescription> eds = computeErrorDescription(info);
407.95 +
407.96 + if (eds == null) {
407.97 + eds = Collections.emptyList();
407.98 + }
407.99 +
407.100 + HintsController.setErrors(info.getFileObject(), ExplicitFindDuplicates.class.getName(), eds);
407.101 + }
407.102 +
407.103 + private Collection<? extends ErrorDescription> computeErrorDescription(CompilationInfo info) throws Exception {
407.104 + int[] span = SelectionAwareJavaSourceTaskFactory.getLastSelection(info.getFileObject());
407.105 +
407.106 + if (span == null) {
407.107 + return null;
407.108 + }
407.109 +
407.110 + TreePath selection = selectionForExpressionHack(info, span[0], span[1]);
407.111 +
407.112 + if (selection == null) {
407.113 + if (selectionForStatementsHack(info, span[0], span[1], new int[2]) == null) {
407.114 + return null;
407.115 + }
407.116 + }
407.117 +
407.118 + Fix f = new FixImpl(info.getFileObject(), span[0], span[1]);
407.119 + int caret = CaretAwareJavaSourceTaskFactory.getLastPosition(info.getFileObject());
407.120 + ErrorDescription ed = ErrorDescriptionFactory.createErrorDescription(Severity.HINT, "Look for Duplicates", Collections.singletonList(f), info.getFileObject(), caret, caret);
407.121 +
407.122 + return Collections.singletonList(ed);
407.123 + }
407.124 +
407.125 + public void cancel() {
407.126 + //XXX
407.127 + }
407.128 +
407.129 + static Tree resolveAndGeneralizePattern(CompilationInfo info, int start, int end) {
407.130 + TreePath selection = selectionForExpressionHack(info, start, end);
407.131 +
407.132 + if (selection == null) {
407.133 + int[] statementSpan = new int[2];
407.134 + TreePathHandle statementSelection = selectionForStatementsHack(info, start, end, statementSpan);
407.135 +
407.136 + if (statementSelection == null) {
407.137 + return null;
407.138 + }
407.139 +
407.140 + selection = statementSelection.resolve(info);
407.141 +
407.142 + if (selection == null) {
407.143 + return null; //XXX
407.144 + }
407.145 +
407.146 + return Utilities.generalizePattern(info, selection, statementSpan[0], statementSpan[1]);
407.147 + } else {
407.148 + return Utilities.generalizePattern(info, selection);
407.149 + }
407.150 + }
407.151 +
407.152 + private static final class FixImpl implements Fix {
407.153 +
407.154 + private final FileObject file;
407.155 + private final int start;
407.156 + private final int end;
407.157 +
407.158 + public FixImpl(FileObject file, int start, int end) {
407.159 + this.file = file;
407.160 + this.start = start;
407.161 + this.end = end;
407.162 + }
407.163 +
407.164 + public String getText() {
407.165 + return "Look for Duplicates in Opened Projects";
407.166 + }
407.167 +
407.168 + public ChangeInfo implement() throws Exception {
407.169 + JavaSource.forFileObject(file).runUserActionTask(new Task<CompilationController>() {
407.170 + public void run(CompilationController cc) throws Exception {
407.171 + cc.toPhase(Phase.RESOLVED);
407.172 +
407.173 + Tree generalized = resolveAndGeneralizePattern(cc, start, end);
407.174 +
407.175 + if (generalized == null) {
407.176 + return ;
407.177 + }
407.178 +
407.179 + final String pattern = generalized.toString(); //XXX
407.180 +
407.181 + SwingUtilities.invokeLater(new Runnable() {
407.182 + public void run() {
407.183 + UI.openRefactoringUI(new FindDuplicatesRefactoringUI(pattern, Scopes.allOpenedProjectsScope()));
407.184 + }
407.185 + });
407.186 + }
407.187 + }, true);
407.188 +
407.189 + return null;
407.190 + }
407.191 +
407.192 + }
407.193 +
407.194 + private static final Set<TypeKind> NOT_ACCEPTED_TYPES = EnumSet.of(TypeKind.NONE, TypeKind.OTHER);
407.195 +
407.196 + static TreePath selectionForExpressionHack(CompilationInfo info, int start, int end) {
407.197 + return validateSelection(info, start, end, NOT_ACCEPTED_TYPES);
407.198 + }
407.199 +
407.200 + static TreePathHandle selectionForStatementsHack(CompilationInfo info, int start, int end, int[] outSpan) {
407.201 + return validateSelectionForIntroduceMethod(info, start, end, outSpan);
407.202 + }
407.203 +
407.204 + private static final Set<JavaTokenId> WHITESPACES = EnumSet.of(JavaTokenId.WHITESPACE, JavaTokenId.BLOCK_COMMENT, JavaTokenId.LINE_COMMENT, JavaTokenId.JAVADOC_COMMENT);
407.205 + static int[] ignoreWhitespaces(CompilationInfo ci, int start, int end) {
407.206 + TokenSequence<JavaTokenId> ts = ci.getTokenHierarchy().tokenSequence(JavaTokenId.language());
407.207 +
407.208 + if (ts == null) {
407.209 + return new int[] {start, end};
407.210 + }
407.211 +
407.212 + ts.move(start);
407.213 +
407.214 + if (ts.moveNext()) {
407.215 + boolean wasMoveNext = true;
407.216 +
407.217 + while (WHITESPACES.contains(ts.token().id()) && (wasMoveNext = ts.moveNext()))
407.218 + ;
407.219 +
407.220 + if (wasMoveNext && ts.offset() > start)
407.221 + start = ts.offset();
407.222 + }
407.223 +
407.224 + ts.move(end);
407.225 +
407.226 + while (ts.movePrevious() && WHITESPACES.contains(ts.token().id()) && ts.offset() < end)
407.227 + end = ts.offset();
407.228 +
407.229 + return new int[] {start, end};
407.230 + }
407.231 +
407.232 + private static boolean isInsideClass(TreePath tp) {
407.233 + while (tp != null) {
407.234 + if (tp.getLeaf().getKind() == Kind.CLASS)
407.235 + return true;
407.236 +
407.237 + tp = tp.getParentPath();
407.238 + }
407.239 +
407.240 + return false;
407.241 + }
407.242 +
407.243 + private static TreePath validateSelection(CompilationInfo ci, int start, int end, Set<TypeKind> ignoredTypes) {
407.244 + TreePath tp = ci.getTreeUtilities().pathFor((start + end) / 2 + 1);
407.245 +
407.246 + for ( ; tp != null; tp = tp.getParentPath()) {
407.247 + Tree leaf = tp.getLeaf();
407.248 +
407.249 + if (!ExpressionTree.class.isAssignableFrom(leaf.getKind().asInterface()))
407.250 + continue;
407.251 +
407.252 + long treeStart = ci.getTrees().getSourcePositions().getStartPosition(ci.getCompilationUnit(), leaf);
407.253 + long treeEnd = ci.getTrees().getSourcePositions().getEndPosition(ci.getCompilationUnit(), leaf);
407.254 +
407.255 + if (treeStart != start || treeEnd != end) {
407.256 + continue;
407.257 + }
407.258 +
407.259 + TypeMirror type = ci.getTrees().getTypeMirror(tp);
407.260 +
407.261 + if (type != null && type.getKind() == TypeKind.ERROR) {
407.262 + type = ci.getTrees().getOriginalType((ErrorType) type);
407.263 + }
407.264 +
407.265 + if (type == null || ignoredTypes.contains(type.getKind()))
407.266 + continue;
407.267 +
407.268 + if(tp.getLeaf().getKind() == Kind.ASSIGNMENT)
407.269 + continue;
407.270 +
407.271 + if (tp.getLeaf().getKind() == Kind.ANNOTATION)
407.272 + continue;
407.273 +
407.274 + if (!isInsideClass(tp))
407.275 + return null;
407.276 +
407.277 + TreePath candidate = tp;
407.278 +
407.279 + tp = tp.getParentPath();
407.280 +
407.281 + while (tp != null) {
407.282 + switch (tp.getLeaf().getKind()) {
407.283 + case VARIABLE:
407.284 + VariableTree vt = (VariableTree) tp.getLeaf();
407.285 + if (vt.getInitializer() == leaf) {
407.286 + return candidate;
407.287 + } else {
407.288 + return null;
407.289 + }
407.290 + case NEW_CLASS:
407.291 + NewClassTree nct = (NewClassTree) tp.getLeaf();
407.292 +
407.293 + if (nct.getIdentifier().equals(candidate.getLeaf())) { //avoid disabling hint ie inside of anonymous class higher in treepath
407.294 + for (Tree p : nct.getArguments()) {
407.295 + if (p == leaf) {
407.296 + return candidate;
407.297 + }
407.298 + }
407.299 +
407.300 + return null;
407.301 + }
407.302 + }
407.303 +
407.304 + leaf = tp.getLeaf();
407.305 + tp = tp.getParentPath();
407.306 + }
407.307 +
407.308 + return candidate;
407.309 + }
407.310 +
407.311 + return null;
407.312 + }
407.313 +
407.314 + private static TreePathHandle validateSelectionForIntroduceMethod(CompilationInfo ci, int start, int end, int[] statementsSpan) {
407.315 + int[] span = ignoreWhitespaces(ci, Math.min(start, end), Math.max(start, end));
407.316 +
407.317 + start = span[0];
407.318 + end = span[1];
407.319 +
407.320 + if (start >= end)
407.321 + return null;
407.322 +
407.323 + TreePath tpStart = ci.getTreeUtilities().pathFor(start);
407.324 + TreePath tpEnd = ci.getTreeUtilities().pathFor(end);
407.325 +
407.326 + if (tpStart.getLeaf() != tpEnd.getLeaf() || tpStart.getLeaf().getKind() != Kind.BLOCK) {
407.327 + //??? not in the same block:
407.328 + return null;
407.329 + }
407.330 +
407.331 + int from = -1;
407.332 + int to = -1;
407.333 +
407.334 + BlockTree block = (BlockTree) tpStart.getLeaf();
407.335 + int index = 0;
407.336 +
407.337 + for (StatementTree s : block.getStatements()) {
407.338 + long sStart = ci.getTrees().getSourcePositions().getStartPosition(ci.getCompilationUnit(), s);
407.339 +
407.340 + if (sStart == start) {
407.341 + from = index;
407.342 + }
407.343 +
407.344 + if (end < sStart && to == (-1)) {
407.345 + to = index - 1;
407.346 + }
407.347 +
407.348 + index++;
407.349 + }
407.350 +
407.351 + if (from == (-1)) {
407.352 + return null;
407.353 + }
407.354 +
407.355 + if (to == (-1))
407.356 + to = block.getStatements().size() - 1;
407.357 +
407.358 + if (to < from) {
407.359 + return null;
407.360 + }
407.361 +
407.362 + statementsSpan[0] = from;
407.363 + statementsSpan[1] = to;
407.364 +
407.365 + return TreePathHandle.create(tpStart, ci);
407.366 + }
407.367 +
407.368 + @ServiceProvider(service=JavaSourceTaskFactory.class)
407.369 + public static final class FactoryImpl extends SelectionAwareJavaSourceTaskFactory {
407.370 +
407.371 + public FactoryImpl() {
407.372 + super(Phase.RESOLVED, Priority.LOW);
407.373 + }
407.374 +
407.375 + @Override
407.376 + protected CancellableTask<CompilationInfo> createTask(FileObject file) {
407.377 + return new ExplicitFindDuplicates();
407.378 + }
407.379 +
407.380 + }
407.381 +
407.382 +}
408.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
408.2 +++ b/sandbox/old-modules/api/src/org/netbeans/modules/jackpot30/impl/resources/Bundle.properties Mon Mar 12 21:10:10 2012 +0100
408.3 @@ -0,0 +1,40 @@
408.4 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
408.5 +#
408.6 +# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
408.7 +#
408.8 +# The contents of this file are subject to the terms of either the GNU
408.9 +# General Public License Version 2 only ("GPL") or the Common
408.10 +# Development and Distribution License("CDDL") (collectively, the
408.11 +# "License"). You may not use this file except in compliance with the
408.12 +# License. You can obtain a copy of the License at
408.13 +# http://www.netbeans.org/cddl-gplv2.html
408.14 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
408.15 +# specific language governing permissions and limitations under the
408.16 +# License. When distributing the software, include this License Header
408.17 +# Notice in each file and include the License file at
408.18 +# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
408.19 +# particular file as subject to the "Classpath" exception as provided
408.20 +# by Sun in the GPL Version 2 section of the License file that
408.21 +# accompanied this code. If applicable, add the following below the
408.22 +# License Header, with the fields enclosed by brackets [] replaced by
408.23 +# your own identifying information:
408.24 +# "Portions Copyrighted [year] [name of copyright owner]"
408.25 +#
408.26 +# If you wish your version of this file to be governed by only the CDDL
408.27 +# or only the GPL Version 2, indicate your decision by adding
408.28 +# "[Contributor] elects to include this software in this distribution
408.29 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
408.30 +# single choice of license, a recipient has the option to distribute
408.31 +# your version of this file under either the CDDL, the GPL Version 2 or
408.32 +# to extend the choice of license to its licensees as provided above.
408.33 +# However, if you add GPL Version 2 code and therefore, elected the GPL
408.34 +# Version 2 license, then the option applies only if the new code is
408.35 +# made subject to such option by the copyright holder.
408.36 +#
408.37 +# Contributor(s):
408.38 +#
408.39 +# Portions Copyrighted 2009 Sun Microsystems, Inc.
408.40 +
408.41 +Actions/Refactoring/org-netbeans-modules-jackpot30-impl-refactoring-ApplyPatternAction.instance=Apply Pattern
408.42 +Actions/Refactoring/org-netbeans-modules-jackpot30-impl-refactoring-FindOccurrencesAction.instance=Find Pattern Occurrences
408.43 +OpenIDE-Module-Name=Jackpot 3.0 API
409.1 Binary file sandbox/old-modules/api/src/org/netbeans/modules/jackpot30/impl/resources/examples_icon.png has changed
410.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
410.2 +++ b/sandbox/old-modules/api/src/org/netbeans/modules/jackpot30/impl/resources/layer.xml Mon Mar 12 21:10:10 2012 +0100
410.3 @@ -0,0 +1,68 @@
410.4 +<?xml version="1.0" encoding="UTF-8"?>
410.5 +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
410.6 +<filesystem>
410.7 + <folder name="Actions">
410.8 + <folder name="Refactoring">
410.9 + <file name="org-netbeans-modules-jackpot30-impl-duplicates-GlobalFindDuplicates.instance">
410.10 + <attr name="delegate" newvalue="org.netbeans.modules.jackpot30.impl.duplicates.GlobalFindDuplicates"/>
410.11 + <attr name="displayName" bundlevalue="org.netbeans.modules.jackpot30.impl.duplicates.Bundle#CTL_GlobalFindDuplicates"/>
410.12 + <attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/>
410.13 + <attr name="noIconInMenu" boolvalue="false"/>
410.14 + </file>
410.15 + <file name="org-netbeans-modules-jackpot30-impl-refactoring-ApplyPatternAction.instance">
410.16 + <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.jackpot30.impl.resources.Bundle"/>
410.17 + <attr name="delegate" newvalue="org.netbeans.modules.jackpot30.impl.refactoring.ApplyPatternAction"/>
410.18 + <attr name="displayName" bundlevalue="org.netbeans.modules.jackpot30.impl.refactoring.Bundle#CTL_ApplyPatternAction"/>
410.19 + <attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/>
410.20 + <attr name="noIconInMenu" boolvalue="false"/>
410.21 + </file>
410.22 + <file name="org-netbeans-modules-jackpot30-impl-refactoring-FindOccurrencesAction.instance">
410.23 + <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.jackpot30.impl.resources.Bundle"/>
410.24 + <attr name="delegate" newvalue="org.netbeans.modules.jackpot30.impl.refactoring.FindOccurrencesAction"/>
410.25 + <attr name="displayName" bundlevalue="org.netbeans.modules.jackpot30.impl.refactoring.Bundle#CTL_FindOccurrencesAction"/>
410.26 + <attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/>
410.27 + <attr name="noIconInMenu" boolvalue="false"/>
410.28 + </file>
410.29 + <file name="org-netbeans-modules-jackpot30-impl-refactoring-upgrade-UpgradeAction.instance">
410.30 + <attr name="delegate" newvalue="org.netbeans.modules.jackpot30.impl.refactoring.upgrade.UpgradeAction"/>
410.31 + <attr name="displayName" bundlevalue="org.netbeans.modules.jackpot30.impl.refactoring.upgrade.Bundle#CTL_UpgradeAction"/>
410.32 + <attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/>
410.33 + <attr name="noIconInMenu" boolvalue="false"/>
410.34 + </file>
410.35 + </folder>
410.36 + </folder>
410.37 +
410.38 + <!--XXX:-->
410.39 + <folder name="Menu">
410.40 + <folder name="Edit">
410.41 + <file name="org-netbeans-modules-jackpot30-impl-refactoring-FindOccurrencesAction.shadow">
410.42 + <attr name="originalFile" stringvalue="Actions/Refactoring/org-netbeans-modules-jackpot30-impl-refactoring-FindOccurrencesAction.instance"/>
410.43 + <attr name="position" intvalue="2250"/>
410.44 + </file>
410.45 + </folder>
410.46 + <folder name="Refactoring">
410.47 + <file name="org-netbeans-modules-jackpot30-impl-duplicates-GlobalFindDuplicates.shadow">
410.48 + <attr name="originalFile" stringvalue="Actions/Refactoring/org-netbeans-modules-jackpot30-impl-duplicates-GlobalFindDuplicates.instance"/>
410.49 + <attr name="position" intvalue="2300"/>
410.50 + </file>
410.51 + <file name="org-netbeans-modules-jackpot30-impl-refactoring-ApplyPatternAction.shadow">
410.52 + <attr name="originalFile" stringvalue="Actions/Refactoring/org-netbeans-modules-jackpot30-impl-refactoring-ApplyPatternAction.instance"/>
410.53 + <attr name="position" intvalue="2200"/>
410.54 + </file>
410.55 + <file name="org-netbeans-modules-jackpot30-impl-refactoring-upgrade-UpgradeAction.shadow">
410.56 + <attr name="originalFile" stringvalue="Actions/Refactoring/org-netbeans-modules-jackpot30-impl-refactoring-upgrade-UpgradeAction.instance"/>
410.57 + <attr name="position" intvalue="2187"/>
410.58 + </file>
410.59 + </folder>
410.60 + </folder>
410.61 +
410.62 + <folder name="Editors">
410.63 + <folder name="text">
410.64 + <folder name="x-java">
410.65 + <file name="org-netbeans-modules-jackpot30-impl-hints-HintsInvoker$FactoryImpl.instance"/>
410.66 + <file name="org-netbeans-modules-jackpot30-impl-indexing-CustomIndexerImpl$CustomIndexerFactoryImpl.instance"/>
410.67 + <file name="org-netbeans-modules-jackpot30-impl-duplicates-indexing-DuplicatesCustomIndexerImpl$FactoryImpl.instance"/>
410.68 + </folder>
410.69 + </folder>
410.70 + </folder>
410.71 +</filesystem>
411.1 Binary file sandbox/old-modules/api/src/org/netbeans/modules/jackpot30/impl/resources/recent_icon.png has changed
412.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
412.2 +++ b/sandbox/old-modules/api/src/org/netbeans/modules/jackpot30/spi/Hacks.java Mon Mar 12 21:10:10 2012 +0100
412.3 @@ -0,0 +1,89 @@
412.4 +/*
412.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
412.6 + *
412.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
412.8 + *
412.9 + * The contents of this file are subject to the terms of either the GNU
412.10 + * General Public License Version 2 only ("GPL") or the Common
412.11 + * Development and Distribution License("CDDL") (collectively, the
412.12 + * "License"). You may not use this file except in compliance with the
412.13 + * License. You can obtain a copy of the License at
412.14 + * http://www.netbeans.org/cddl-gplv2.html
412.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
412.16 + * specific language governing permissions and limitations under the
412.17 + * License. When distributing the software, include this License Header
412.18 + * Notice in each file and include the License file at
412.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
412.20 + * particular file as subject to the "Classpath" exception as provided
412.21 + * by Sun in the GPL Version 2 section of the License file that
412.22 + * accompanied this code. If applicable, add the following below the
412.23 + * License Header, with the fields enclosed by brackets [] replaced by
412.24 + * your own identifying information:
412.25 + * "Portions Copyrighted [year] [name of copyright owner]"
412.26 + *
412.27 + * If you wish your version of this file to be governed by only the CDDL
412.28 + * or only the GPL Version 2, indicate your decision by adding
412.29 + * "[Contributor] elects to include this software in this distribution
412.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
412.31 + * single choice of license, a recipient has the option to distribute
412.32 + * your version of this file under either the CDDL, the GPL Version 2 or
412.33 + * to extend the choice of license to its licensees as provided above.
412.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
412.35 + * Version 2 license, then the option applies only if the new code is
412.36 + * made subject to such option by the copyright holder.
412.37 + *
412.38 + * Contributor(s):
412.39 + *
412.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
412.41 + */
412.42 +
412.43 +package org.netbeans.modules.jackpot30.spi;
412.44 +
412.45 +import com.sun.source.util.TreePath;
412.46 +import java.util.ArrayList;
412.47 +import java.util.Collections;
412.48 +import java.util.LinkedList;
412.49 +import java.util.List;
412.50 +import java.util.Set;
412.51 +import java.util.concurrent.atomic.AtomicBoolean;
412.52 +import java.util.prefs.Preferences;
412.53 +import org.netbeans.api.java.source.WorkingCopy;
412.54 +import org.netbeans.api.project.Project;
412.55 +import org.netbeans.modules.java.hints.jackpot.impl.MessageImpl;
412.56 +import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchUtilities;
412.57 +import org.netbeans.modules.java.hints.jackpot.impl.hints.HintsInvoker;
412.58 +import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
412.59 +import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata;
412.60 +import org.netbeans.spi.editor.hints.ErrorDescription;
412.61 +import org.openide.util.Exceptions;
412.62 +
412.63 +/**
412.64 + *
412.65 + * @author lahvac
412.66 + */
412.67 +public class Hacks {
412.68 +
412.69 + public static interface HintPreferencesProvider {
412.70 + public Preferences findPreferences(HintMetadata hm);
412.71 + }
412.72 +
412.73 + public static void findHintsAndApplyFixes(WorkingCopy copy, Iterable<? extends HintDescription> hints, TreePath on, AtomicBoolean cancel) {
412.74 + HintsInvoker inv = new HintsInvoker(copy, cancel);
412.75 + List<ErrorDescription> errs = new ArrayList<ErrorDescription>(inv.computeHints(copy, hints));
412.76 + List<MessageImpl> problems = new LinkedList<MessageImpl>();
412.77 +
412.78 + try {
412.79 + if (BatchUtilities.applyFixes(copy, Collections.<Project, Set<String>>emptyMap(), errs, problems)) {
412.80 + throw new IllegalStateException();
412.81 + }
412.82 + } catch (IllegalStateException ex) {
412.83 + Exceptions.printStackTrace(ex);
412.84 + } catch (Exception ex) {
412.85 + Exceptions.printStackTrace(ex);
412.86 + }
412.87 +
412.88 + if (!problems.isEmpty()) {
412.89 + throw new IllegalStateException(problems.get(0).text);
412.90 + }
412.91 + }
412.92 +}
413.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
413.2 +++ b/sandbox/old-modules/api/test/unit/src/org/netbeans/modules/jackpot30/impl/TestBase.java Mon Mar 12 21:10:10 2012 +0100
413.3 @@ -0,0 +1,120 @@
413.4 +/*
413.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
413.6 + *
413.7 + * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
413.8 + *
413.9 + * The contents of this file are subject to the terms of either the GNU
413.10 + * General Public License Version 2 only ("GPL") or the Common
413.11 + * Development and Distribution License("CDDL") (collectively, the
413.12 + * "License"). You may not use this file except in compliance with the
413.13 + * License. You can obtain a copy of the License at
413.14 + * http://www.netbeans.org/cddl-gplv2.html
413.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
413.16 + * specific language governing permissions and limitations under the
413.17 + * License. When distributing the software, include this License Header
413.18 + * Notice in each file and include the License file at
413.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
413.20 + * particular file as subject to the "Classpath" exception as provided
413.21 + * by Sun in the GPL Version 2 section of the License file that
413.22 + * accompanied this code. If applicable, add the following below the
413.23 + * License Header, with the fields enclosed by brackets [] replaced by
413.24 + * your own identifying information:
413.25 + * "Portions Copyrighted [year] [name of copyright owner]"
413.26 + *
413.27 + * If you wish your version of this file to be governed by only the CDDL
413.28 + * or only the GPL Version 2, indicate your decision by adding
413.29 + * "[Contributor] elects to include this software in this distribution
413.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
413.31 + * single choice of license, a recipient has the option to distribute
413.32 + * your version of this file under either the CDDL, the GPL Version 2 or
413.33 + * to extend the choice of license to its licensees as provided above.
413.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
413.35 + * Version 2 license, then the option applies only if the new code is
413.36 + * made subject to such option by the copyright holder.
413.37 + *
413.38 + * Contributor(s):
413.39 + *
413.40 + * Portions Copyrighted 2008-2009 Sun Microsystems, Inc.
413.41 + */
413.42 +
413.43 +package org.netbeans.modules.jackpot30.impl;
413.44 +
413.45 +import java.io.File;
413.46 +import javax.swing.text.Document;
413.47 +import org.netbeans.api.java.lexer.JavaTokenId;
413.48 +import org.netbeans.api.java.source.CompilationInfo;
413.49 +import org.netbeans.api.java.source.JavaSource;
413.50 +import org.netbeans.api.java.source.JavaSource.Phase;
413.51 +import org.netbeans.api.java.source.SourceUtilsTestUtil;
413.52 +import org.netbeans.api.java.source.TestUtilities;
413.53 +import org.netbeans.api.lexer.Language;
413.54 +import org.netbeans.junit.NbTestCase;
413.55 +import org.netbeans.modules.java.source.TreeLoader;
413.56 +import org.openide.cookies.EditorCookie;
413.57 +import org.openide.filesystems.FileObject;
413.58 +import org.openide.filesystems.FileUtil;
413.59 +import org.openide.loaders.DataObject;
413.60 +
413.61 +/**
413.62 + *
413.63 + * @author Jan Lahoda
413.64 + */
413.65 +public class TestBase extends NbTestCase {
413.66 +
413.67 + public TestBase(String name) {
413.68 + super(name);
413.69 + }
413.70 +
413.71 + @Override
413.72 + protected void setUp() throws Exception {
413.73 + super.setUp();
413.74 + SourceUtilsTestUtil.prepareTest(new String[0], new Object[0]);
413.75 + TreeLoader.DISABLE_CONFINEMENT_TEST = true;
413.76 + }
413.77 +
413.78 + protected void prepareTest(String fileName, String code) throws Exception {
413.79 + clearWorkDir();
413.80 +
413.81 + FileUtil.refreshFor(File.listRoots());
413.82 +
413.83 + FileObject workFO = FileUtil.toFileObject(getWorkDir());
413.84 +
413.85 + assertNotNull(workFO);
413.86 +
413.87 + workFO.refresh();
413.88 +
413.89 + sourceRoot = workFO.createFolder("src");
413.90 + FileObject buildRoot = workFO.createFolder("build");
413.91 + FileObject cache = workFO.createFolder("cache");
413.92 +
413.93 + FileObject data = FileUtil.createData(sourceRoot, fileName);
413.94 + File dataFile = FileUtil.toFile(data);
413.95 +
413.96 + assertNotNull(dataFile);
413.97 +
413.98 + TestUtilities.copyStringToFile(dataFile, code);
413.99 +
413.100 + SourceUtilsTestUtil.prepareTest(sourceRoot, buildRoot, cache);
413.101 +
413.102 + DataObject od = DataObject.find(data);
413.103 + EditorCookie ec = od.getLookup().lookup(EditorCookie.class);
413.104 +
413.105 + assertNotNull(ec);
413.106 +
413.107 + doc = ec.openDocument();
413.108 + doc.putProperty(Language.class, JavaTokenId.language());
413.109 +
413.110 + JavaSource js = JavaSource.forFileObject(data);
413.111 +
413.112 + assertNotNull(js);
413.113 +
413.114 + info = SourceUtilsTestUtil.getCompilationInfo(js, Phase.RESOLVED);
413.115 +
413.116 + assertNotNull(info);
413.117 + }
413.118 +
413.119 + protected FileObject sourceRoot;
413.120 + protected CompilationInfo info;
413.121 + protected Document doc;
413.122 +
413.123 +}
414.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
414.2 +++ b/sandbox/old-modules/api/test/unit/src/org/netbeans/modules/jackpot30/impl/examples/LoadExamplesTest.java Mon Mar 12 21:10:10 2012 +0100
414.3 @@ -0,0 +1,71 @@
414.4 +/*
414.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
414.6 + *
414.7 + * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
414.8 + *
414.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
414.10 + * Other names may be trademarks of their respective owners.
414.11 + *
414.12 + * The contents of this file are subject to the terms of either the GNU
414.13 + * General Public License Version 2 only ("GPL") or the Common
414.14 + * Development and Distribution License("CDDL") (collectively, the
414.15 + * "License"). You may not use this file except in compliance with the
414.16 + * License. You can obtain a copy of the License at
414.17 + * http://www.netbeans.org/cddl-gplv2.html
414.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
414.19 + * specific language governing permissions and limitations under the
414.20 + * License. When distributing the software, include this License Header
414.21 + * Notice in each file and include the License file at
414.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
414.23 + * particular file as subject to the "Classpath" exception as provided
414.24 + * by Oracle in the GPL Version 2 section of the License file that
414.25 + * accompanied this code. If applicable, add the following below the
414.26 + * License Header, with the fields enclosed by brackets [] replaced by
414.27 + * your own identifying information:
414.28 + * "Portions Copyrighted [year] [name of copyright owner]"
414.29 + *
414.30 + * If you wish your version of this file to be governed by only the CDDL
414.31 + * or only the GPL Version 2, indicate your decision by adding
414.32 + * "[Contributor] elects to include this software in this distribution
414.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
414.34 + * single choice of license, a recipient has the option to distribute
414.35 + * your version of this file under either the CDDL, the GPL Version 2 or
414.36 + * to extend the choice of license to its licensees as provided above.
414.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
414.38 + * Version 2 license, then the option applies only if the new code is
414.39 + * made subject to such option by the copyright holder.
414.40 + *
414.41 + * Contributor(s):
414.42 + *
414.43 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
414.44 + */
414.45 +
414.46 +package org.netbeans.modules.jackpot30.impl.examples;
414.47 +
414.48 +import java.util.Arrays;
414.49 +import java.util.LinkedList;
414.50 +import java.util.List;
414.51 +import org.netbeans.junit.NbTestCase;
414.52 +import static org.junit.Assert.*;
414.53 +
414.54 +/**
414.55 + *
414.56 + * @author lahvac
414.57 + */
414.58 +public class LoadExamplesTest extends NbTestCase {
414.59 +
414.60 + public LoadExamplesTest(String name) {
414.61 + super(name);
414.62 + }
414.63 +
414.64 + public void testLoadExamples() {
414.65 + List<String> actual = new LinkedList<String>();
414.66 +
414.67 + for (Example e : LoadExamples.loadExamples("test-examples.list")) {
414.68 + actual.add("" + e.getKey() + ":" + e.getOptions() + ":" + e.getCode());
414.69 + }
414.70 +
414.71 + assertEquals(Arrays.asList("key1:[]:EX1\n", "key2:[VERIFY, FIX]:EX2\n", "key3:[FIX]:EX3\n"), actual);
414.72 + }
414.73 +
414.74 +}
414.75 \ No newline at end of file
415.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
415.2 +++ b/sandbox/old-modules/api/test/unit/src/org/netbeans/modules/jackpot30/impl/examples/test-example1.example Mon Mar 12 21:10:10 2012 +0100
415.3 @@ -0,0 +1,6 @@
415.4 +%%example=key1
415.5 +EX1
415.6 +%%example=key2,verify,fix
415.7 +EX2
415.8 +%%example=key3,fix
415.9 +EX3
416.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
416.2 +++ b/sandbox/old-modules/api/test/unit/src/org/netbeans/modules/jackpot30/impl/examples/test-examples.list Mon Mar 12 21:10:10 2012 +0100
416.3 @@ -0,0 +1,1 @@
416.4 +test-example1.example
417.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
417.2 +++ b/sandbox/old-modules/api/test/unit/src/org/netbeans/modules/jackpot30/impl/hints/ExplicitFindDuplicatesTest.java Mon Mar 12 21:10:10 2012 +0100
417.3 @@ -0,0 +1,138 @@
417.4 +/*
417.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
417.6 + *
417.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
417.8 + *
417.9 + * The contents of this file are subject to the terms of either the GNU
417.10 + * General Public License Version 2 only ("GPL") or the Common
417.11 + * Development and Distribution License("CDDL") (collectively, the
417.12 + * "License"). You may not use this file except in compliance with the
417.13 + * License. You can obtain a copy of the License at
417.14 + * http://www.netbeans.org/cddl-gplv2.html
417.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
417.16 + * specific language governing permissions and limitations under the
417.17 + * License. When distributing the software, include this License Header
417.18 + * Notice in each file and include the License file at
417.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
417.20 + * particular file as subject to the "Classpath" exception as provided
417.21 + * by Sun in the GPL Version 2 section of the License file that
417.22 + * accompanied this code. If applicable, add the following below the
417.23 + * License Header, with the fields enclosed by brackets [] replaced by
417.24 + * your own identifying information:
417.25 + * "Portions Copyrighted [year] [name of copyright owner]"
417.26 + *
417.27 + * If you wish your version of this file to be governed by only the CDDL
417.28 + * or only the GPL Version 2, indicate your decision by adding
417.29 + * "[Contributor] elects to include this software in this distribution
417.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
417.31 + * single choice of license, a recipient has the option to distribute
417.32 + * your version of this file under either the CDDL, the GPL Version 2 or
417.33 + * to extend the choice of license to its licensees as provided above.
417.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
417.35 + * Version 2 license, then the option applies only if the new code is
417.36 + * made subject to such option by the copyright holder.
417.37 + *
417.38 + * Contributor(s):
417.39 + *
417.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
417.41 + */
417.42 +
417.43 +package org.netbeans.modules.jackpot30.impl.hints;
417.44 +
417.45 +import com.sun.source.tree.Tree;
417.46 +import com.sun.tools.javac.tree.JCTree;
417.47 +import java.util.regex.Pattern;
417.48 +import org.netbeans.modules.jackpot30.impl.TestBase;
417.49 +import org.netbeans.modules.java.source.pretty.VeryPretty;
417.50 +import org.netbeans.modules.java.source.save.DiffContext;
417.51 +
417.52 +/**
417.53 + *
417.54 + * @author lahvac
417.55 + */
417.56 +public class ExplicitFindDuplicatesTest extends TestBase {
417.57 +
417.58 + public ExplicitFindDuplicatesTest(String name) {
417.59 + super(name);
417.60 + }
417.61 +
417.62 + public void testLocalVariablesGeneralization() throws Exception {
417.63 + performGeneralizationTest("package test;\n" +
417.64 + "public class Test {\n" +
417.65 + " private void test() {\n" +
417.66 + " |int i = 0;\n" +
417.67 + " i++;\n" +
417.68 + " int j = i;|\n" +
417.69 + " }\n" +
417.70 + "}\n" +
417.71 + "",
417.72 + "{\n" +
417.73 + " $s0$;\n" +
417.74 + " int $0 = 0;\n" +
417.75 + " $0++;\n" +
417.76 + " int $1 = $0;\n" +
417.77 + " $s1$;\n" +
417.78 + "}");
417.79 + }
417.80 +
417.81 + public void testSingleStatementPattern() throws Exception {
417.82 + performGeneralizationTest("package test;\n" +
417.83 + "public class Test {\n" +
417.84 + " private void test() {\n" +
417.85 + " int i = 0;\n" +
417.86 + " |i++;|\n" +
417.87 + " int j = i;\n" +
417.88 + " }\n" +
417.89 + "}\n" +
417.90 + "",
417.91 + "$0++;");
417.92 + }
417.93 +
417.94 + public void testExpressionPattern() throws Exception {
417.95 + performGeneralizationTest("package test;\n" +
417.96 + "public class Test {\n" +
417.97 + " private void test() {\n" +
417.98 + " int i = 0;\n" +
417.99 + " i++;\n" +
417.100 + " int j = |i|;\n" +
417.101 + " }\n" +
417.102 + "}\n" +
417.103 + "",
417.104 + "$0");
417.105 + }
417.106 +
417.107 + public void testVoidMethod() throws Exception {
417.108 + performGeneralizationTest("package test;\n" +
417.109 + "public class Test {\n" +
417.110 + " private void test() {\n" +
417.111 + " |System.err.println()|;\n" +
417.112 + " }\n" +
417.113 + "}\n" +
417.114 + "",
417.115 + "System.err.println()");
417.116 + }
417.117 +
417.118 + private void performGeneralizationTest(String code, String generalized) throws Exception {
417.119 + String[] split = code.split(Pattern.quote("|"));
417.120 +
417.121 + assertEquals(3, split.length);
417.122 +
417.123 + int start = split[0].length();
417.124 + int end = split[1].length() + start;
417.125 +
417.126 + code = split[0] + split[1] + split[2];
417.127 +
417.128 + prepareTest("test/Test.java", code);
417.129 +
417.130 + Tree generalizedTree = ExplicitFindDuplicates.resolveAndGeneralizePattern(info, start, end);
417.131 + VeryPretty vp = new VeryPretty(new DiffContext(info));
417.132 +
417.133 + vp.print((JCTree) generalizedTree);
417.134 +
417.135 + String repr = vp.toString();
417.136 +
417.137 + assertEquals(generalized.replaceAll("[ \n\t]+", " "),
417.138 + repr.replaceAll("[ \n\t]+", " "));
417.139 + }
417.140 +
417.141 +}
417.142 \ No newline at end of file
418.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
418.2 +++ b/sandbox/old-modules/api/test/unit/src/org/netbeans/modules/jackpot30/impl/pm/BulkSearchPerformance.java Mon Mar 12 21:10:10 2012 +0100
418.3 @@ -0,0 +1,226 @@
418.4 +/*
418.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
418.6 + *
418.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
418.8 + *
418.9 + * The contents of this file are subject to the terms of either the GNU
418.10 + * General Public License Version 2 only ("GPL") or the Common
418.11 + * Development and Distribution License("CDDL") (collectively, the
418.12 + * "License"). You may not use this file except in compliance with the
418.13 + * License. You can obtain a copy of the License at
418.14 + * http://www.netbeans.org/cddl-gplv2.html
418.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
418.16 + * specific language governing permissions and limitations under the
418.17 + * License. When distributing the software, include this License Header
418.18 + * Notice in each file and include the License file at
418.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
418.20 + * particular file as subject to the "Classpath" exception as provided
418.21 + * by Sun in the GPL Version 2 section of the License file that
418.22 + * accompanied this code. If applicable, add the following below the
418.23 + * License Header, with the fields enclosed by brackets [] replaced by
418.24 + * your own identifying information:
418.25 + * "Portions Copyrighted [year] [name of copyright owner]"
418.26 + *
418.27 + * If you wish your version of this file to be governed by only the CDDL
418.28 + * or only the GPL Version 2, indicate your decision by adding
418.29 + * "[Contributor] elects to include this software in this distribution
418.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
418.31 + * single choice of license, a recipient has the option to distribute
418.32 + * your version of this file under either the CDDL, the GPL Version 2 or
418.33 + * to extend the choice of license to its licensees as provided above.
418.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
418.35 + * Version 2 license, then the option applies only if the new code is
418.36 + * made subject to such option by the copyright holder.
418.37 + *
418.38 + * Contributor(s):
418.39 + *
418.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
418.41 + */
418.42 +
418.43 +package org.netbeans.modules.jackpot30.impl.pm;
418.44 +
418.45 +import com.sun.source.util.TreePath;
418.46 +import java.io.ByteArrayInputStream;
418.47 +import java.io.ByteArrayOutputStream;
418.48 +import java.io.File;
418.49 +import java.io.IOException;
418.50 +import java.util.LinkedList;
418.51 +import java.util.List;
418.52 +import org.netbeans.api.java.source.ClasspathInfo;
418.53 +import org.netbeans.api.java.source.CompilationController;
418.54 +import org.netbeans.api.java.source.JavaSource;
418.55 +import org.netbeans.api.java.source.JavaSource.Phase;
418.56 +import org.netbeans.api.java.source.Task;
418.57 +import org.netbeans.junit.NbTestCase;
418.58 +import org.netbeans.modules.java.hints.jackpot.impl.Utilities;
418.59 +import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch;
418.60 +import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch.BulkPattern;
418.61 +import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch.EncodingContext;
418.62 +import org.netbeans.modules.java.hints.jackpot.impl.pm.CopyFinderBasedBulkSearch;
418.63 +import org.netbeans.modules.java.hints.jackpot.impl.pm.NFABasedBulkSearch;
418.64 +import org.openide.filesystems.FileObject;
418.65 +import org.openide.filesystems.FileUtil;
418.66 +
418.67 +/**
418.68 + *
418.69 + * @author lahvac
418.70 + */
418.71 +public class BulkSearchPerformance extends NbTestCase {
418.72 +
418.73 + public BulkSearchPerformance(String name) {
418.74 + super(name);
418.75 + }
418.76 +
418.77 + public void testPerformance() throws Exception {
418.78 + File root = new File("/media/karta/space/src/nb-main/uml");
418.79 + List<FileObject> files = new LinkedList<FileObject>();
418.80 +
418.81 + gatherFiles(FileUtil.toFileObject(root), files);
418.82 +
418.83 + String[] patterns = new String[] {"$1.isDirectory()", "new ImageIcon()"};
418.84 +
418.85 + for (int c = 0; c < 5; c++) {
418.86 + performPerformanceTest(files, new NFABasedBulkSearch(), patterns);
418.87 + performPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
418.88 + }
418.89 +
418.90 + performPerformanceTest(files, new NFABasedBulkSearch(), patterns);
418.91 + long nfa1 = performPerformanceTest(files, new NFABasedBulkSearch(), patterns);
418.92 + performPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
418.93 + long cf1 = performPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
418.94 +
418.95 + performPerformanceTest(files, new NFABasedBulkSearch(), patterns);
418.96 + long nfa2 = performPerformanceTest(files, new NFABasedBulkSearch(), patterns);
418.97 + performPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
418.98 + long cf2 = performPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
418.99 +
418.100 + System.err.println("nfa1=" + nfa1);
418.101 + System.err.println("cf1=" + cf1);
418.102 + System.err.println("nfa2=" + nfa2);
418.103 + System.err.println("cf2=" + cf2);
418.104 +
418.105 + System.err.println("perf (cf1/nfa1): " + ((1000 * cf1 / nfa1) /10.0) + "%");
418.106 + System.err.println("perf (cf2/nfa2): " + ((1000 * cf2 / nfa2) /10.0) + "%");
418.107 + }
418.108 +
418.109 + public void testIndexingPerformance() throws Exception {
418.110 + File root = new File("/media/karta/space/src/nb-main/uml");
418.111 +// File root = new File("/media/karta/space/src/nb-main/contrib/javahints");
418.112 + List<FileObject> files = new LinkedList<FileObject>();
418.113 +
418.114 + gatherFiles(FileUtil.toFileObject(root), files);
418.115 +
418.116 + String[] patterns = new String[] {"$1.isDirectory()", "new ImageIcon()"};
418.117 +
418.118 + for (int c = 0; c < 5; c++) {
418.119 + performIndexingPerformanceTest(files, new NFABasedBulkSearch(), patterns);
418.120 +// performIndexingPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
418.121 + }
418.122 +
418.123 + performIndexingPerformanceTest(files, new NFABasedBulkSearch(), patterns);
418.124 + long[] nfa1 = performIndexingPerformanceTest(files, new NFABasedBulkSearch(), patterns);
418.125 +// performIndexingPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
418.126 +// long cf1 = performIndexingPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
418.127 +
418.128 + performIndexingPerformanceTest(files, new NFABasedBulkSearch(), patterns);
418.129 + long[] nfa2 = performIndexingPerformanceTest(files, new NFABasedBulkSearch(), patterns);
418.130 +// performIndexingPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
418.131 +// long cf2 = performIndexingPerformanceTest(files, new CopyFinderBasedBulkSearch(), patterns);
418.132 +
418.133 + System.err.println("i.nfa1=" + nfa1[0]);
418.134 + System.err.println("m.nfa1=" + nfa1[1]);
418.135 +// System.err.println("cf1=" + cf1);
418.136 + System.err.println("i.nfa2=" + nfa2[0]);
418.137 + System.err.println("m.nfa2=" + nfa2[1]);
418.138 +// System.err.println("cf2=" + cf2);
418.139 +
418.140 +// System.err.println("perf i.(nfa1/regexp1): " + ((1000 * nfa1[0] / regexp1[0]) /10.0) + "%");
418.141 +// System.err.println("perf m.(nfa1/regexp1): " + ((1000 * nfa1[1] / regexp1[1]) /10.0) + "%");
418.142 +// System.err.println("perf i.(nfa2/regexp2): " + ((1000 * nfa2[0] / regexp2[0]) /10.0) + "%");
418.143 +// System.err.println("perf m.(nfa2/regexp2): " + ((1000 * nfa2[1] / regexp2[1]) /10.0) + "%");
418.144 +// System.err.println("perf (cf1/regexp1): " + ((1000 * cf1 / regexp1) /10.0) + "%");
418.145 +// System.err.println("perf (cf2/regexp2): " + ((1000 * cf2 / regexp2) /10.0) + "%");
418.146 + }
418.147 +
418.148 + private long performPerformanceTest(List<FileObject> files, final BulkSearch search, final String... pattern) throws IOException {
418.149 + ClasspathInfo cpInfo = Utilities.createUniversalCPInfo();
418.150 +
418.151 + final BulkPattern[] bulkPattern = new BulkPattern[1];
418.152 + JavaSource.create(cpInfo).runUserActionTask(new Task<CompilationController>() {
418.153 +
418.154 + public void run(CompilationController parameter) throws Exception {
418.155 + bulkPattern[0] = search.create(parameter, pattern);
418.156 + }
418.157 + }, true);
418.158 +
418.159 + long start = System.currentTimeMillis();
418.160 + JavaSource.create(cpInfo, files).runUserActionTask(new Task<CompilationController>() {
418.161 +
418.162 + public void run(CompilationController parameter) throws Exception {
418.163 + if (parameter.toPhase(Phase.PARSED).compareTo(Phase.PARSED) < 0)
418.164 + return;
418.165 +
418.166 + search.match(parameter, new TreePath(parameter.getCompilationUnit()), bulkPattern[0]);
418.167 + }
418.168 + }, true);
418.169 + long end = System.currentTimeMillis();
418.170 +
418.171 + return end - start;
418.172 + }
418.173 +
418.174 + private long[] performIndexingPerformanceTest(List<FileObject> files, final BulkSearch search, final String... pattern) throws IOException {
418.175 + final List<byte[]> index = new LinkedList<byte[]>();
418.176 + long[] result = new long[2];
418.177 + ClasspathInfo cpInfo = Utilities.createUniversalCPInfo();
418.178 +
418.179 + final BulkPattern[] bulkPattern = new BulkPattern[1];
418.180 + JavaSource.create(cpInfo).runUserActionTask(new Task<CompilationController>() {
418.181 +
418.182 + public void run(CompilationController parameter) throws Exception {
418.183 + bulkPattern[0] = search.create(parameter, pattern);
418.184 + }
418.185 + }, true);
418.186 +
418.187 + long start = System.currentTimeMillis();
418.188 + JavaSource.create(cpInfo, files).runUserActionTask(new Task<CompilationController>() {
418.189 +
418.190 + public void run(CompilationController parameter) throws Exception {
418.191 + if (parameter.toPhase(Phase.PARSED).compareTo(Phase.PARSED) < 0)
418.192 + return;
418.193 +
418.194 + ByteArrayOutputStream out = new ByteArrayOutputStream();
418.195 + EncodingContext ec = new EncodingContext(out, false);
418.196 + search.encode(parameter.getCompilationUnit(), ec);
418.197 +
418.198 + index.add(out.toByteArray());
418.199 + }
418.200 + }, true);
418.201 + long end = System.currentTimeMillis();
418.202 +
418.203 + result[0] = end - start;
418.204 +
418.205 + start = System.currentTimeMillis();
418.206 +
418.207 + for (byte[] data : index) {
418.208 + search.matches(new ByteArrayInputStream(data), bulkPattern[0]);
418.209 + }
418.210 +
418.211 + end = System.currentTimeMillis();
418.212 +
418.213 + result[1] = end - start;
418.214 +
418.215 + return result;
418.216 + }
418.217 +
418.218 + private static void gatherFiles(FileObject root, List<FileObject> files) {
418.219 + if ("java".equals(root.getExt())) {
418.220 + files.add(root);
418.221 + }
418.222 +
418.223 + if (root.isFolder()) {
418.224 + for (FileObject c : root.getChildren()) {
418.225 + gatherFiles(c, files);
418.226 + }
418.227 + }
418.228 + }
418.229 +}
419.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
419.2 +++ b/sandbox/old-modules/api/test/unit/src/org/netbeans/modules/jackpot30/impl/pm/IndexBulkTest.java Mon Mar 12 21:10:10 2012 +0100
419.3 @@ -0,0 +1,182 @@
419.4 +/*
419.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
419.6 + *
419.7 + * Copyright 2009-2010 Oracle and/or its affiliates. All rights reserved.
419.8 + *
419.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
419.10 + * Other names may be trademarks of their respective owners.
419.11 + *
419.12 + * The contents of this file are subject to the terms of either the GNU
419.13 + * General Public License Version 2 only ("GPL") or the Common
419.14 + * Development and Distribution License("CDDL") (collectively, the
419.15 + * "License"). You may not use this file except in compliance with the
419.16 + * License. You can obtain a copy of the License at
419.17 + * http://www.netbeans.org/cddl-gplv2.html
419.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
419.19 + * specific language governing permissions and limitations under the
419.20 + * License. When distributing the software, include this License Header
419.21 + * Notice in each file and include the License file at
419.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
419.23 + * particular file as subject to the "Classpath" exception as provided
419.24 + * by Oracle in the GPL Version 2 section of the License file that
419.25 + * accompanied this code. If applicable, add the following below the
419.26 + * License Header, with the fields enclosed by brackets [] replaced by
419.27 + * your own identifying information:
419.28 + * "Portions Copyrighted [year] [name of copyright owner]"
419.29 + *
419.30 + * If you wish your version of this file to be governed by only the CDDL
419.31 + * or only the GPL Version 2, indicate your decision by adding
419.32 + * "[Contributor] elects to include this software in this distribution
419.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
419.34 + * single choice of license, a recipient has the option to distribute
419.35 + * your version of this file under either the CDDL, the GPL Version 2 or
419.36 + * to extend the choice of license to its licensees as provided above.
419.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
419.38 + * Version 2 license, then the option applies only if the new code is
419.39 + * made subject to such option by the copyright holder.
419.40 + *
419.41 + * Contributor(s):
419.42 + *
419.43 + * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
419.44 + */
419.45 +
419.46 +package org.netbeans.modules.jackpot30.impl.pm;
419.47 +
419.48 +import com.sun.source.tree.Tree;
419.49 +import com.sun.source.util.TreePath;
419.50 +import java.io.IOException;
419.51 +import java.io.InputStream;
419.52 +import java.io.Reader;
419.53 +import java.util.Collection;
419.54 +import java.util.Collections;
419.55 +import java.util.Map;
419.56 +import org.apache.lucene.analysis.Analyzer;
419.57 +import org.apache.lucene.analysis.TokenStream;
419.58 +import org.apache.lucene.index.IndexReader;
419.59 +import org.apache.lucene.index.IndexWriter.MaxFieldLength;
419.60 +import org.apache.lucene.store.Directory;
419.61 +import org.apache.lucene.store.RAMDirectory;
419.62 +import org.netbeans.api.java.source.CompilationInfo;
419.63 +import org.netbeans.modules.jackpot30.impl.indexing.AbstractLuceneIndex;
419.64 +import org.netbeans.modules.jackpot30.impl.indexing.Index.IndexWriter;
419.65 +import org.netbeans.modules.jackpot30.impl.indexing.IndexInfo;
419.66 +import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch;
419.67 +import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch.BulkPattern;
419.68 +import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch.EncodingContext;
419.69 +import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearchTestPerformer;
419.70 +import org.netbeans.modules.java.hints.jackpot.impl.pm.NFABasedBulkSearch;
419.71 +import org.netbeans.modules.java.hints.jackpot.spi.HintDescription.AdditionalQueryConstraints;
419.72 +
419.73 +/**
419.74 + *
419.75 + * @author lahvac
419.76 + */
419.77 +public class IndexBulkTest extends BulkSearchTestPerformer {
419.78 +
419.79 + public IndexBulkTest(String name) {
419.80 + super(name);
419.81 + }
419.82 +
419.83 +// public static TestSuite suite() {
419.84 +// NbTestSuite r = new NbTestSuite();
419.85 +//
419.86 +// r.addTest(new NFABasedBulkSearchTest("testField1"));
419.87 +// r.addTest(new NFABasedBulkSearchTest("testField2"));
419.88 +//
419.89 +// return r;
419.90 +// }
419.91 +
419.92 + @Override
419.93 + protected BulkSearch createSearch() {
419.94 + return new BulkSearchImpl(false);
419.95 + }
419.96 +
419.97 + private static class BulkSearchImpl extends BulkSearch {
419.98 +
419.99 + public BulkSearchImpl(boolean requiresLightweightVerification) {
419.100 + super(requiresLightweightVerification);
419.101 + }
419.102 +
419.103 + @Override
419.104 + public Map<String, Collection<TreePath>> match(CompilationInfo info, TreePath toSearch, BulkPattern pattern, Map<String, Long> timeLog) {
419.105 + try {
419.106 + IndexImpl ii = new IndexImpl();
419.107 + IndexWriter writer = ii.openForWriting();
419.108 +
419.109 + writer.record(toSearch.getCompilationUnit().getSourceFile().toUri().toURL(), toSearch.getCompilationUnit(), null);
419.110 + writer.close();
419.111 +
419.112 + if (!ii.findCandidates(pattern).isEmpty()) {
419.113 + return new NFABasedBulkSearch().match(info, toSearch, pattern, timeLog);
419.114 + } else {
419.115 + assertTrue(new NFABasedBulkSearch().match(info, toSearch, pattern, timeLog).isEmpty());
419.116 + return Collections.emptyMap();
419.117 + }
419.118 + } catch (IOException ex) {
419.119 + throw new IllegalStateException(ex);
419.120 + }
419.121 + }
419.122 +
419.123 + @Override
419.124 + public boolean matches(InputStream encoded, BulkPattern pattern) {
419.125 + return new NFABasedBulkSearch().matches(encoded, pattern);
419.126 + }
419.127 +
419.128 + @Override
419.129 + public boolean matches(CompilationInfo info, TreePath toSearch, BulkPattern pattern) {
419.130 + return new NFABasedBulkSearch().matches(info, toSearch, pattern);
419.131 + }
419.132 +
419.133 + @Override
419.134 + public void encode(Tree tree, EncodingContext ctx) {
419.135 + new NFABasedBulkSearch().encode(tree, ctx);
419.136 + }
419.137 +
419.138 + @Override
419.139 + public BulkPattern create(Collection<? extends String> code, Collection<? extends Tree> patterns, Collection<? extends AdditionalQueryConstraints> additionalConstraints) {
419.140 + return new NFABasedBulkSearch().create(code, patterns, additionalConstraints);
419.141 + }
419.142 +
419.143 + @Override
419.144 + public Map<String, Integer> matchesWithFrequencies(InputStream encoded, BulkPattern pattern) {
419.145 + return new NFABasedBulkSearch().matchesWithFrequencies(encoded, pattern);
419.146 + }
419.147 + }
419.148 +
419.149 + private static final class IndexImpl extends AbstractLuceneIndex {
419.150 +
419.151 + private final Directory dir = new RAMDirectory();
419.152 +
419.153 + public IndexImpl() {
419.154 + super(0, false, true);
419.155 + }
419.156 +
419.157 + @Override
419.158 + protected IndexReader createReader() throws IOException {
419.159 + return IndexReader.open(dir, true);
419.160 + }
419.161 +
419.162 + @Override
419.163 + protected org.apache.lucene.index.IndexWriter createWriter() throws IOException {
419.164 + return new org.apache.lucene.index.IndexWriter(dir, new NoAnalyzer(), MaxFieldLength.UNLIMITED);
419.165 + }
419.166 +
419.167 + @Override
419.168 + public IndexInfo getIndexInfo() {
419.169 + return IndexInfo.empty();
419.170 + }
419.171 +
419.172 + @Override
419.173 + protected void storeIndexInfo(IndexInfo info) throws IOException {}
419.174 + }
419.175 +
419.176 + private static final class NoAnalyzer extends Analyzer {
419.177 +
419.178 + @Override
419.179 + public TokenStream tokenStream(String string, Reader reader) {
419.180 + throw new UnsupportedOperationException("Should not be called");
419.181 + }
419.182 +
419.183 + }
419.184 +
419.185 +}
420.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
420.2 +++ b/sandbox/old-modules/api/test/unit/src/org/netbeans/modules/jackpot30/spi/refactoring/JackpotBasedRefactoringTestBase.java Mon Mar 12 21:10:10 2012 +0100
420.3 @@ -0,0 +1,198 @@
420.4 +/*
420.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
420.6 + *
420.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
420.8 + *
420.9 + * The contents of this file are subject to the terms of either the GNU
420.10 + * General Public License Version 2 only ("GPL") or the Common
420.11 + * Development and Distribution License("CDDL") (collectively, the
420.12 + * "License"). You may not use this file except in compliance with the
420.13 + * License. You can obtain a copy of the License at
420.14 + * http://www.netbeans.org/cddl-gplv2.html
420.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
420.16 + * specific language governing permissions and limitations under the
420.17 + * License. When distributing the software, include this License Header
420.18 + * Notice in each file and include the License file at
420.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
420.20 + * particular file as subject to the "Classpath" exception as provided
420.21 + * by Sun in the GPL Version 2 section of the License file that
420.22 + * accompanied this code. If applicable, add the following below the
420.23 + * License Header, with the fields enclosed by brackets [] replaced by
420.24 + * your own identifying information:
420.25 + * "Portions Copyrighted [year] [name of copyright owner]"
420.26 + *
420.27 + * If you wish your version of this file to be governed by only the CDDL
420.28 + * or only the GPL Version 2, indicate your decision by adding
420.29 + * "[Contributor] elects to include this software in this distribution
420.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
420.31 + * single choice of license, a recipient has the option to distribute
420.32 + * your version of this file under either the CDDL, the GPL Version 2 or
420.33 + * to extend the choice of license to its licensees as provided above.
420.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
420.35 + * Version 2 license, then the option applies only if the new code is
420.36 + * made subject to such option by the copyright holder.
420.37 + *
420.38 + * Contributor(s):
420.39 + *
420.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
420.41 + */
420.42 +
420.43 +package org.netbeans.modules.jackpot30.spi.refactoring;
420.44 +
420.45 +import java.io.IOException;
420.46 +import java.util.Collections;
420.47 +import org.netbeans.api.editor.mimelookup.MimePath;
420.48 +import org.netbeans.api.java.classpath.ClassPath;
420.49 +import org.netbeans.api.java.classpath.GlobalPathRegistry;
420.50 +import org.netbeans.api.java.source.SourceUtils;
420.51 +import org.netbeans.api.java.source.SourceUtilsTestUtil;
420.52 +import org.netbeans.api.java.source.TestUtilities;
420.53 +import org.netbeans.api.project.Project;
420.54 +import org.netbeans.api.project.ProjectManager;
420.55 +import org.netbeans.core.startup.Main;
420.56 +import org.netbeans.junit.NbTestCase;
420.57 +import org.netbeans.modules.java.JavaDataLoader;
420.58 +import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
420.59 +import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
420.60 +import org.netbeans.modules.parsing.impl.indexing.MimeTypes;
420.61 +import org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater;
420.62 +import org.netbeans.modules.parsing.impl.indexing.Util;
420.63 +import org.netbeans.spi.editor.mimelookup.MimeDataProvider;
420.64 +import org.netbeans.spi.java.classpath.ClassPathProvider;
420.65 +import org.netbeans.spi.java.classpath.support.ClassPathSupport;
420.66 +import org.netbeans.spi.project.ProjectFactory;
420.67 +import org.netbeans.spi.project.ProjectState;
420.68 +import org.openide.filesystems.FileObject;
420.69 +import org.openide.filesystems.FileUtil;
420.70 +import org.openide.util.Lookup;
420.71 +import org.openide.util.lookup.Lookups;
420.72 +import org.openide.util.lookup.ServiceProvider;
420.73 +
420.74 +/**
420.75 + *
420.76 + * @author lahvac
420.77 + */
420.78 +public class JackpotBasedRefactoringTestBase extends NbTestCase {
420.79 +
420.80 + public JackpotBasedRefactoringTestBase(String name) {
420.81 + super(name);
420.82 + }
420.83 +
420.84 + protected static void writeFilesAndWaitForScan(FileObject sourceRoot, File... files) throws Exception {
420.85 + for (FileObject c : sourceRoot.getChildren()) {
420.86 + c.delete();
420.87 + }
420.88 +
420.89 + for (File f : files) {
420.90 + FileObject fo = FileUtil.createData(sourceRoot, f.filename);
420.91 + TestUtilities.copyStringToFile(fo, f.content);
420.92 + }
420.93 +
420.94 + SourceUtils.waitScanFinished();
420.95 + }
420.96 +
420.97 + protected static void assertContent(FileObject sourceRoot, File... files) throws Exception {
420.98 + for (File f : files) {
420.99 + FileObject fo = sourceRoot.getFileObject(f.filename);
420.100 +
420.101 + assertNotNull(f.filename, fo);
420.102 +
420.103 + assertEquals(f.content.replaceAll("[ \t\n]+", " "), TestUtilities.copyFileToString(FileUtil.toFile(fo)).replaceAll("[ \t\n]+", " "));
420.104 + }
420.105 + }
420.106 +
420.107 + protected static final class File {
420.108 + public final String filename;
420.109 + public final String content;
420.110 +
420.111 + public File(String filename, String content) {
420.112 + this.filename = filename;
420.113 + this.content = content;
420.114 + }
420.115 + }
420.116 +
420.117 + protected FileObject src;
420.118 + protected Project prj;
420.119 +
420.120 + @Override
420.121 + protected void setUp() throws Exception {
420.122 + SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml"}, new Object[] {
420.123 + new ClassPathProvider() {
420.124 + public ClassPath findClassPath(FileObject file, String type) {
420.125 + if (src != null && (file == src || FileUtil.isParentOf(src, file))) {
420.126 + if (ClassPath.BOOT.equals(type)) {
420.127 + return ClassPathSupport.createClassPath(System.getProperty("sun.boot.class.path"));
420.128 + }
420.129 + if (ClassPath.COMPILE.equals(type)) {
420.130 + return ClassPathSupport.createClassPath(new FileObject[0]);
420.131 + }
420.132 + if (ClassPath.SOURCE.equals(type)) {
420.133 + return ClassPathSupport.createClassPath(src);
420.134 + }
420.135 + }
420.136 +
420.137 + return null;
420.138 + }
420.139 + },
420.140 + new ProjectFactory() {
420.141 + public boolean isProject(FileObject projectDirectory) {
420.142 + return src == projectDirectory;
420.143 + }
420.144 + public Project loadProject(final FileObject projectDirectory, ProjectState state) throws IOException {
420.145 + if (!isProject(projectDirectory)) return null;
420.146 + return new Project() {
420.147 + public FileObject getProjectDirectory() {
420.148 + return projectDirectory;
420.149 + }
420.150 + public Lookup getLookup() {
420.151 + return Lookup.EMPTY;
420.152 + }
420.153 + };
420.154 + }
420.155 + public void saveProject(Project project) throws IOException, ClassCastException {}
420.156 + },
420.157 + JavaDataLoader.getLoader(JavaDataLoader.class),
420.158 + });
420.159 + Main.initializeURLFactory();
420.160 + org.netbeans.api.project.ui.OpenProjects.getDefault().getOpenProjects();
420.161 + prepareTest();
420.162 + org.netbeans.api.project.ui.OpenProjects.getDefault().open(new Project[] {prj = ProjectManager.getDefault().findProject(src)}, false);
420.163 + MimeTypes.setAllMimeTypes(Collections.singleton("text/x-java"));
420.164 + GlobalPathRegistry.getDefault().register(ClassPath.SOURCE, new ClassPath[] {ClassPathSupport.createClassPath(src)});
420.165 + RepositoryUpdater.getDefault().start(true);
420.166 + super.setUp();
420.167 + }
420.168 +
420.169 + @Override
420.170 + protected void tearDown() throws Exception {
420.171 + super.tearDown();
420.172 + org.netbeans.api.project.ui.OpenProjects.getDefault().open(new Project[] {prj}, false);
420.173 + prj = null;
420.174 + }
420.175 +
420.176 + private void prepareTest() throws Exception {
420.177 + FileObject workdir = SourceUtilsTestUtil.makeScratchDir(this);
420.178 +
420.179 + src = FileUtil.createFolder(workdir, "src");
420.180 +
420.181 + FileObject cache = FileUtil.createFolder(workdir, "cache");
420.182 +
420.183 + CacheFolder.setCacheFolder(cache);
420.184 + }
420.185 +
420.186 + @ServiceProvider(service=MimeDataProvider.class)
420.187 + public static final class MimeDataProviderImpl implements MimeDataProvider {
420.188 +
420.189 + private static final Lookup L = Lookups.singleton(new JavaCustomIndexer.Factory());
420.190 +
420.191 + public Lookup getLookup(MimePath mimePath) {
420.192 + if ("text/x-java".equals(mimePath.getPath())) {
420.193 + return L;
420.194 + }
420.195 +
420.196 + return null;
420.197 + }
420.198 +
420.199 + }
420.200 +
420.201 +}
421.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
421.2 +++ b/sandbox/old-modules/bridges/refactoring/build.xml Mon Mar 12 21:10:10 2012 +0100
421.3 @@ -0,0 +1,9 @@
421.4 +<?xml version="1.0" encoding="UTF-8"?>
421.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
421.6 +<!-- for some information on what you could do (e.g. targets to override). -->
421.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
421.8 +<project name="org.netbeans.modules.jackpot30.refactoring" default="netbeans" basedir=".">
421.9 + <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.refactoring.</description>
421.10 + <import file="nbproject/build-impl.xml"/>
421.11 + <import file="${suite.dir}/findbugs-import.xml"/>
421.12 +</project>
422.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
422.2 +++ b/sandbox/old-modules/bridges/refactoring/manifest.mf Mon Mar 12 21:10:10 2012 +0100
422.3 @@ -0,0 +1,6 @@
422.4 +Manifest-Version: 1.0
422.5 +OpenIDE-Module: org.netbeans.modules.jackpot30.refactoring
422.6 +OpenIDE-Module-Implementation-Version: 1
422.7 +OpenIDE-Module-Layer: org/netbeans/modules/jackpot30/refactoring/layer.xml
422.8 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/refactoring/Bundle.properties
422.9 +
423.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
423.2 +++ b/sandbox/old-modules/bridges/refactoring/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
423.3 @@ -0,0 +1,45 @@
423.4 +<?xml version="1.0" encoding="UTF-8"?>
423.5 +<!--
423.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
423.7 +*** EDIT ../build.xml INSTEAD ***
423.8 +-->
423.9 +<project name="org.netbeans.modules.jackpot30.refactoring-impl" basedir="..">
423.10 + <fail message="Please build using Ant 1.7.1 or higher.">
423.11 + <condition>
423.12 + <not>
423.13 + <antversion atleast="1.7.1"/>
423.14 + </not>
423.15 + </condition>
423.16 + </fail>
423.17 + <property file="nbproject/private/suite-private.properties"/>
423.18 + <property file="nbproject/suite.properties"/>
423.19 + <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
423.20 + <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
423.21 + <property file="${suite.dir}/nbproject/platform.properties"/>
423.22 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
423.23 + <attribute name="name"/>
423.24 + <attribute name="value"/>
423.25 + <sequential>
423.26 + <property name="@{name}" value="${@{value}}"/>
423.27 + </sequential>
423.28 + </macrodef>
423.29 + <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
423.30 + <attribute name="property"/>
423.31 + <attribute name="value"/>
423.32 + <sequential>
423.33 + <property name="@{property}" value="@{value}"/>
423.34 + </sequential>
423.35 + </macrodef>
423.36 + <property file="${user.properties.file}"/>
423.37 + <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
423.38 + <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
423.39 + <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
423.40 + <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
423.41 + <condition>
423.42 + <not>
423.43 + <contains string="${cluster.path.evaluated}" substring="platform"/>
423.44 + </not>
423.45 + </condition>
423.46 + </fail>
423.47 + <import file="${harness.dir}/build.xml"/>
423.48 +</project>
424.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
424.2 +++ b/sandbox/old-modules/bridges/refactoring/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
424.3 @@ -0,0 +1,8 @@
424.4 +build.xml.data.CRC32=46e4f14a
424.5 +build.xml.script.CRC32=4a0f84c4
424.6 +build.xml.stylesheet.CRC32=79c3b980@1.39
424.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
424.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
424.9 +nbproject/build-impl.xml.data.CRC32=2e452477
424.10 +nbproject/build-impl.xml.script.CRC32=fd9920c9
424.11 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.49
425.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
425.2 +++ b/sandbox/old-modules/bridges/refactoring/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
425.3 @@ -0,0 +1,4 @@
425.4 +is.eager=true
425.5 +javac.source=1.6
425.6 +javac.compilerargs=-Xlint -Xlint:-serial
425.7 +spec.version.base=1.16.0
426.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
426.2 +++ b/sandbox/old-modules/bridges/refactoring/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
426.3 @@ -0,0 +1,199 @@
426.4 +<?xml version="1.0" encoding="UTF-8"?>
426.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
426.6 + <type>org.netbeans.modules.apisupport.project</type>
426.7 + <configuration>
426.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
426.9 + <code-name-base>org.netbeans.modules.jackpot30.refactoring</code-name-base>
426.10 + <suite-component/>
426.11 + <module-dependencies>
426.12 + <dependency>
426.13 + <code-name-base>org.netbeans.api.annotations.common</code-name-base>
426.14 + <build-prerequisite/>
426.15 + <compile-dependency/>
426.16 + <run-dependency>
426.17 + <release-version>1</release-version>
426.18 + <specification-version>1.4</specification-version>
426.19 + </run-dependency>
426.20 + </dependency>
426.21 + <dependency>
426.22 + <code-name-base>org.netbeans.api.java.classpath</code-name-base>
426.23 + <build-prerequisite/>
426.24 + <compile-dependency/>
426.25 + <run-dependency>
426.26 + <release-version>1</release-version>
426.27 + <specification-version>1.24</specification-version>
426.28 + </run-dependency>
426.29 + </dependency>
426.30 + <dependency>
426.31 + <code-name-base>org.netbeans.libs.javacapi</code-name-base>
426.32 + <build-prerequisite/>
426.33 + <compile-dependency/>
426.34 + <run-dependency>
426.35 + <specification-version>0.12.0.1</specification-version>
426.36 + </run-dependency>
426.37 + </dependency>
426.38 + <dependency>
426.39 + <code-name-base>org.netbeans.modules.jackpot30.api</code-name-base>
426.40 + <build-prerequisite/>
426.41 + <compile-dependency/>
426.42 + <run-dependency>
426.43 + <specification-version>1.12</specification-version>
426.44 + </run-dependency>
426.45 + </dependency>
426.46 + <dependency>
426.47 + <code-name-base>org.netbeans.modules.java.hints</code-name-base>
426.48 + <build-prerequisite/>
426.49 + <compile-dependency/>
426.50 + <run-dependency>
426.51 + <release-version>1</release-version>
426.52 + <implementation-version/>
426.53 + </run-dependency>
426.54 + </dependency>
426.55 + <dependency>
426.56 + <code-name-base>org.netbeans.modules.java.source</code-name-base>
426.57 + <build-prerequisite/>
426.58 + <compile-dependency/>
426.59 + <run-dependency>
426.60 + <specification-version>0.57.0.9.8.4</specification-version>
426.61 + </run-dependency>
426.62 + </dependency>
426.63 + <dependency>
426.64 + <code-name-base>org.netbeans.modules.java.sourceui</code-name-base>
426.65 + <build-prerequisite/>
426.66 + <compile-dependency/>
426.67 + <run-dependency>
426.68 + <release-version>1</release-version>
426.69 + <specification-version>1.26.0.1.19</specification-version>
426.70 + </run-dependency>
426.71 + </dependency>
426.72 + <dependency>
426.73 + <code-name-base>org.netbeans.modules.queries</code-name-base>
426.74 + <build-prerequisite/>
426.75 + <compile-dependency/>
426.76 + <run-dependency>
426.77 + <release-version>1</release-version>
426.78 + <specification-version>1.18</specification-version>
426.79 + </run-dependency>
426.80 + </dependency>
426.81 + <dependency>
426.82 + <code-name-base>org.netbeans.modules.refactoring.api</code-name-base>
426.83 + <build-prerequisite/>
426.84 + <compile-dependency/>
426.85 + <run-dependency>
426.86 + <specification-version>1.10</specification-version>
426.87 + </run-dependency>
426.88 + </dependency>
426.89 + <dependency>
426.90 + <code-name-base>org.netbeans.modules.refactoring.java</code-name-base>
426.91 + <build-prerequisite/>
426.92 + <compile-dependency/>
426.93 + <run-dependency>
426.94 + <release-version>1</release-version>
426.95 + <implementation-version/>
426.96 + </run-dependency>
426.97 + </dependency>
426.98 + <dependency>
426.99 + <code-name-base>org.openide.awt</code-name-base>
426.100 + <build-prerequisite/>
426.101 + <compile-dependency/>
426.102 + <run-dependency>
426.103 + <specification-version>7.23</specification-version>
426.104 + </run-dependency>
426.105 + </dependency>
426.106 + <dependency>
426.107 + <code-name-base>org.openide.filesystems</code-name-base>
426.108 + <build-prerequisite/>
426.109 + <compile-dependency/>
426.110 + <run-dependency>
426.111 + <specification-version>7.36</specification-version>
426.112 + </run-dependency>
426.113 + </dependency>
426.114 + <dependency>
426.115 + <code-name-base>org.openide.loaders</code-name-base>
426.116 + <build-prerequisite/>
426.117 + <compile-dependency/>
426.118 + <run-dependency>
426.119 + <specification-version>7.16</specification-version>
426.120 + </run-dependency>
426.121 + </dependency>
426.122 + <dependency>
426.123 + <code-name-base>org.openide.nodes</code-name-base>
426.124 + <build-prerequisite/>
426.125 + <compile-dependency/>
426.126 + <run-dependency>
426.127 + <specification-version>7.16</specification-version>
426.128 + </run-dependency>
426.129 + </dependency>
426.130 + <dependency>
426.131 + <code-name-base>org.openide.text</code-name-base>
426.132 + <build-prerequisite/>
426.133 + <compile-dependency/>
426.134 + <run-dependency>
426.135 + <specification-version>6.29</specification-version>
426.136 + </run-dependency>
426.137 + </dependency>
426.138 + <dependency>
426.139 + <code-name-base>org.openide.util</code-name-base>
426.140 + <build-prerequisite/>
426.141 + <compile-dependency/>
426.142 + <run-dependency>
426.143 + <specification-version>8.2</specification-version>
426.144 + </run-dependency>
426.145 + </dependency>
426.146 + <dependency>
426.147 + <code-name-base>org.openide.util.lookup</code-name-base>
426.148 + <build-prerequisite/>
426.149 + <compile-dependency/>
426.150 + <run-dependency>
426.151 + <specification-version>8.2</specification-version>
426.152 + </run-dependency>
426.153 + </dependency>
426.154 + <dependency>
426.155 + <code-name-base>org.openide.windows</code-name-base>
426.156 + <build-prerequisite/>
426.157 + <compile-dependency/>
426.158 + <run-dependency>
426.159 + <specification-version>6.33</specification-version>
426.160 + </run-dependency>
426.161 + </dependency>
426.162 + </module-dependencies>
426.163 + <test-dependencies>
426.164 + <test-type>
426.165 + <name>unit</name>
426.166 + <test-dependency>
426.167 + <code-name-base>org.netbeans.libs.junit4</code-name-base>
426.168 + <compile-dependency/>
426.169 + </test-dependency>
426.170 + <test-dependency>
426.171 + <code-name-base>org.netbeans.modules.jackpot30.api</code-name-base>
426.172 + <recursive/>
426.173 + <compile-dependency/>
426.174 + <test/>
426.175 + </test-dependency>
426.176 + <test-dependency>
426.177 + <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
426.178 + <compile-dependency/>
426.179 + </test-dependency>
426.180 + <test-dependency>
426.181 + <code-name-base>org.netbeans.modules.java.hints.declarative</code-name-base>
426.182 + <compile-dependency/>
426.183 + </test-dependency>
426.184 + <test-dependency>
426.185 + <code-name-base>org.netbeans.modules.junit</code-name-base>
426.186 + <compile-dependency/>
426.187 + </test-dependency>
426.188 + <test-dependency>
426.189 + <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
426.190 + <recursive/>
426.191 + <compile-dependency/>
426.192 + </test-dependency>
426.193 + <test-dependency>
426.194 + <code-name-base>org.netbeans.modules.projectui</code-name-base>
426.195 + <compile-dependency/>
426.196 + </test-dependency>
426.197 + </test-type>
426.198 + </test-dependencies>
426.199 + <public-packages/>
426.200 + </data>
426.201 + </configuration>
426.202 +</project>
427.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
427.2 +++ b/sandbox/old-modules/bridges/refactoring/nbproject/suite.properties Mon Mar 12 21:10:10 2012 +0100
427.3 @@ -0,0 +1,1 @@
427.4 +suite.dir=${basedir}/../..
428.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
428.2 +++ b/sandbox/old-modules/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/Bundle.properties Mon Mar 12 21:10:10 2012 +0100
428.3 @@ -0,0 +1,4 @@
428.4 +OpenIDE-Module-Name=Jackpot 3.0 Refactoring Bridge
428.5 +GenerateScriptPanel.generate.text=Generate Jackpot script for automatic upgrade
428.6 +GenerateScriptPanel.makePrivate.text=Make existing element private
428.7 +GenerateScriptPanel.deprecate.text=Deprecate existing element
429.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
429.2 +++ b/sandbox/old-modules/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/ExtraData.java Mon Mar 12 21:10:10 2012 +0100
429.3 @@ -0,0 +1,58 @@
429.4 +/*
429.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
429.6 + *
429.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
429.8 + *
429.9 + * The contents of this file are subject to the terms of either the GNU
429.10 + * General Public License Version 2 only ("GPL") or the Common
429.11 + * Development and Distribution License("CDDL") (collectively, the
429.12 + * "License"). You may not use this file except in compliance with the
429.13 + * License. You can obtain a copy of the License at
429.14 + * http://www.netbeans.org/cddl-gplv2.html
429.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
429.16 + * specific language governing permissions and limitations under the
429.17 + * License. When distributing the software, include this License Header
429.18 + * Notice in each file and include the License file at
429.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
429.20 + * particular file as subject to the "Classpath" exception as provided
429.21 + * by Sun in the GPL Version 2 section of the License file that
429.22 + * accompanied this code. If applicable, add the following below the
429.23 + * License Header, with the fields enclosed by brackets [] replaced by
429.24 + * your own identifying information:
429.25 + * "Portions Copyrighted [year] [name of copyright owner]"
429.26 + *
429.27 + * If you wish your version of this file to be governed by only the CDDL
429.28 + * or only the GPL Version 2, indicate your decision by adding
429.29 + * "[Contributor] elects to include this software in this distribution
429.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
429.31 + * single choice of license, a recipient has the option to distribute
429.32 + * your version of this file under either the CDDL, the GPL Version 2 or
429.33 + * to extend the choice of license to its licensees as provided above.
429.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
429.35 + * Version 2 license, then the option applies only if the new code is
429.36 + * made subject to such option by the copyright holder.
429.37 + *
429.38 + * Contributor(s):
429.39 + *
429.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
429.41 + */
429.42 +
429.43 +package org.netbeans.modules.jackpot30.refactoring;
429.44 +
429.45 +/**
429.46 + *
429.47 + * @author lahvac
429.48 + */
429.49 +public final class ExtraData {
429.50 +
429.51 + public final boolean generateUpgradeScript;
429.52 + public final boolean makeOriginalPrivate;
429.53 + public final boolean makeOriginalDeprecated;
429.54 +
429.55 + public ExtraData(boolean generateUpgradeScript, boolean makeOriginalPrivate, boolean makeOriginalDeprecated) {
429.56 + this.generateUpgradeScript = generateUpgradeScript;
429.57 + this.makeOriginalPrivate = makeOriginalPrivate;
429.58 + this.makeOriginalDeprecated = makeOriginalDeprecated;
429.59 + }
429.60 +
429.61 +}
430.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
430.2 +++ b/sandbox/old-modules/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/GenerateScriptPanel.form Mon Mar 12 21:10:10 2012 +0100
430.3 @@ -0,0 +1,77 @@
430.4 +<?xml version="1.0" encoding="UTF-8" ?>
430.5 +
430.6 +<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
430.7 + <AuxValues>
430.8 + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
430.9 + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
430.10 + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
430.11 + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
430.12 + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
430.13 + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
430.14 + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
430.15 + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
430.16 + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
430.17 + </AuxValues>
430.18 +
430.19 + <Layout>
430.20 + <DimensionLayout dim="0">
430.21 + <Group type="103" groupAlignment="0" attributes="0">
430.22 + <Group type="102" attributes="0">
430.23 + <Group type="103" groupAlignment="0" attributes="0">
430.24 + <Group type="102" alignment="0" attributes="0">
430.25 + <EmptySpace min="-2" pref="29" max="-2" attributes="0"/>
430.26 + <Group type="103" groupAlignment="0" attributes="0">
430.27 + <Component id="deprecate" alignment="0" min="-2" max="-2" attributes="0"/>
430.28 + <Component id="makePrivate" alignment="0" min="-2" max="-2" attributes="0"/>
430.29 + </Group>
430.30 + </Group>
430.31 + <Group type="102" alignment="0" attributes="0">
430.32 + <EmptySpace max="-2" attributes="0"/>
430.33 + <Component id="generate" min="-2" max="-2" attributes="0"/>
430.34 + </Group>
430.35 + </Group>
430.36 + <EmptySpace pref="79" max="32767" attributes="0"/>
430.37 + </Group>
430.38 + </Group>
430.39 + </DimensionLayout>
430.40 + <DimensionLayout dim="1">
430.41 + <Group type="103" groupAlignment="0" attributes="0">
430.42 + <Group type="102" alignment="0" attributes="0">
430.43 + <EmptySpace max="-2" attributes="0"/>
430.44 + <Component id="generate" min="-2" max="-2" attributes="0"/>
430.45 + <EmptySpace max="-2" attributes="0"/>
430.46 + <Component id="makePrivate" min="-2" max="-2" attributes="0"/>
430.47 + <EmptySpace max="-2" attributes="0"/>
430.48 + <Component id="deprecate" min="-2" max="-2" attributes="0"/>
430.49 + <EmptySpace pref="223" max="32767" attributes="0"/>
430.50 + </Group>
430.51 + </Group>
430.52 + </DimensionLayout>
430.53 + </Layout>
430.54 + <SubComponents>
430.55 + <Component class="javax.swing.JCheckBox" name="generate">
430.56 + <Properties>
430.57 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
430.58 + <ResourceString bundle="org/netbeans/modules/jackpot30/refactoring/Bundle.properties" key="GenerateScriptPanel.generate.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
430.59 + </Property>
430.60 + </Properties>
430.61 + <Events>
430.62 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="generateActionPerformed"/>
430.63 + </Events>
430.64 + </Component>
430.65 + <Component class="javax.swing.JCheckBox" name="makePrivate">
430.66 + <Properties>
430.67 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
430.68 + <ResourceString bundle="org/netbeans/modules/jackpot30/refactoring/Bundle.properties" key="GenerateScriptPanel.makePrivate.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
430.69 + </Property>
430.70 + </Properties>
430.71 + </Component>
430.72 + <Component class="javax.swing.JCheckBox" name="deprecate">
430.73 + <Properties>
430.74 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
430.75 + <ResourceString bundle="org/netbeans/modules/jackpot30/refactoring/Bundle.properties" key="GenerateScriptPanel.deprecate.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
430.76 + </Property>
430.77 + </Properties>
430.78 + </Component>
430.79 + </SubComponents>
430.80 +</Form>
431.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
431.2 +++ b/sandbox/old-modules/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/GenerateScriptPanel.java Mon Mar 12 21:10:10 2012 +0100
431.3 @@ -0,0 +1,174 @@
431.4 +/*
431.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
431.6 + *
431.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
431.8 + *
431.9 + * The contents of this file are subject to the terms of either the GNU
431.10 + * General Public License Version 2 only ("GPL") or the Common
431.11 + * Development and Distribution License("CDDL") (collectively, the
431.12 + * "License"). You may not use this file except in compliance with the
431.13 + * License. You can obtain a copy of the License at
431.14 + * http://www.netbeans.org/cddl-gplv2.html
431.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
431.16 + * specific language governing permissions and limitations under the
431.17 + * License. When distributing the software, include this License Header
431.18 + * Notice in each file and include the License file at
431.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
431.20 + * particular file as subject to the "Classpath" exception as provided
431.21 + * by Sun in the GPL Version 2 section of the License file that
431.22 + * accompanied this code. If applicable, add the following below the
431.23 + * License Header, with the fields enclosed by brackets [] replaced by
431.24 + * your own identifying information:
431.25 + * "Portions Copyrighted [year] [name of copyright owner]"
431.26 + *
431.27 + * If you wish your version of this file to be governed by only the CDDL
431.28 + * or only the GPL Version 2, indicate your decision by adding
431.29 + * "[Contributor] elects to include this software in this distribution
431.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
431.31 + * single choice of license, a recipient has the option to distribute
431.32 + * your version of this file under either the CDDL, the GPL Version 2 or
431.33 + * to extend the choice of license to its licensees as provided above.
431.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
431.35 + * Version 2 license, then the option applies only if the new code is
431.36 + * made subject to such option by the copyright holder.
431.37 + *
431.38 + * Contributor(s):
431.39 + *
431.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
431.41 + */
431.42 +package org.netbeans.modules.jackpot30.refactoring;
431.43 +
431.44 +import java.util.prefs.Preferences;
431.45 +import org.openide.util.NbPreferences;
431.46 +
431.47 +/**
431.48 + *
431.49 + * @author lahvac
431.50 + */
431.51 +public class GenerateScriptPanel extends javax.swing.JPanel {
431.52 +
431.53 + private final boolean supported;
431.54 +
431.55 + public GenerateScriptPanel(boolean supported) {
431.56 + this.supported = supported;
431.57 + initComponents();
431.58 + loadDefaults();
431.59 + }
431.60 +
431.61 + /** This method is called from within the constructor to
431.62 + * initialize the form.
431.63 + * WARNING: Do NOT modify this code. The content of this method is
431.64 + * always regenerated by the Form Editor.
431.65 + */
431.66 + @SuppressWarnings("unchecked")
431.67 + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
431.68 + private void initComponents() {
431.69 +
431.70 + generate = new javax.swing.JCheckBox();
431.71 + makePrivate = new javax.swing.JCheckBox();
431.72 + deprecate = new javax.swing.JCheckBox();
431.73 +
431.74 + generate.setText(org.openide.util.NbBundle.getMessage(GenerateScriptPanel.class, "GenerateScriptPanel.generate.text")); // NOI18N
431.75 + generate.addActionListener(new java.awt.event.ActionListener() {
431.76 + public void actionPerformed(java.awt.event.ActionEvent evt) {
431.77 + generateActionPerformed(evt);
431.78 + }
431.79 + });
431.80 +
431.81 + makePrivate.setText(org.openide.util.NbBundle.getMessage(GenerateScriptPanel.class, "GenerateScriptPanel.makePrivate.text")); // NOI18N
431.82 +
431.83 + deprecate.setText(org.openide.util.NbBundle.getMessage(GenerateScriptPanel.class, "GenerateScriptPanel.deprecate.text")); // NOI18N
431.84 +
431.85 + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
431.86 + this.setLayout(layout);
431.87 + layout.setHorizontalGroup(
431.88 + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
431.89 + .addGroup(layout.createSequentialGroup()
431.90 + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
431.91 + .addGroup(layout.createSequentialGroup()
431.92 + .addGap(29, 29, 29)
431.93 + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
431.94 + .addComponent(deprecate)
431.95 + .addComponent(makePrivate)))
431.96 + .addGroup(layout.createSequentialGroup()
431.97 + .addContainerGap()
431.98 + .addComponent(generate)))
431.99 + .addContainerGap(79, Short.MAX_VALUE))
431.100 + );
431.101 + layout.setVerticalGroup(
431.102 + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
431.103 + .addGroup(layout.createSequentialGroup()
431.104 + .addContainerGap()
431.105 + .addComponent(generate)
431.106 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
431.107 + .addComponent(makePrivate)
431.108 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
431.109 + .addComponent(deprecate)
431.110 + .addContainerGap(223, Short.MAX_VALUE))
431.111 + );
431.112 + }// </editor-fold>//GEN-END:initComponents
431.113 +
431.114 + private void generateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generateActionPerformed
431.115 + updateState();
431.116 + }//GEN-LAST:event_generateActionPerformed
431.117 +
431.118 + private static final String KEY_DO_GENERATE_SCRIPT = "generate-script";
431.119 + private static final boolean DEF_DO_GENERATE_SCRIPT = true;
431.120 + private static final String KEY_MAKE_PRIVATE = "make-private";
431.121 + private static final boolean DEF_MAKE_PRIVATE = true;
431.122 + private static final String KEY_DEPRECATE = "deprecate";
431.123 + private static final boolean DEF_DEPRECATE = false;
431.124 +
431.125 + private Preferences getPreferencesStorage() {
431.126 + return NbPreferences.forModule(GenerateScriptPanel.class).node(GenerateScriptPanel.class.getSimpleName());
431.127 + }
431.128 +
431.129 + private void loadDefaults() {
431.130 + if (supported) {
431.131 + Preferences p = getPreferencesStorage();
431.132 + generate.setSelected(p.getBoolean(KEY_DO_GENERATE_SCRIPT, DEF_DO_GENERATE_SCRIPT));
431.133 + makePrivate.setSelected(p.getBoolean(KEY_MAKE_PRIVATE, DEF_MAKE_PRIVATE));
431.134 + deprecate.setSelected(p.getBoolean(KEY_DEPRECATE, DEF_DEPRECATE));
431.135 + } else {
431.136 + generate.setSelected(false);
431.137 + makePrivate.setSelected(false);
431.138 + deprecate.setSelected(false);
431.139 + }
431.140 +
431.141 + updateState();
431.142 + }
431.143 +
431.144 + public void saveDefaults() {
431.145 + Preferences p = getPreferencesStorage();
431.146 + boolean doGenerate = generate.isSelected();
431.147 +
431.148 + p.putBoolean(KEY_DO_GENERATE_SCRIPT, doGenerate);
431.149 +
431.150 + if (doGenerate) {
431.151 + p.putBoolean(KEY_MAKE_PRIVATE, makePrivate.isSelected());
431.152 + p.putBoolean(KEY_DEPRECATE, deprecate.isSelected());
431.153 + }
431.154 + }
431.155 +
431.156 + private void updateState() {
431.157 + if (supported) {
431.158 + generate.setEnabled(true);
431.159 + makePrivate.setEnabled(generate.isSelected());
431.160 + deprecate.setEnabled(generate.isSelected());
431.161 + } else {
431.162 + generate.setEnabled(false);
431.163 + makePrivate.setEnabled(false);
431.164 + deprecate.setEnabled(false);
431.165 + }
431.166 + }
431.167 +
431.168 + // Variables declaration - do not modify//GEN-BEGIN:variables
431.169 + private javax.swing.JCheckBox deprecate;
431.170 + private javax.swing.JCheckBox generate;
431.171 + private javax.swing.JCheckBox makePrivate;
431.172 + // End of variables declaration//GEN-END:variables
431.173 +
431.174 + public ExtraData getData() {
431.175 + return new ExtraData(generate.isSelected(), makePrivate.isSelected(), deprecate.isSelected());
431.176 + }
431.177 +}
432.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
432.2 +++ b/sandbox/old-modules/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/RefactoringActionsProviderExt.java Mon Mar 12 21:10:10 2012 +0100
432.3 @@ -0,0 +1,238 @@
432.4 +/*
432.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
432.6 + *
432.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
432.8 + *
432.9 + * The contents of this file are subject to the terms of either the GNU
432.10 + * General Public License Version 2 only ("GPL") or the Common
432.11 + * Development and Distribution License("CDDL") (collectively, the
432.12 + * "License"). You may not use this file except in compliance with the
432.13 + * License. You can obtain a copy of the License at
432.14 + * http://www.netbeans.org/cddl-gplv2.html
432.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
432.16 + * specific language governing permissions and limitations under the
432.17 + * License. When distributing the software, include this License Header
432.18 + * Notice in each file and include the License file at
432.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
432.20 + * particular file as subject to the "Classpath" exception as provided
432.21 + * by Sun in the GPL Version 2 section of the License file that
432.22 + * accompanied this code. If applicable, add the following below the
432.23 + * License Header, with the fields enclosed by brackets [] replaced by
432.24 + * your own identifying information:
432.25 + * "Portions Copyrighted [year] [name of copyright owner]"
432.26 + *
432.27 + * If you wish your version of this file to be governed by only the CDDL
432.28 + * or only the GPL Version 2, indicate your decision by adding
432.29 + * "[Contributor] elects to include this software in this distribution
432.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
432.31 + * single choice of license, a recipient has the option to distribute
432.32 + * your version of this file under either the CDDL, the GPL Version 2 or
432.33 + * to extend the choice of license to its licensees as provided above.
432.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
432.35 + * Version 2 license, then the option applies only if the new code is
432.36 + * made subject to such option by the copyright holder.
432.37 + *
432.38 + * Contributor(s):
432.39 + *
432.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
432.41 + */
432.42 +package org.netbeans.modules.jackpot30.refactoring;
432.43 +
432.44 +import java.util.Collection;
432.45 +import java.util.HashSet;
432.46 +import java.util.logging.Logger;
432.47 +import javax.lang.model.element.Element;
432.48 +import javax.lang.model.element.ElementKind;
432.49 +import javax.lang.model.element.ExecutableElement;
432.50 +import javax.lang.model.element.VariableElement;
432.51 +import javax.lang.model.type.TypeKind;
432.52 +import org.netbeans.api.java.source.CompilationInfo;
432.53 +import org.netbeans.api.java.source.TreePathHandle;
432.54 +import org.netbeans.api.java.source.ui.ScanDialog;
432.55 +import org.netbeans.modules.jackpot30.refactoring.invertboolean.InvertBooleanRefactoringUI;
432.56 +import org.netbeans.modules.jackpot30.refactoring.noconstructor.ReplaceConstructorRefactoringUI;
432.57 +import org.netbeans.modules.refactoring.api.RenameRefactoring;
432.58 +import org.netbeans.modules.refactoring.java.RefactoringUtils;
432.59 +import org.netbeans.modules.refactoring.java.ui.RefactoringActionsProvider;
432.60 +import org.netbeans.modules.refactoring.spi.ui.ActionsImplementationProvider;
432.61 +import org.netbeans.modules.refactoring.spi.ui.RefactoringUI;
432.62 +import org.openide.cookies.EditorCookie;
432.63 +import org.openide.filesystems.FileObject;
432.64 +import org.openide.loaders.DataObject;
432.65 +import org.openide.nodes.Node;
432.66 +import org.openide.text.CloneableEditorSupport;
432.67 +import org.openide.util.Lookup;
432.68 +import org.openide.util.lookup.ServiceProvider;
432.69 +import org.openide.windows.TopComponent;
432.70 +
432.71 +
432.72 +/**
432.73 + *
432.74 + * @author lahvac
432.75 + */
432.76 +@ServiceProvider(service=ActionsImplementationProvider.class, supersedes="org.netbeans.modules.refactoring.java.ui.RefactoringActionsProvider")
432.77 +public class RefactoringActionsProviderExt extends RefactoringActionsProvider {
432.78 +
432.79 + private static RefactoringUI doReplaceConstructorImpl(TreePathHandle selectedElement, CompilationInfo info) {
432.80 + Element selected = selectedElement.resolveElement(info);
432.81 + if (selected==null) {
432.82 +// logger().log(Level.INFO, "doRename: " + selectedElement, new NullPointerException("selected")); // NOI18N
432.83 + return null;
432.84 + }
432.85 + if (selected.getKind() == ElementKind.CONSTRUCTOR) {
432.86 + return new ReplaceConstructorRefactoringUI(selectedElement);
432.87 + }
432.88 +
432.89 + return null;
432.90 + }
432.91 +
432.92 + public static void doReplaceConstructor(final Lookup lookup) {
432.93 + Runnable task;
432.94 + EditorCookie ec = lookup.lookup(EditorCookie.class);
432.95 + if (isFromEditor(ec)) {
432.96 + task = new TextComponentTask(ec) {
432.97 + @Override
432.98 + protected RefactoringUI createRefactoringUI(TreePathHandle selectedElement,int startOffset,int endOffset, final CompilationInfo info) {
432.99 + return doReplaceConstructorImpl(selectedElement, info);
432.100 + }
432.101 + };
432.102 + } else {
432.103 + task = new TreePathHandleTask(new HashSet<Node>(lookup.lookupAll(Node.class)), true) {
432.104 +
432.105 + RefactoringUI ui;
432.106 +
432.107 + @Override
432.108 + protected void treePathHandleResolved(TreePathHandle handle, CompilationInfo javac) {
432.109 + ui = doReplaceConstructorImpl(handle, javac);
432.110 + }
432.111 +
432.112 + @Override
432.113 + protected RefactoringUI createRefactoringUI(Collection<TreePathHandle> handles) {
432.114 + return ui;
432.115 + }
432.116 +
432.117 + };
432.118 + }
432.119 +
432.120 + ScanDialog.runWhenScanFinished(task, "Remove Constructor");//getActionName(RefactoringActionsFactory.renameAction()));
432.121 + }
432.122 +
432.123 + private static RefactoringUI doInvertBooleanImpl(TreePathHandle selectedElement, CompilationInfo info) {
432.124 + Element selected = selectedElement.resolveElement(info);
432.125 + if (selected==null) {
432.126 +// logger().log(Level.INFO, "doRename: " + selectedElement, new NullPointerException("selected")); // NOI18N
432.127 + return null;
432.128 + }
432.129 + if (selected.getKind().isField() && ((VariableElement) selected).asType().getKind() == TypeKind.BOOLEAN) {
432.130 + return new InvertBooleanRefactoringUI(selectedElement, ((VariableElement) selected).getSimpleName().toString());
432.131 + }
432.132 + if (selected.getKind() == ElementKind.METHOD && ((ExecutableElement) selected).getReturnType().getKind() == TypeKind.BOOLEAN) {
432.133 + return new InvertBooleanRefactoringUI(selectedElement, ((ExecutableElement) selected).getSimpleName().toString());
432.134 + }
432.135 +
432.136 + return null;
432.137 + }
432.138 +
432.139 + public static void doInvertBoolean(final Lookup lookup) {
432.140 + Runnable task;
432.141 + EditorCookie ec = lookup.lookup(EditorCookie.class);
432.142 + if (isFromEditor(ec)) {
432.143 + task = new TextComponentTask(ec) {
432.144 + @Override
432.145 + protected RefactoringUI createRefactoringUI(TreePathHandle selectedElement,int startOffset,int endOffset, final CompilationInfo info) {
432.146 + return doInvertBooleanImpl(selectedElement, info);
432.147 + }
432.148 + };
432.149 + } else {
432.150 + task = new TreePathHandleTask(new HashSet<Node>(lookup.lookupAll(Node.class)), true) {
432.151 +
432.152 + RefactoringUI ui;
432.153 +
432.154 + @Override
432.155 + protected void treePathHandleResolved(TreePathHandle handle, CompilationInfo javac) {
432.156 + ui = doInvertBooleanImpl(handle, javac);
432.157 + }
432.158 +
432.159 + @Override
432.160 + protected RefactoringUI createRefactoringUI(Collection<TreePathHandle> handles) {
432.161 + return ui;
432.162 + }
432.163 +
432.164 + };
432.165 + }
432.166 +
432.167 + ScanDialog.runWhenScanFinished(task, "Remove Constructor");//getActionName(RefactoringActionsFactory.renameAction()));
432.168 + }
432.169 +
432.170 +// static String getActionName(Action action) {
432.171 +// String arg = (String) action.getValue(Action.NAME);
432.172 +// arg = arg.replace("&", ""); // NOI18N
432.173 +// return arg.replace("...", ""); // NOI18N
432.174 +// }
432.175 +
432.176 +
432.177 + public static boolean canReplaceConstructor(Lookup lookup) {
432.178 + return canRefactor(lookup);
432.179 + }
432.180 +
432.181 + public static boolean canInvertBoolean(Lookup lookup) {
432.182 + return canRefactor(lookup);
432.183 + }
432.184 +
432.185 + private static boolean canRefactor(Lookup lookup) {
432.186 + Collection<? extends Node> nodes = new HashSet<Node>(lookup.lookupAll(Node.class));
432.187 + if(nodes.size() != 1)
432.188 + return false;
432.189 + Node node = nodes.iterator().next();
432.190 + TreePathHandle tph = node.getLookup().lookup(TreePathHandle.class);
432.191 + if (tph != null) {
432.192 + return RefactoringUtils.isRefactorable(tph.getFileObject());
432.193 + }
432.194 + DataObject dObj = node.getCookie(DataObject.class);
432.195 + if(null == dObj)
432.196 + return false;
432.197 + FileObject fileObj = dObj.getPrimaryFile();
432.198 + if(null == fileObj || !RefactoringUtils.isRefactorable(fileObj))
432.199 + return false;
432.200 +
432.201 + EditorCookie ec = lookup.lookup(EditorCookie.class);
432.202 + if (isFromEditor(ec)) {
432.203 + return true;
432.204 + }
432.205 + return false;
432.206 + }
432.207 +
432.208 + @Override
432.209 + protected RefactoringUI wrap(RefactoringUI orig) {
432.210 + if (orig.getRefactoring() instanceof RenameRefactoring) {
432.211 + return new RenameRefactoringWrapper(orig, ((RenameRefactoring) orig.getRefactoring()));
432.212 + }
432.213 +
432.214 + return super.wrap(orig);
432.215 + }
432.216 +
432.217 +
432.218 + //XXX: copied from RefactoringActionsProvider:\
432.219 + static boolean isFromEditor(EditorCookie ec) {
432.220 + if (ec != null && ec.getOpenedPanes() != null) {
432.221 + TopComponent activetc = TopComponent.getRegistry().getActivated();
432.222 + if (activetc instanceof CloneableEditorSupport.Pane) {
432.223 + return true;
432.224 + }
432.225 + }
432.226 + return false;
432.227 + }
432.228 +
432.229 + static boolean nodeHandle(Lookup lookup) {
432.230 + Node n = lookup.lookup(Node.class);
432.231 + if (n!=null) {
432.232 + if (n.getLookup().lookup(TreePathHandle.class)!=null)
432.233 + return true;
432.234 + }
432.235 + return false;
432.236 + }
432.237 +
432.238 + private static Logger logger() {
432.239 + return Logger.getLogger(RefactoringActionsProvider.class.getName());
432.240 + }
432.241 +}
433.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
433.2 +++ b/sandbox/old-modules/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/RefactoringElementImpl.java Mon Mar 12 21:10:10 2012 +0100
433.3 @@ -0,0 +1,227 @@
433.4 +/*
433.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
433.6 + *
433.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
433.8 + *
433.9 + * The contents of this file are subject to the terms of either the GNU
433.10 + * General Public License Version 2 only ("GPL") or the Common
433.11 + * Development and Distribution License("CDDL") (collectively, the
433.12 + * "License"). You may not use this file except in compliance with the
433.13 + * License. You can obtain a copy of the License at
433.14 + * http://www.netbeans.org/cddl-gplv2.html
433.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
433.16 + * specific language governing permissions and limitations under the
433.17 + * License. When distributing the software, include this License Header
433.18 + * Notice in each file and include the License file at
433.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
433.20 + * particular file as subject to the "Classpath" exception as provided
433.21 + * by Sun in the GPL Version 2 section of the License file that
433.22 + * accompanied this code. If applicable, add the following below the
433.23 + * License Header, with the fields enclosed by brackets [] replaced by
433.24 + * your own identifying information:
433.25 + * "Portions Copyrighted [year] [name of copyright owner]"
433.26 + *
433.27 + * If you wish your version of this file to be governed by only the CDDL
433.28 + * or only the GPL Version 2, indicate your decision by adding
433.29 + * "[Contributor] elects to include this software in this distribution
433.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
433.31 + * single choice of license, a recipient has the option to distribute
433.32 + * your version of this file under either the CDDL, the GPL Version 2 or
433.33 + * to extend the choice of license to its licensees as provided above.
433.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
433.35 + * Version 2 license, then the option applies only if the new code is
433.36 + * made subject to such option by the copyright holder.
433.37 + *
433.38 + * Contributor(s):
433.39 + *
433.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
433.41 + */
433.42 +
433.43 +package org.netbeans.modules.jackpot30.refactoring;
433.44 +
433.45 +import java.io.File;
433.46 +import java.io.FileInputStream;
433.47 +import java.io.IOException;
433.48 +import java.io.InputStreamReader;
433.49 +import java.io.OutputStreamWriter;
433.50 +import java.io.Reader;
433.51 +import java.io.Writer;
433.52 +import java.nio.charset.Charset;
433.53 +import org.netbeans.api.queries.FileEncodingQuery;
433.54 +import org.netbeans.modules.refactoring.spi.BackupFacility;
433.55 +import org.netbeans.modules.refactoring.spi.BackupFacility.Handle;
433.56 +import org.netbeans.modules.refactoring.spi.SimpleRefactoringElementImplementation;
433.57 +import org.openide.filesystems.FileObject;
433.58 +import org.openide.filesystems.FileUtil;
433.59 +import org.openide.text.PositionBounds;
433.60 +import org.openide.util.Exceptions;
433.61 +import org.openide.util.Lookup;
433.62 +
433.63 +/**
433.64 + *
433.65 + * @author lahvac
433.66 + */
433.67 +public class RefactoringElementImpl extends SimpleRefactoringElementImplementation {
433.68 +
433.69 + private final File target;
433.70 + private final String rule;
433.71 +
433.72 + public RefactoringElementImpl(File target, String rule) {
433.73 + this.target = target;
433.74 + this.rule = rule;
433.75 + }
433.76 +
433.77 + @Override
433.78 + public String getText() {
433.79 + return "Jackpot 3.0 rule";
433.80 + }
433.81 +
433.82 + @Override
433.83 + public String getDisplayText() {
433.84 + return "Jackpot 3.0 rule";
433.85 + }
433.86 +
433.87 + private Handle backup;
433.88 +
433.89 + @Override
433.90 + public void performChange() {
433.91 + try {
433.92 + FileObject fo = FileUtil.toFileObject(target);
433.93 + Charset encoding = FileEncodingQuery.getEncoding(getParentFile());
433.94 + String current;
433.95 +
433.96 + if (fo != null) {
433.97 + backup = BackupFacility.getDefault().backup(fo);
433.98 + current = read(target, encoding).toString();
433.99 + } else {
433.100 + if (!target.exists()) {
433.101 + backup = new Handle() {
433.102 + @Override
433.103 + public void restore() throws IOException {
433.104 + FileObject fo = FileUtil.toFileObject(target);
433.105 +
433.106 + fo.delete();
433.107 + }
433.108 + };
433.109 + current = "";
433.110 + } else {
433.111 + //XXX: log
433.112 + current = read(target, encoding).toString();
433.113 + }
433.114 + }
433.115 +
433.116 + current += rule;
433.117 + current += "\n";
433.118 +
433.119 + write(target, encoding, current);
433.120 + } catch (IOException ex) {
433.121 + Exceptions.printStackTrace(ex);
433.122 + }
433.123 + }
433.124 +
433.125 + @Override
433.126 + public void undoChange() {
433.127 + if (backup != null) {
433.128 + try {
433.129 + backup.restore();
433.130 + } catch (IOException ex) {
433.131 + Exceptions.printStackTrace(ex);
433.132 + }
433.133 + }
433.134 + backup = null;
433.135 + }
433.136 +
433.137 + @Override
433.138 + protected String getNewFileContent() {
433.139 + try {
433.140 + Charset encoding = FileEncodingQuery.getEncoding(getParentFile());
433.141 + String current;
433.142 +
433.143 + if (!target.exists()) {
433.144 + current = "";
433.145 + } else {
433.146 + //XXX: log
433.147 + current = read(target, encoding).toString();
433.148 + }
433.149 +
433.150 + current += rule;
433.151 + current += "\n";
433.152 +
433.153 + return current;
433.154 + } catch (IOException ex) {
433.155 + Exceptions.printStackTrace(ex);
433.156 + return null;
433.157 + }
433.158 + }
433.159 +
433.160 + @Override
433.161 + public Lookup getLookup() {
433.162 + return Lookup.EMPTY;
433.163 + }
433.164 +
433.165 + @Override
433.166 + public FileObject getParentFile() {
433.167 + File f = target;
433.168 +
433.169 + while (true) {
433.170 + FileObject fo = FileUtil.toFileObject(f);
433.171 +
433.172 + if (fo != null) {
433.173 + return fo;
433.174 + }
433.175 +
433.176 + f = f.getParentFile();
433.177 + }
433.178 + }
433.179 +
433.180 + @Override
433.181 + public PositionBounds getPosition() {
433.182 + //XXX:
433.183 + return null;
433.184 + }
433.185 +
433.186 + private CharSequence read(File f, Charset encoding) throws IOException {
433.187 + Reader in = null;
433.188 + StringBuilder result = new StringBuilder();
433.189 +
433.190 + try {
433.191 + in = new InputStreamReader(new FileInputStream(f), encoding);
433.192 +
433.193 + int r;
433.194 +
433.195 + while ((r = in.read()) != (-1)) {
433.196 + result.append((char) r);
433.197 + }
433.198 + } finally {
433.199 + if (in != null) {
433.200 + try {
433.201 + in.close();
433.202 + } catch (IOException ex) {
433.203 + Exceptions.printStackTrace(ex);
433.204 + }
433.205 + }
433.206 + }
433.207 +
433.208 + return result;
433.209 + }
433.210 +
433.211 + private void write(File f, Charset encoding, CharSequence text) throws IOException {
433.212 + Writer out = null;
433.213 +
433.214 + try {
433.215 + FileObject fo = FileUtil.createData(f);
433.216 + out = new OutputStreamWriter(fo.getOutputStream(), encoding);
433.217 +
433.218 + out.write(text.toString());
433.219 + } finally {
433.220 + if (out != null) {
433.221 + try {
433.222 + out.close();
433.223 + } catch (IOException ex) {
433.224 + Exceptions.printStackTrace(ex);
433.225 + }
433.226 + }
433.227 + }
433.228 + }
433.229 +
433.230 +}
434.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
434.2 +++ b/sandbox/old-modules/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/RefactoringPluginFactoryImpl.java Mon Mar 12 21:10:10 2012 +0100
434.3 @@ -0,0 +1,75 @@
434.4 +/*
434.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
434.6 + *
434.7 + * Copyright 2008-2010 Sun Microsystems, Inc. All rights reserved.
434.8 + *
434.9 + * The contents of this file are subject to the terms of either the GNU
434.10 + * General Public License Version 2 only ("GPL") or the Common
434.11 + * Development and Distribution License("CDDL") (collectively, the
434.12 + * "License"). You may not use this file except in compliance with the
434.13 + * License. You can obtain a copy of the License at
434.14 + * http://www.netbeans.org/cddl-gplv2.html
434.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
434.16 + * specific language governing permissions and limitations under the
434.17 + * License. When distributing the software, include this License Header
434.18 + * Notice in each file and include the License file at
434.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
434.20 + * particular file as subject to the "Classpath" exception as provided
434.21 + * by Sun in the GPL Version 2 section of the License file that
434.22 + * accompanied this code. If applicable, add the following below the
434.23 + * License Header, with the fields enclosed by brackets [] replaced by
434.24 + * your own identifying information:
434.25 + * "Portions Copyrighted [year] [name of copyright owner]"
434.26 + *
434.27 + * If you wish your version of this file to be governed by only the CDDL
434.28 + * or only the GPL Version 2, indicate your decision by adding
434.29 + * "[Contributor] elects to include this software in this distribution
434.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
434.31 + * single choice of license, a recipient has the option to distribute
434.32 + * your version of this file under either the CDDL, the GPL Version 2 or
434.33 + * to extend the choice of license to its licensees as provided above.
434.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
434.35 + * Version 2 license, then the option applies only if the new code is
434.36 + * made subject to such option by the copyright holder.
434.37 + *
434.38 + * Contributor(s):
434.39 + *
434.40 + * Portions Copyrighted 2008-2010 Sun Microsystems, Inc.
434.41 + */
434.42 +
434.43 +package org.netbeans.modules.jackpot30.refactoring;
434.44 +
434.45 +import org.netbeans.modules.jackpot30.refactoring.invertboolean.InvertBooleanRefactoring;
434.46 +import org.netbeans.modules.jackpot30.refactoring.invertboolean.InvertBooleanRefactoringPluginImpl;
434.47 +import org.netbeans.modules.jackpot30.refactoring.noconstructor.ReplaceConstructorRefactoring;
434.48 +import org.netbeans.modules.jackpot30.refactoring.noconstructor.ReplaceConstructorRefactoringPluginImpl;
434.49 +import org.netbeans.modules.refactoring.api.AbstractRefactoring;
434.50 +import org.netbeans.modules.refactoring.api.RenameRefactoring;
434.51 +import org.netbeans.modules.refactoring.spi.RefactoringPlugin;
434.52 +import org.netbeans.modules.refactoring.spi.RefactoringPluginFactory;
434.53 +import org.openide.util.lookup.ServiceProvider;
434.54 +
434.55 +/**
434.56 + *
434.57 + * @author Jan Lahoda
434.58 + */
434.59 +@ServiceProvider(service=RefactoringPluginFactory.class)
434.60 +public class RefactoringPluginFactoryImpl implements RefactoringPluginFactory {
434.61 +
434.62 + public RefactoringPlugin createInstance(AbstractRefactoring refactoring) {
434.63 + if (refactoring instanceof RenameRefactoring) {
434.64 + return new RenameRefactoringPluginImpl((RenameRefactoring) refactoring);
434.65 + }
434.66 +
434.67 + if (refactoring instanceof ReplaceConstructorRefactoring) {
434.68 + return new ReplaceConstructorRefactoringPluginImpl((ReplaceConstructorRefactoring) refactoring);
434.69 + }
434.70 +
434.71 + if (refactoring instanceof InvertBooleanRefactoring) {
434.72 + return new InvertBooleanRefactoringPluginImpl((InvertBooleanRefactoring) refactoring);
434.73 + }
434.74 +
434.75 + return null;
434.76 + }
434.77 +
434.78 +}
435.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
435.2 +++ b/sandbox/old-modules/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/RenameRefactoringPluginImpl.java Mon Mar 12 21:10:10 2012 +0100
435.3 @@ -0,0 +1,209 @@
435.4 +/*
435.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
435.6 + *
435.7 + * Copyright 2008-2010 Sun Microsystems, Inc. All rights reserved.
435.8 + *
435.9 + * The contents of this file are subject to the terms of either the GNU
435.10 + * General Public License Version 2 only ("GPL") or the Common
435.11 + * Development and Distribution License("CDDL") (collectively, the
435.12 + * "License"). You may not use this file except in compliance with the
435.13 + * License. You can obtain a copy of the License at
435.14 + * http://www.netbeans.org/cddl-gplv2.html
435.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
435.16 + * specific language governing permissions and limitations under the
435.17 + * License. When distributing the software, include this License Header
435.18 + * Notice in each file and include the License file at
435.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
435.20 + * particular file as subject to the "Classpath" exception as provided
435.21 + * by Sun in the GPL Version 2 section of the License file that
435.22 + * accompanied this code. If applicable, add the following below the
435.23 + * License Header, with the fields enclosed by brackets [] replaced by
435.24 + * your own identifying information:
435.25 + * "Portions Copyrighted [year] [name of copyright owner]"
435.26 + *
435.27 + * If you wish your version of this file to be governed by only the CDDL
435.28 + * or only the GPL Version 2, indicate your decision by adding
435.29 + * "[Contributor] elects to include this software in this distribution
435.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
435.31 + * single choice of license, a recipient has the option to distribute
435.32 + * your version of this file under either the CDDL, the GPL Version 2 or
435.33 + * to extend the choice of license to its licensees as provided above.
435.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
435.35 + * Version 2 license, then the option applies only if the new code is
435.36 + * made subject to such option by the copyright holder.
435.37 + *
435.38 + * Contributor(s):
435.39 + *
435.40 + * Portions Copyrighted 2008-2010 Sun Microsystems, Inc.
435.41 + */
435.42 +
435.43 +package org.netbeans.modules.jackpot30.refactoring;
435.44 +
435.45 +import com.sun.source.tree.BlockTree;
435.46 +import com.sun.source.tree.ClassTree;
435.47 +import com.sun.source.tree.ExpressionTree;
435.48 +import com.sun.source.tree.MethodInvocationTree;
435.49 +import com.sun.source.tree.MethodTree;
435.50 +import com.sun.source.tree.ModifiersTree;
435.51 +import com.sun.source.tree.StatementTree;
435.52 +import com.sun.source.tree.VariableTree;
435.53 +import com.sun.source.util.TreePath;
435.54 +import java.io.File;
435.55 +import java.util.Collections;
435.56 +import java.util.EnumSet;
435.57 +import java.util.LinkedList;
435.58 +import java.util.List;
435.59 +import java.util.Set;
435.60 +import javax.lang.model.element.Element;
435.61 +import javax.lang.model.element.ElementKind;
435.62 +import javax.lang.model.element.ExecutableElement;
435.63 +import javax.lang.model.element.Modifier;
435.64 +import javax.lang.model.element.TypeElement;
435.65 +import javax.lang.model.type.TypeKind;
435.66 +import org.netbeans.api.java.source.CancellableTask;
435.67 +import org.netbeans.api.java.source.ClasspathInfo.PathKind;
435.68 +import org.netbeans.api.java.source.JavaSource;
435.69 +import org.netbeans.api.java.source.TreeMaker;
435.70 +import org.netbeans.api.java.source.TreePathHandle;
435.71 +import org.netbeans.api.java.source.WorkingCopy;
435.72 +import org.netbeans.modules.refactoring.api.Problem;
435.73 +import org.netbeans.modules.refactoring.api.RenameRefactoring;
435.74 +import org.netbeans.modules.refactoring.java.spi.JavaRefactoringPlugin;
435.75 +import org.netbeans.modules.refactoring.spi.RefactoringElementsBag;
435.76 +import org.openide.filesystems.FileObject;
435.77 +import org.openide.filesystems.FileUtil;
435.78 +import org.openide.util.Lookup;
435.79 +
435.80 +/**
435.81 + *
435.82 + * @author Jan Lahoda
435.83 + */
435.84 +public class RenameRefactoringPluginImpl extends JavaRefactoringPlugin {
435.85 +
435.86 + private final RenameRefactoring rr;
435.87 +
435.88 + public RenameRefactoringPluginImpl(RenameRefactoring rr) {
435.89 + this.rr = rr;
435.90 + }
435.91 +
435.92 + @Override
435.93 + public Problem preCheck() {
435.94 + return null;
435.95 + }
435.96 +
435.97 + @Override
435.98 + public Problem checkParameters() {
435.99 + return null;
435.100 + }
435.101 +
435.102 + @Override
435.103 + public Problem fastCheckParameters() {
435.104 + return null;
435.105 + }
435.106 +
435.107 + @Override
435.108 + public void cancelRequest() {
435.109 + }
435.110 +
435.111 + public Problem prepare(final RefactoringElementsBag refactoringElements) {
435.112 + final ExtraData data = rr.getContext().lookup(ExtraData.class);
435.113 +
435.114 + if (data == null || !data.generateUpgradeScript) {
435.115 + return null;
435.116 + }
435.117 +
435.118 + Lookup source = rr.getRefactoringSource();
435.119 + final TreePathHandle toRename = source.lookup(TreePathHandle.class);
435.120 +
435.121 + if (toRename == null) {
435.122 + return null;
435.123 + }
435.124 +
435.125 + JavaSource js = JavaSource.forFileObject(toRename.getFileObject());
435.126 +
435.127 + if (js != null) {
435.128 + CancellableTask<WorkingCopy> work = new CancellableTask<WorkingCopy>() {
435.129 + public void run(WorkingCopy parameter) throws Exception {
435.130 + parameter.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
435.131 + TreePath tp = toRename.resolve(parameter);
435.132 +
435.133 + if (tp == null) {
435.134 + return ;
435.135 + }
435.136 +
435.137 + Element e = parameter.getTrees().getElement(tp);
435.138 +
435.139 + if (e == null || e.getKind() != ElementKind.METHOD) {
435.140 + return ;
435.141 + }
435.142 +
435.143 + MethodTree m = (MethodTree) tp.getLeaf();
435.144 + ClassTree ct = (ClassTree) tp.getParentPath().getLeaf();
435.145 +
435.146 + TreeMaker make = parameter.getTreeMaker();
435.147 +
435.148 + List<ExpressionTree> args = new LinkedList<ExpressionTree>();
435.149 +
435.150 + for (VariableTree vt : m.getParameters()) {
435.151 + args.add(make.Identifier(vt.getName()));
435.152 + }
435.153 +
435.154 + MethodInvocationTree mit = make.MethodInvocation(Collections.<ExpressionTree>emptyList(), make.Identifier(rr.getNewName()), args);
435.155 +
435.156 + StatementTree invoke;
435.157 +
435.158 + if (((ExecutableElement) e).getReturnType().getKind() == TypeKind.VOID) {
435.159 + invoke = make.ExpressionStatement(mit);
435.160 + } else {
435.161 + invoke = make.Return(mit);
435.162 + }
435.163 +
435.164 + BlockTree body = make.Block(Collections.<StatementTree>singletonList(invoke), false);
435.165 +// ModifiersTree mods = make.addModifiersAnnotation(m.getModifiers(), constructTransformation(parameter, make, rr.getNewName(), (ExecutableElement) e));
435.166 + ModifiersTree mods = m.getModifiers();
435.167 +
435.168 + if (data.makeOriginalDeprecated) {
435.169 + mods = make.addModifiersAnnotation(mods, make.Annotation(make.QualIdent(parameter.getElements().getTypeElement("java.lang.Deprecated")), Collections.<ExpressionTree>emptyList()));
435.170 + }
435.171 +
435.172 + if (data.makeOriginalPrivate) {
435.173 + Set<Modifier> modSet = EnumSet.noneOf(Modifier.class);
435.174 +
435.175 + modSet.addAll(mods.getFlags());
435.176 + modSet.removeAll(EnumSet.of(Modifier.PUBLIC, Modifier.PROTECTED));
435.177 + modSet.add(Modifier.PRIVATE);
435.178 +
435.179 + mods = make.Modifiers(modSet, mods.getAnnotations());
435.180 + }
435.181 +
435.182 + MethodTree nue = make.Method(mods, m.getName(), m.getReturnType(), m.getTypeParameters(), m.getParameters(), m.getThrows(), body, null);
435.183 +
435.184 + ClassTree nueClass = make.insertClassMember(ct, ct.getMembers().indexOf(m), nue);
435.185 +
435.186 + parameter.rewrite(ct, nueClass);
435.187 +
435.188 + FileObject root = parameter.getClasspathInfo().getClassPath(PathKind.SOURCE).findOwnerRoot(parameter.getFileObject());
435.189 +
435.190 + if (root != null) {
435.191 + File f = FileUtil.toFile(root);
435.192 + String rule = ScriptGenerator.constructRenameRule(parameter, rr.getNewName(), e);
435.193 + File ruleFile = new File(f, "META-INF/upgrade/" + ((TypeElement) e.getEnclosingElement()).getQualifiedName().toString() + ".hint");
435.194 +
435.195 + refactoringElements.add(rr, new RefactoringElementImpl( ruleFile, rule));
435.196 + }
435.197 + }
435.198 + public void cancel() {}
435.199 + };
435.200 +
435.201 + createAndAddElements(Collections.singleton(toRename.getFileObject()), work, refactoringElements, rr);
435.202 + }
435.203 +
435.204 + return null;
435.205 + }
435.206 +
435.207 + @Override
435.208 + protected JavaSource getJavaSource(Phase p) {
435.209 + return null;
435.210 + }
435.211 +
435.212 +}
436.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
436.2 +++ b/sandbox/old-modules/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/RenameRefactoringWrapper.java Mon Mar 12 21:10:10 2012 +0100
436.3 @@ -0,0 +1,162 @@
436.4 +/*
436.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
436.6 + *
436.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
436.8 + *
436.9 + * The contents of this file are subject to the terms of either the GNU
436.10 + * General Public License Version 2 only ("GPL") or the Common
436.11 + * Development and Distribution License("CDDL") (collectively, the
436.12 + * "License"). You may not use this file except in compliance with the
436.13 + * License. You can obtain a copy of the License at
436.14 + * http://www.netbeans.org/cddl-gplv2.html
436.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
436.16 + * specific language governing permissions and limitations under the
436.17 + * License. When distributing the software, include this License Header
436.18 + * Notice in each file and include the License file at
436.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
436.20 + * particular file as subject to the "Classpath" exception as provided
436.21 + * by Sun in the GPL Version 2 section of the License file that
436.22 + * accompanied this code. If applicable, add the following below the
436.23 + * License Header, with the fields enclosed by brackets [] replaced by
436.24 + * your own identifying information:
436.25 + * "Portions Copyrighted [year] [name of copyright owner]"
436.26 + *
436.27 + * If you wish your version of this file to be governed by only the CDDL
436.28 + * or only the GPL Version 2, indicate your decision by adding
436.29 + * "[Contributor] elects to include this software in this distribution
436.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
436.31 + * single choice of license, a recipient has the option to distribute
436.32 + * your version of this file under either the CDDL, the GPL Version 2 or
436.33 + * to extend the choice of license to its licensees as provided above.
436.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
436.35 + * Version 2 license, then the option applies only if the new code is
436.36 + * made subject to such option by the copyright holder.
436.37 + *
436.38 + * Contributor(s):
436.39 + *
436.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
436.41 + */
436.42 +
436.43 +package org.netbeans.modules.jackpot30.refactoring;
436.44 +
436.45 +import com.sun.source.tree.Tree.Kind;
436.46 +import java.awt.BorderLayout;
436.47 +import java.awt.Component;
436.48 +import javax.swing.JComponent;
436.49 +import javax.swing.JPanel;
436.50 +import javax.swing.border.EmptyBorder;
436.51 +import javax.swing.event.ChangeListener;
436.52 +import org.netbeans.api.java.source.TreePathHandle;
436.53 +import org.netbeans.modules.refactoring.api.AbstractRefactoring;
436.54 +import org.netbeans.modules.refactoring.api.Problem;
436.55 +import org.netbeans.modules.refactoring.api.RenameRefactoring;
436.56 +import org.netbeans.modules.refactoring.spi.ui.CustomRefactoringPanel;
436.57 +import org.netbeans.modules.refactoring.spi.ui.RefactoringUI;
436.58 +import org.openide.util.HelpCtx;
436.59 +import org.openide.util.Lookup;
436.60 +
436.61 +/**
436.62 + *
436.63 + * @author lahvac
436.64 + */
436.65 +public class RenameRefactoringWrapper implements RefactoringUI {
436.66 +
436.67 + private final RefactoringUI delegate;
436.68 + private final RenameRefactoring refactoring;
436.69 +
436.70 + public RenameRefactoringWrapper(RefactoringUI delegate, RenameRefactoring refactoring) {
436.71 + this.delegate = delegate;
436.72 + this.refactoring = refactoring;
436.73 + }
436.74 +
436.75 + @Override
436.76 + public String getName() {
436.77 + return delegate.getName();
436.78 + }
436.79 +
436.80 + @Override
436.81 + public String getDescription() {
436.82 + return delegate.getDescription();
436.83 + }
436.84 +
436.85 + @Override
436.86 + public boolean isQuery() {
436.87 + return delegate.isQuery();
436.88 + }
436.89 +
436.90 + private GenerateScriptPanel gsp;
436.91 + private CustomRefactoringPanel crp;
436.92 +
436.93 + @Override
436.94 + public CustomRefactoringPanel getPanel(ChangeListener parent) {
436.95 + if (crp == null) {
436.96 + Lookup source = refactoring.getRefactoringSource();
436.97 + TreePathHandle toRename = source.lookup(TreePathHandle.class);
436.98 +
436.99 + gsp = new GenerateScriptPanel(toRename != null && toRename.getKind() == Kind.METHOD);
436.100 + crp = new CustomRefactoringPanelImpl(gsp, delegate.getPanel(parent));
436.101 + }
436.102 +
436.103 + return crp;
436.104 + }
436.105 +
436.106 + @Override
436.107 + public Problem setParameters() {
436.108 + gsp.saveDefaults();
436.109 + refactoring.getContext().add(gsp.getData());
436.110 + return delegate.setParameters();
436.111 + }
436.112 +
436.113 + @Override
436.114 + public Problem checkParameters() {
436.115 + return delegate.checkParameters();
436.116 + }
436.117 +
436.118 + @Override
436.119 + public boolean hasParameters() {
436.120 + return true;
436.121 + }
436.122 +
436.123 + @Override
436.124 + public AbstractRefactoring getRefactoring() {
436.125 + return refactoring;
436.126 + }
436.127 +
436.128 + @Override
436.129 + public HelpCtx getHelpCtx() {
436.130 + return delegate.getHelpCtx();
436.131 + }
436.132 +
436.133 + private static final class CustomRefactoringPanelImpl implements CustomRefactoringPanel {
436.134 + private final CustomRefactoringPanel delegate;
436.135 + private final JComponent component;
436.136 + public CustomRefactoringPanelImpl(final GenerateScriptPanel panel, CustomRefactoringPanel delegate) {
436.137 + this.delegate = delegate;
436.138 + final Component delegateComponent = delegate.getComponent();
436.139 + this.component = new JPanel(new BorderLayout()) {
436.140 + {
436.141 + add(delegateComponent, BorderLayout.CENTER);
436.142 + panel.setBorder(new EmptyBorder(0, 5, 0, 0));
436.143 + add(panel, BorderLayout.SOUTH);
436.144 + delegateComponent.requestFocus();
436.145 + }
436.146 + @Override
436.147 + public void requestFocus() {
436.148 + delegateComponent.requestFocus();
436.149 + }
436.150 + };
436.151 + }
436.152 +
436.153 + @Override
436.154 + public void initialize() {
436.155 + delegate.initialize();
436.156 + }
436.157 +
436.158 + @Override
436.159 + public Component getComponent() {
436.160 + return component;
436.161 + }
436.162 +
436.163 + }
436.164 +
436.165 +}
437.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
437.2 +++ b/sandbox/old-modules/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/ScriptGenerator.java Mon Mar 12 21:10:10 2012 +0100
437.3 @@ -0,0 +1,113 @@
437.4 +/*
437.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
437.6 + *
437.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
437.8 + *
437.9 + * The contents of this file are subject to the terms of either the GNU
437.10 + * General Public License Version 2 only ("GPL") or the Common
437.11 + * Development and Distribution License("CDDL") (collectively, the
437.12 + * "License"). You may not use this file except in compliance with the
437.13 + * License. You can obtain a copy of the License at
437.14 + * http://www.netbeans.org/cddl-gplv2.html
437.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
437.16 + * specific language governing permissions and limitations under the
437.17 + * License. When distributing the software, include this License Header
437.18 + * Notice in each file and include the License file at
437.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
437.20 + * particular file as subject to the "Classpath" exception as provided
437.21 + * by Sun in the GPL Version 2 section of the License file that
437.22 + * accompanied this code. If applicable, add the following below the
437.23 + * License Header, with the fields enclosed by brackets [] replaced by
437.24 + * your own identifying information:
437.25 + * "Portions Copyrighted [year] [name of copyright owner]"
437.26 + *
437.27 + * If you wish your version of this file to be governed by only the CDDL
437.28 + * or only the GPL Version 2, indicate your decision by adding
437.29 + * "[Contributor] elects to include this software in this distribution
437.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
437.31 + * single choice of license, a recipient has the option to distribute
437.32 + * your version of this file under either the CDDL, the GPL Version 2 or
437.33 + * to extend the choice of license to its licensees as provided above.
437.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
437.35 + * Version 2 license, then the option applies only if the new code is
437.36 + * made subject to such option by the copyright holder.
437.37 + *
437.38 + * Contributor(s):
437.39 + *
437.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
437.41 + */
437.42 +
437.43 +package org.netbeans.modules.jackpot30.refactoring;
437.44 +
437.45 +import javax.lang.model.element.Element;
437.46 +import javax.lang.model.element.ExecutableElement;
437.47 +import javax.lang.model.element.Modifier;
437.48 +import javax.lang.model.element.TypeElement;
437.49 +import javax.lang.model.element.VariableElement;
437.50 +import org.netbeans.api.annotations.common.NonNull;
437.51 +import org.netbeans.api.java.source.WorkingCopy;
437.52 +
437.53 +/**
437.54 + *
437.55 + * @author lahvac
437.56 + */
437.57 +public class ScriptGenerator {
437.58 +
437.59 + public static @NonNull String constructRenameRule(@NonNull WorkingCopy wc, @NonNull String newName, @NonNull Element original) {
437.60 + switch (original.getKind()) {
437.61 + case METHOD: return constructRenameRule(wc, newName, (ExecutableElement) original);
437.62 + default: throw new UnsupportedOperationException();
437.63 + }
437.64 + }
437.65 +
437.66 + private static String constructRenameRule(WorkingCopy wc, String newName, ExecutableElement method) {
437.67 + //XXX: type parameters?
437.68 + StringBuilder pattern = new StringBuilder();
437.69 + StringBuilder constraints = new StringBuilder();
437.70 + StringBuilder target = new StringBuilder();
437.71 +
437.72 + TypeElement clazz = (TypeElement) method.getEnclosingElement();
437.73 +
437.74 + if (method.getModifiers().contains(Modifier.STATIC)) {
437.75 + pattern.append(clazz.getQualifiedName().toString()).append(".");
437.76 + target.append(clazz.getQualifiedName().toString()).append(".");
437.77 + } else {
437.78 + pattern.append("$0.");
437.79 + constraints.append(" :: $0 instanceof " + clazz.getQualifiedName().toString());
437.80 + target.append("$0.");
437.81 + }
437.82 +
437.83 + pattern.append(method.getSimpleName().toString());
437.84 + target.append(newName);
437.85 + pattern.append("(");
437.86 + target.append("(");
437.87 +
437.88 + int count = 1;
437.89 +
437.90 + for (VariableElement p : method.getParameters()) {
437.91 + if (count++ > 1) {
437.92 + pattern.append(", ");
437.93 + target.append(", ");
437.94 + }
437.95 +
437.96 + String name = "$" + p.getSimpleName().toString();
437.97 +
437.98 + pattern.append(name);
437.99 + target.append(name);
437.100 +
437.101 + if (constraints.length() == 0) {
437.102 + constraints.append(" :: ");
437.103 + } else {
437.104 + constraints.append(" && ");
437.105 + }
437.106 +
437.107 + constraints.append(name).append(" instanceof ").append(p.asType());
437.108 + }
437.109 +
437.110 + pattern.append(")");
437.111 + target.append(")");
437.112 +
437.113 + return " " + pattern + constraints + "\n=> " + target + "\n;;";
437.114 + }
437.115 +
437.116 +}
438.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
438.2 +++ b/sandbox/old-modules/bridges/refactoring/src/org/netbeans/modules/jackpot30/refactoring/layer.xml Mon Mar 12 21:10:10 2012 +0100
438.3 @@ -0,0 +1,34 @@
438.4 +<?xml version="1.0" encoding="UTF-8"?>
438.5 +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
438.6 +<filesystem>
438.7 + <folder name="Actions">
438.8 + <folder name="Refactoring">
438.9 + <file name="org-netbeans-modules-jackpot30-refactoring-noconstructor-ReplaceConstructorAction.instance">
438.10 + <attr name="instanceCreate" methodvalue="org.netbeans.modules.jackpot30.refactoring.noconstructor.ReplaceConstructorAction.create"/>
438.11 + </file>
438.12 + <file name="org-netbeans-modules-jackpot30-refactoring-invertboolean-InvertBooleanAction.instance">
438.13 + <attr name="instanceCreate" methodvalue="org.netbeans.modules.jackpot30.refactoring.invertboolean.InvertBooleanAction.create"/>
438.14 + </file>
438.15 + </folder>
438.16 + </folder>
438.17 + <folder name="Menu">
438.18 + <folder name="Refactoring">
438.19 + <file name="org-netbeans-modules-jackpot30-refactoring-noconstructor-ReplaceConstructorAction-separatorAfter.instance">
438.20 + <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
438.21 + <attr name="position" intvalue="2175"/>
438.22 + </file>
438.23 + <file name="org-netbeans-modules-jackpot30-refactoring-noconstructor-ReplaceConstructorAction-separatorBefore.instance">
438.24 + <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
438.25 + <attr name="position" intvalue="2125"/>
438.26 + </file>
438.27 + <file name="org-netbeans-modules-jackpot30-refactoring-noconstructor-ReplaceConstructorAction.shadow">
438.28 + <attr name="originalFile" stringvalue="Actions/Refactoring/org-netbeans-modules-jackpot30-refactoring-noconstructor-ReplaceConstructorAction.instance"/>
438.29 + <attr name="position" intvalue="2150"/>
438.30 + </file>
438.31 + <file name="org-netbeans-modules-jackpot30-refactoring-invertboolean-InvertBooleanAction.shadow">
438.32 + <attr name="originalFile" stringvalue="Actions/Refactoring/org-netbeans-modules-jackpot30-refactoring-invertboolean-InvertBooleanAction.instance"/>
438.33 + <attr name="position" intvalue="2152"/>
438.34 + </file>
438.35 + </folder>
438.36 + </folder>
438.37 +</filesystem>
439.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
439.2 +++ b/sandbox/old-modules/bridges/refactoring/test/unit/src/org/netbeans/modules/jackpot30/refactoring/RefactoringTestBase.java Mon Mar 12 21:10:10 2012 +0100
439.3 @@ -0,0 +1,251 @@
439.4 +/*
439.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
439.6 + *
439.7 + * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
439.8 + *
439.9 + * The contents of this file are subject to the terms of either the GNU
439.10 + * General Public License Version 2 only ("GPL") or the Common
439.11 + * Development and Distribution License("CDDL") (collectively, the
439.12 + * "License"). You may not use this file except in compliance with the
439.13 + * License. You can obtain a copy of the License at
439.14 + * http://www.netbeans.org/cddl-gplv2.html
439.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
439.16 + * specific language governing permissions and limitations under the
439.17 + * License. When distributing the software, include this License Header
439.18 + * Notice in each file and include the License file at
439.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
439.20 + * particular file as subject to the "Classpath" exception as provided
439.21 + * by Sun in the GPL Version 2 section of the License file that
439.22 + * accompanied this code. If applicable, add the following below the
439.23 + * License Header, with the fields enclosed by brackets [] replaced by
439.24 + * your own identifying information:
439.25 + * "Portions Copyrighted [year] [name of copyright owner]"
439.26 + *
439.27 + * If you wish your version of this file to be governed by only the CDDL
439.28 + * or only the GPL Version 2, indicate your decision by adding
439.29 + * "[Contributor] elects to include this software in this distribution
439.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
439.31 + * single choice of license, a recipient has the option to distribute
439.32 + * your version of this file under either the CDDL, the GPL Version 2 or
439.33 + * to extend the choice of license to its licensees as provided above.
439.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
439.35 + * Version 2 license, then the option applies only if the new code is
439.36 + * made subject to such option by the copyright holder.
439.37 + *
439.38 + * Contributor(s):
439.39 + *
439.40 + * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
439.41 + */
439.42 +package org.netbeans.modules.jackpot30.refactoring;
439.43 +
439.44 +import java.io.IOException;
439.45 +import java.util.Arrays;
439.46 +import java.util.Collections;
439.47 +import java.util.HashMap;
439.48 +import java.util.HashSet;
439.49 +import java.util.LinkedList;
439.50 +import java.util.List;
439.51 +import java.util.Map;
439.52 +import java.util.Set;
439.53 +import org.netbeans.api.editor.mimelookup.MimePath;
439.54 +import org.netbeans.api.java.classpath.ClassPath;
439.55 +import org.netbeans.api.java.classpath.GlobalPathRegistry;
439.56 +import org.netbeans.api.java.source.SourceUtils;
439.57 +import org.netbeans.api.java.source.SourceUtilsTestUtil;
439.58 +import org.netbeans.api.java.source.TestUtilities;
439.59 +import org.netbeans.api.project.Project;
439.60 +import org.netbeans.api.project.ProjectManager;
439.61 +import org.netbeans.core.startup.Main;
439.62 +import org.netbeans.junit.NbTestCase;
439.63 +import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
439.64 +import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
439.65 +import org.netbeans.modules.parsing.impl.indexing.MimeTypes;
439.66 +import org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater;
439.67 +import org.netbeans.modules.refactoring.api.AbstractRefactoring;
439.68 +import org.netbeans.modules.refactoring.api.RefactoringSession;
439.69 +import org.netbeans.spi.editor.mimelookup.MimeDataProvider;
439.70 +import org.netbeans.spi.java.classpath.ClassPathProvider;
439.71 +import org.netbeans.spi.java.classpath.support.ClassPathSupport;
439.72 +import org.netbeans.spi.project.ProjectFactory;
439.73 +import org.netbeans.spi.project.ProjectState;
439.74 +import org.openide.filesystems.FileObject;
439.75 +import org.openide.filesystems.FileUtil;
439.76 +import org.openide.util.Lookup;
439.77 +import org.openide.util.lookup.Lookups;
439.78 +import org.openide.util.lookup.ServiceProvider;
439.79 +
439.80 +public class RefactoringTestBase extends NbTestCase {
439.81 +
439.82 + public RefactoringTestBase(String name) {
439.83 + super(name);
439.84 + }
439.85 +
439.86 + protected static void writeFilesAndWaitForScan(FileObject sourceRoot, File... files) throws Exception {
439.87 + for (FileObject c : sourceRoot.getChildren()) {
439.88 + c.delete();
439.89 + }
439.90 +
439.91 + for (File f : files) {
439.92 + FileObject fo = FileUtil.createData(sourceRoot, f.filename);
439.93 + TestUtilities.copyStringToFile(fo, f.content);
439.94 + }
439.95 +
439.96 + SourceUtils.waitScanFinished();
439.97 + }
439.98 +
439.99 + protected static final class File {
439.100 + public final String filename;
439.101 + public final String content;
439.102 +
439.103 + public File(String filename, String content) {
439.104 + this.filename = filename;
439.105 + this.content = content;
439.106 + }
439.107 + }
439.108 +
439.109 + protected FileObject src;
439.110 + protected Project prj;
439.111 +
439.112 + @Override
439.113 + protected void setUp() throws Exception {
439.114 + SourceUtilsTestUtil.prepareTest(new String[0], new Object[] {
439.115 + new ClassPathProvider() {
439.116 + public ClassPath findClassPath(FileObject file, String type) {
439.117 + if (src != null && (file == src || FileUtil.isParentOf(src, file))) {
439.118 + if (ClassPath.BOOT.equals(type)) {
439.119 + return ClassPathSupport.createClassPath(System.getProperty("sun.boot.class.path"));
439.120 + }
439.121 + if (ClassPath.COMPILE.equals(type)) {
439.122 + return ClassPathSupport.createClassPath(new FileObject[0]);
439.123 + }
439.124 + if (ClassPath.SOURCE.equals(type)) {
439.125 + return ClassPathSupport.createClassPath(src);
439.126 + }
439.127 + }
439.128 +
439.129 + return null;
439.130 + }
439.131 + },
439.132 + new ProjectFactory() {
439.133 + public boolean isProject(FileObject projectDirectory) {
439.134 + return src == projectDirectory;
439.135 + }
439.136 + public Project loadProject(final FileObject projectDirectory, ProjectState state) throws IOException {
439.137 + if (!isProject(projectDirectory)) return null;
439.138 + return new Project() {
439.139 + public FileObject getProjectDirectory() {
439.140 + return projectDirectory;
439.141 + }
439.142 + public Lookup getLookup() {
439.143 + return Lookup.EMPTY;
439.144 + }
439.145 + };
439.146 + }
439.147 + public void saveProject(Project project) throws IOException, ClassCastException {}
439.148 + }
439.149 + });
439.150 + Main.initializeURLFactory();
439.151 + org.netbeans.api.project.ui.OpenProjects.getDefault().getOpenProjects();
439.152 + prepareTest();
439.153 + org.netbeans.api.project.ui.OpenProjects.getDefault().open(new Project[] {prj = ProjectManager.getDefault().findProject(src)}, false);
439.154 + MimeTypes.setAllMimeTypes(Collections.singleton("text/x-java"));
439.155 + GlobalPathRegistry.getDefault().register(ClassPath.SOURCE, new ClassPath[] {ClassPathSupport.createClassPath(src)});
439.156 + RepositoryUpdater.getDefault().start(true);
439.157 + super.setUp();
439.158 + }
439.159 +
439.160 + @Override
439.161 + protected void tearDown() throws Exception {
439.162 + super.tearDown();
439.163 + org.netbeans.api.project.ui.OpenProjects.getDefault().open(new Project[] {prj}, false);
439.164 + prj = null;
439.165 + }
439.166 +
439.167 + private void prepareTest() throws Exception {
439.168 + FileObject workdir = SourceUtilsTestUtil.makeScratchDir(this);
439.169 +
439.170 + src = FileUtil.createFolder(workdir, "src");
439.171 +
439.172 + FileObject cache = FileUtil.createFolder(workdir, "cache");
439.173 +
439.174 + CacheFolder.setCacheFolder(cache);
439.175 + }
439.176 +
439.177 + protected void performRefactoring(AbstractRefactoring r, File... verify) throws IOException {
439.178 + Map<FileObject, String> originalContent = new HashMap<FileObject, String>();
439.179 +
439.180 + for (FileObject file : recursive(src)) {
439.181 + originalContent.put(file, readFile(file));
439.182 + }
439.183 +
439.184 + RefactoringSession rs = RefactoringSession.create("Session");
439.185 +
439.186 + r.prepare(rs);
439.187 +
439.188 + assertNull(rs.doRefactoring(true));
439.189 +
439.190 +// IndexingManager.getDefault().refreshIndex(src.getURL(), null);
439.191 +// SourceUtils.waitScanFinished();
439.192 +// assertEquals(false, TaskCache.getDefault().isInError(src, true));
439.193 +
439.194 + for (File v : verify) {
439.195 + FileObject file = src.getFileObject(v.filename);
439.196 +
439.197 + assertNotNull(v.filename, file);
439.198 +
439.199 + String content = readFile(file);
439.200 +
439.201 + assertEquals(v.content.replaceAll("[ \n\t]+", " "), content.replaceAll("[ \n\t]+", " "));
439.202 + }
439.203 +
439.204 + rs.undoRefactoring(true);
439.205 +
439.206 + for (FileObject file : recursive(src)) {
439.207 + String content = originalContent.remove(file);
439.208 +
439.209 + assertNotNull(FileUtil.getFileDisplayName(file), content);
439.210 + assertEquals(content, readFile(file));
439.211 + }
439.212 +
439.213 + assertTrue(originalContent.toString(), originalContent.isEmpty());
439.214 + }
439.215 +
439.216 + private String readFile(FileObject file) throws IOException {
439.217 + return TestUtilities.copyFileToString(FileUtil.toFile(file));
439.218 + }
439.219 +
439.220 + private static Iterable<? extends FileObject> recursive(FileObject r) {
439.221 + Set<FileObject> result = new HashSet<FileObject>();
439.222 + List<FileObject> queue = new LinkedList<FileObject>();
439.223 +
439.224 + queue.add(r);
439.225 +
439.226 + while (!queue.isEmpty()) {
439.227 + FileObject c = queue.remove(0);
439.228 +
439.229 + if (c.isData()) {
439.230 + result.add(c);
439.231 + } else {
439.232 + queue.addAll(Arrays.asList(c.getChildren()));
439.233 + }
439.234 + }
439.235 +
439.236 + return result;
439.237 + }
439.238 +
439.239 + @ServiceProvider(service=MimeDataProvider.class)
439.240 + public static final class MimeDataProviderImpl implements MimeDataProvider {
439.241 +
439.242 + private static final Lookup L = Lookups.singleton(new JavaCustomIndexer.Factory());
439.243 +
439.244 + public Lookup getLookup(MimePath mimePath) {
439.245 + if ("text/x-java".equals(mimePath.getPath())) {
439.246 + return L;
439.247 + }
439.248 +
439.249 + return null;
439.250 + }
439.251 +
439.252 + }
439.253 +
439.254 +}
440.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
440.2 +++ b/sandbox/old-modules/bridges/refactoring/test/unit/src/org/netbeans/modules/jackpot30/refactoring/RenameRefactoringPluginImplTest.java Mon Mar 12 21:10:10 2012 +0100
440.3 @@ -0,0 +1,111 @@
440.4 +/*
440.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
440.6 + *
440.7 + * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
440.8 + *
440.9 + * The contents of this file are subject to the terms of either the GNU
440.10 + * General Public License Version 2 only ("GPL") or the Common
440.11 + * Development and Distribution License("CDDL") (collectively, the
440.12 + * "License"). You may not use this file except in compliance with the
440.13 + * License. You can obtain a copy of the License at
440.14 + * http://www.netbeans.org/cddl-gplv2.html
440.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
440.16 + * specific language governing permissions and limitations under the
440.17 + * License. When distributing the software, include this License Header
440.18 + * Notice in each file and include the License file at
440.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
440.20 + * particular file as subject to the "Classpath" exception as provided
440.21 + * by Sun in the GPL Version 2 section of the License file that
440.22 + * accompanied this code. If applicable, add the following below the
440.23 + * License Header, with the fields enclosed by brackets [] replaced by
440.24 + * your own identifying information:
440.25 + * "Portions Copyrighted [year] [name of copyright owner]"
440.26 + *
440.27 + * If you wish your version of this file to be governed by only the CDDL
440.28 + * or only the GPL Version 2, indicate your decision by adding
440.29 + * "[Contributor] elects to include this software in this distribution
440.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
440.31 + * single choice of license, a recipient has the option to distribute
440.32 + * your version of this file under either the CDDL, the GPL Version 2 or
440.33 + * to extend the choice of license to its licensees as provided above.
440.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
440.35 + * Version 2 license, then the option applies only if the new code is
440.36 + * made subject to such option by the copyright holder.
440.37 + *
440.38 + * Contributor(s):
440.39 + *
440.40 + * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
440.41 + */
440.42 +package org.netbeans.modules.jackpot30.refactoring;
440.43 +
440.44 +import com.sun.source.tree.ClassTree;
440.45 +import com.sun.source.tree.CompilationUnitTree;
440.46 +import com.sun.source.tree.MethodTree;
440.47 +import com.sun.source.util.TreePath;
440.48 +import org.netbeans.api.java.source.CompilationController;
440.49 +import org.netbeans.api.java.source.JavaSource;
440.50 +import org.netbeans.api.java.source.Task;
440.51 +import org.netbeans.api.java.source.TreePathHandle;
440.52 +import org.netbeans.modules.refactoring.api.RenameRefactoring;
440.53 +import org.openide.util.lookup.Lookups;
440.54 +
440.55 +public class RenameRefactoringPluginImplTest extends RefactoringTestBase {
440.56 +
440.57 + public RenameRefactoringPluginImplTest(String name) {
440.58 + super(name);
440.59 + }
440.60 +
440.61 + public void testSimple1() throws Exception {
440.62 + writeFilesAndWaitForScan(src,
440.63 + new File("t/A.java", "package t; public class A {\n public void test() {\n}\n }"));
440.64 + final RenameRefactoring[] r = new RenameRefactoring[1];
440.65 +
440.66 + JavaSource.forFileObject(src.getFileObject("t/A.java")).runUserActionTask(new Task<CompilationController>() {
440.67 +
440.68 + public void run(CompilationController parameter) throws Exception {
440.69 + parameter.toPhase(JavaSource.Phase.RESOLVED);
440.70 + CompilationUnitTree cut = parameter.getCompilationUnit();
440.71 +
440.72 + MethodTree var = (MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(1);
440.73 +
440.74 + TreePath tp = TreePath.getPath(cut, var);
440.75 + r[0] = new RenameRefactoring(Lookups.singleton(TreePathHandle.create(tp, parameter)));
440.76 + }
440.77 + }, true);
440.78 +
440.79 + r[0].setNewName("foo");
440.80 + r[0].getContext().add(new ExtraData(true, true, true));
440.81 +
440.82 + performRefactoring(r[0],
440.83 + new File("t/A.java", "package t; public class A { @Deprecated private void test() { foo(); } public void foo() { } }"),
440.84 + new File("META-INF/upgrade/t.A.hint", " $0.test() :: $0 instanceof t.A => $0.foo() ;; "));
440.85 + }
440.86 +
440.87 + public void testSimple2() throws Exception {
440.88 + writeFilesAndWaitForScan(src,
440.89 + new File("t/A.java", "package t; public class A {\n public void test() {\n}\n }"),
440.90 + new File("META-INF/upgrade/t.A.hint", "$0.isDirectory();; "));
440.91 + final RenameRefactoring[] r = new RenameRefactoring[1];
440.92 +
440.93 + JavaSource.forFileObject(src.getFileObject("t/A.java")).runUserActionTask(new Task<CompilationController>() {
440.94 +
440.95 + public void run(CompilationController parameter) throws Exception {
440.96 + parameter.toPhase(JavaSource.Phase.RESOLVED);
440.97 + CompilationUnitTree cut = parameter.getCompilationUnit();
440.98 +
440.99 + MethodTree var = (MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(1);
440.100 +
440.101 + TreePath tp = TreePath.getPath(cut, var);
440.102 + r[0] = new RenameRefactoring(Lookups.singleton(TreePathHandle.create(tp, parameter)));
440.103 + }
440.104 + }, true);
440.105 +
440.106 + r[0].setNewName("foo");
440.107 + r[0].getContext().add(new ExtraData(true, /*XXX: false will fail badly here!!*/true, false));
440.108 +
440.109 + performRefactoring(r[0],
440.110 + new File("t/A.java", "package t; public class A { private void test() { foo(); } public void foo() { } }"),
440.111 + new File("META-INF/upgrade/t.A.hint", "$0.isDirectory();; $0.test() :: $0 instanceof t.A => $0.foo() ;; "));
440.112 + }
440.113 +
440.114 +}
441.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
441.2 +++ b/sandbox/old-modules/bridges/refactoring/test/unit/src/org/netbeans/modules/jackpot30/refactoring/ScriptGeneratorTest.java Mon Mar 12 21:10:10 2012 +0100
441.3 @@ -0,0 +1,135 @@
441.4 +/*
441.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
441.6 + *
441.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
441.8 + *
441.9 + * The contents of this file are subject to the terms of either the GNU
441.10 + * General Public License Version 2 only ("GPL") or the Common
441.11 + * Development and Distribution License("CDDL") (collectively, the
441.12 + * "License"). You may not use this file except in compliance with the
441.13 + * License. You can obtain a copy of the License at
441.14 + * http://www.netbeans.org/cddl-gplv2.html
441.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
441.16 + * specific language governing permissions and limitations under the
441.17 + * License. When distributing the software, include this License Header
441.18 + * Notice in each file and include the License file at
441.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
441.20 + * particular file as subject to the "Classpath" exception as provided
441.21 + * by Sun in the GPL Version 2 section of the License file that
441.22 + * accompanied this code. If applicable, add the following below the
441.23 + * License Header, with the fields enclosed by brackets [] replaced by
441.24 + * your own identifying information:
441.25 + * "Portions Copyrighted [year] [name of copyright owner]"
441.26 + *
441.27 + * If you wish your version of this file to be governed by only the CDDL
441.28 + * or only the GPL Version 2, indicate your decision by adding
441.29 + * "[Contributor] elects to include this software in this distribution
441.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
441.31 + * single choice of license, a recipient has the option to distribute
441.32 + * your version of this file under either the CDDL, the GPL Version 2 or
441.33 + * to extend the choice of license to its licensees as provided above.
441.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
441.35 + * Version 2 license, then the option applies only if the new code is
441.36 + * made subject to such option by the copyright holder.
441.37 + *
441.38 + * Contributor(s):
441.39 + *
441.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
441.41 + */
441.42 +
441.43 +package org.netbeans.modules.jackpot30.refactoring;
441.44 +
441.45 +import com.sun.source.util.TreePath;
441.46 +import java.util.regex.Pattern;
441.47 +import javax.lang.model.element.Element;
441.48 +import org.netbeans.api.java.source.SourceUtilsTestUtil;
441.49 +import org.netbeans.modules.jackpot30.impl.TestBase;
441.50 +
441.51 +/**
441.52 + *
441.53 + * @author lahvac
441.54 + */
441.55 +public class ScriptGeneratorTest extends TestBase {
441.56 +
441.57 + public ScriptGeneratorTest(String testName) {
441.58 + super(testName);
441.59 + }
441.60 +
441.61 + @Override
441.62 + protected void setUp() throws Exception {
441.63 + SourceUtilsTestUtil.prepareTest(new String[0], new Object[0]);
441.64 + super.setUp();
441.65 + }
441.66 +
441.67 + public void testInstanceMethod() throws Exception {
441.68 + performTest("package test;\n" +
441.69 + "public class Test {\n" +
441.70 + " public void te|st() {}" +
441.71 + "}\n",
441.72 + "foo",
441.73 + " $0.test() :: $0 instanceof test.Test\n" +
441.74 + "=> $0.foo()\n" +
441.75 + ";;");
441.76 + }
441.77 +
441.78 + public void testInstanceMethodParam() throws Exception {
441.79 + performTest("package test;\n" +
441.80 + "public class Test {\n" +
441.81 + " public void te|st(int i) {}" +
441.82 + "}\n",
441.83 + "foo",
441.84 + " $0.test($i) :: $0 instanceof test.Test && $i instanceof int\n" +
441.85 + "=> $0.foo($i)\n" +
441.86 + ";;");
441.87 + }
441.88 +
441.89 + public void testStaticMethod() throws Exception {
441.90 + performTest("package test;\n" +
441.91 + "public class Test {\n" +
441.92 + " public static void te|st() {}" +
441.93 + "}\n",
441.94 + "foo",
441.95 + " test.Test.test()\n" +
441.96 + "=> test.Test.foo()\n" +
441.97 + ";;");
441.98 + }
441.99 +
441.100 + public void testStaticMethodParam() throws Exception {
441.101 + performTest("package test;\n" +
441.102 + "public class Test {\n" +
441.103 + " public static void te|st(int i) {}" +
441.104 + "}\n",
441.105 + "foo",
441.106 + " test.Test.test($i) :: $i instanceof int\n" +
441.107 + "=> test.Test.foo($i)\n" +
441.108 + ";;");
441.109 + }
441.110 +
441.111 + public void testMultipleParameters183659() throws Exception {
441.112 + performTest("package test;\n" +
441.113 + "public class Test {\n" +
441.114 + " public void te|st(int i, int j) {}" +
441.115 + "}\n",
441.116 + "foo",
441.117 + " $0.test($i, $j) :: $0 instanceof test.Test && $i instanceof int && $j instanceof int\n" +
441.118 + "=> $0.foo($i, $j)\n" +
441.119 + ";;");
441.120 + }
441.121 +
441.122 + private void performTest(String code, String newName, String script) throws Exception {
441.123 + assertEquals(2, code.split(Pattern.quote("|")).length);
441.124 +
441.125 + int pos = code.indexOf('|');
441.126 +
441.127 + code = code.substring(0, pos) + code.substring(pos + 1);
441.128 +
441.129 + prepareTest("test/Test.java", code);
441.130 +
441.131 + TreePath path = info.getTreeUtilities().pathFor(pos);
441.132 + Element el = info.getTrees().getElement(path);
441.133 +
441.134 + assertNotNull(el);
441.135 +
441.136 + assertEquals(script, ScriptGenerator.constructRenameRule(null, newName, el));
441.137 + }
441.138 +}
442.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
442.2 +++ b/sandbox/old-modules/help/build.xml Mon Mar 12 21:10:10 2012 +0100
442.3 @@ -0,0 +1,48 @@
442.4 +<?xml version="1.0" encoding="UTF-8"?>
442.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
442.6 +<!-- for some information on what you could do (e.g. targets to override). -->
442.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
442.8 +<project name="org.netbeans.modules.jackpot30.help" default="netbeans" basedir=".">
442.9 + <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.help.</description>
442.10 + <import file="nbproject/build-impl.xml"/>
442.11 + <import file="${suite.dir}/findbugs-import.xml"/>
442.12 +
442.13 + <target name="help-init">
442.14 + <property environment="ENV." />
442.15 + <condition property="hasLaTeX2HTML">
442.16 + <available file="latex2html" filepath="${ENV.PATH}" />
442.17 + </condition>
442.18 + </target>
442.19 +
442.20 + <target name="compile-help" depends="help-init" if="hasLaTeX2HTML">
442.21 + <mkdir dir="${basedir}/build/help/org/netbeans/modules/jackpot30/help/docs" />
442.22 +
442.23 + <copy file="jackpot30-helpset.xml" todir="${basedir}/build/help/org/netbeans/modules/jackpot30/help/docs" />
442.24 +
442.25 + <exec executable="latex2html">
442.26 + <arg value="-antialias" />
442.27 + <arg value="-antialias_text" />
442.28 + <arg value="-dir" />
442.29 + <arg value="build/help/org/netbeans/modules/jackpot30/help/docs" />
442.30 + <arg value="jackpot30-help.tex" />
442.31 + </exec>
442.32 +
442.33 + <java classname="org.netbeans.modules.jackpot30.help.CreateMap"
442.34 + classpath="build/classes">
442.35 + <arg value="${basedir}/build/help/org/netbeans/modules/jackpot30/help/docs" />
442.36 + </java>
442.37 +
442.38 + <mkdir dir="${suite.dir}/build/cluster/modules/docs" />
442.39 +
442.40 + <jar destfile="${suite.dir}/build/cluster/modules/docs/org-netbeans-modules-jackpot30-help.jar" basedir="${basedir}/build/help">
442.41 +
442.42 + </jar>
442.43 + </target>
442.44 +
442.45 + <target name="compile" depends="projectized-common.compile,compile-help" />
442.46 +
442.47 + <target name="test" />
442.48 + <target name="test-coverage" />
442.49 + <target name="coverage-report" />
442.50 +
442.51 +</project>
443.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
443.2 +++ b/sandbox/old-modules/help/jackpot30-help.tex Mon Mar 12 21:10:10 2012 +0100
443.3 @@ -0,0 +1,119 @@
443.4 +\documentclass{article}
443.5 +\usepackage{verbdef}
443.6 +\usepackage{hyperref}
443.7 +
443.8 +\verbdef\simplevariable=$[0-9A-Za-z_]+=
443.9 +\verbdef\statementvariable=$[0-9A-Za-z_]+;=
443.10 +\verbdef\multipletreevariable=$[0-9A-Za-z_]+$=
443.11 +\verbdef\multiplestatementvariable=$[0-9A-Za-z_]+$;=
443.12 +\verbdef\wholepattern=$_=
443.13 +\verbdef\reserved=$$[0-9A-Za-z_]+=
443.14 +
443.15 +\begin{document}
443.16 +
443.17 +\section{Rules Language}
443.18 +
443.19 +\subsection{Basic Structure}
443.20 +
443.21 +The rules file consists of any number of transformation rules.
443.22 +The rule is defined as follows:
443.23 +\begin{verbatim}
443.24 + <pattern>
443.25 +=> <fix-pattern>
443.26 +=> <fix-pattern>
443.27 +;;
443.28 +\end{verbatim}
443.29 +
443.30 +Each occurrence of \verb=<pattern>= in the source code can be rewritten to one
443.31 +of the \verb=<fix-pattern>=s. For example, the following transformation rule:
443.32 +\begin{verbatim}
443.33 + $1 == null
443.34 +=> null == $1
443.35 +;;
443.36 +\end{verbatim}
443.37 +
443.38 +will rewrite the following code:
443.39 +\begin{verbatim}
443.40 +if (a == null) {
443.41 + System.err.println("a is null");
443.42 +}
443.43 +\end{verbatim}
443.44 +to:
443.45 +\begin{verbatim}
443.46 +if (null == a) {
443.47 + System.err.println("a is null");
443.48 +}
443.49 +\end{verbatim}
443.50 +
443.51 +Note: \verb=$1$= is a variable, explained \hyperref{below}{in Section~}{variables}{}.
443.52 +
443.53 +Note: batch refactoring will typically use only the first applicable fix patterns
443.54 +of each applicable rule.
443.55 +
443.56 +\subsection{Patterns}
443.57 +
443.58 +The pattern is a Java expression, statement or several statements.
443.59 +All references to classes in the pattern need to be resolvable, i.e. either fully
443.60 +qualified names need to be used, or the custom import section must be used
443.61 +(see \hyperref{Custom Imports}{Section~}{custom-import}{}).
443.62 +
443.63 +TODO: equivalence - static elements are checked only against themselves, blocks with
443.64 +one statement considered equivalent to single statement.
443.65 +
443.66 +Note: variable declaration is a Java statement.
443.67 +
443.68 +\subsection{Variables}
443.69 +
443.70 +Variables start with the dollar sign (\verb=$=). In the pattern, first occurrences
443.71 +of a variable is bound to the actual sub-tree that appears in the code. Second and
443.72 +following occurrences of the variable the actual sub-tree is verified against the subtree
443.73 +bound to the variable. The pattern occurs in the text only if the actual sub-tree
443.74 +matches the sub-tree bound to the variable. In the fix pattern, all occurrences of
443.75 +the variables are replaced with the tree(s) bound to the respective variables.
443.76 +
443.77 +The forms of the variables are:
443.78 +\begin{description}
443.79 +\item[\simplevariable]{any expression}
443.80 +\item[\statementvariable]{any statement}
443.81 +\item[\multipletreevariable]{any number of sub-trees (except statements - see next definition)}
443.82 +\item[\multiplestatementvariable]{any number of statements}
443.83 +\item[\wholepattern]{for patterns undefined, for fixes and conditions automatically bound to the current matched region}
443.84 +\item[\reserved]{reserved -- do not use}
443.85 +\end{description}
443.86 +
443.87 +\subsection{Conditions}
443.88 +
443.89 +Both the search and fix patterns may specify additional conditions. These conditions
443.90 +are specified after \verb=::=. Currently, the conditions have the following
443.91 +limitations:
443.92 +
443.93 +\begin{verbatim}
443.94 + $1.isDirectory() :: $1 instanceof java.io.File
443.95 +=> !$1.isFile()
443.96 +;;
443.97 +\end{verbatim}
443.98 +
443.99 +will rewrite the following code:
443.100 +\begin{verbatim}
443.101 +java.io.File testFile = new java.io.File("/tmp");
443.102 +if (testFile.isDirectory()) {
443.103 + System.err.println("/tmp is a directory");
443.104 +}
443.105 +\end{verbatim}
443.106 +to:
443.107 +\begin{verbatim}
443.108 +java.io.File testFile = new java.io.File("/tmp");
443.109 +if (!testFile.isFile()) {
443.110 + System.err.println("/tmp is a directory");
443.111 +}
443.112 +\end{verbatim}
443.113 +
443.114 +\subsection{Display Names and Localization}
443.115 +
443.116 +\subsection{Custom Conditions}
443.117 +
443.118 +\subsection{Custom Import}
443.119 +
443.120 +\subsection{Options}
443.121 +
443.122 +\end{document}
444.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
444.2 +++ b/sandbox/old-modules/help/jackpot30-helpset.xml Mon Mar 12 21:10:10 2012 +0100
444.3 @@ -0,0 +1,31 @@
444.4 +<?xml version="1.0" encoding="UTF-8"?>
444.5 +<!--
444.6 +To change this template, choose Tools | Templates
444.7 +and open the template in the editor.
444.8 +-->
444.9 +<!DOCTYPE helpset PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 2.0//EN" "http://java.sun.com/products/javahelp/helpset_2_0.dtd">
444.10 +<helpset version="2.0">
444.11 + <title>Jackpot 3.0 Help</title>
444.12 + <maps>
444.13 + <homeID>jackpot30.about</homeID>
444.14 + <mapref location="jackpot30-map.xml"/>
444.15 + </maps>
444.16 + <view mergetype="javax.help.AppendMerge">
444.17 + <name>TOC</name>
444.18 + <label>Table of Contents</label>
444.19 + <type>javax.help.TOCView</type>
444.20 + <data>jackpot30-toc.xml</data>
444.21 + </view>
444.22 +<!-- <view mergetype="javax.help.AppendMerge">
444.23 + <name>Index</name>
444.24 + <label>Index</label>
444.25 + <type>javax.help.IndexView</type>
444.26 + <data>dsaf-idx.xml</data>
444.27 + </view>-->
444.28 +<!-- <view>
444.29 + <name>Search</name>
444.30 + <label>Search</label>
444.31 + <type>javax.help.SearchView</type>
444.32 + <data engine="com.sun.java.help.search.DefaultSearchEngine">JavaHelpSearch</data>
444.33 + </view>-->
444.34 +</helpset>
445.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
445.2 +++ b/sandbox/old-modules/help/manifest.mf Mon Mar 12 21:10:10 2012 +0100
445.3 @@ -0,0 +1,7 @@
445.4 +Manifest-Version: 1.0
445.5 +OpenIDE-Module: org.netbeans.modules.jackpot30.help
445.6 +OpenIDE-Module-Layer: org/netbeans/modules/jackpot30/help/layer.xml
445.7 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/help/Bundle.properties
445.8 +OpenIDE-Module-Specification-Version: 1.16
445.9 +OpenIDE-Module-Requires: org.netbeans.api.javahelp.Help
445.10 +Class-Path: docs/org-netbeans-modules-jackpot30-help.jar
446.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
446.2 +++ b/sandbox/old-modules/help/nbproject-help.tex/build-settings.properties Mon Mar 12 21:10:10 2012 +0100
446.3 @@ -0,0 +1,3 @@
446.4 +build-configuration-name=latexdvips
446.5 +
446.6 +mainfile=../jackpot30-help.tex
447.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
447.2 +++ b/sandbox/old-modules/help/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
447.3 @@ -0,0 +1,45 @@
447.4 +<?xml version="1.0" encoding="UTF-8"?>
447.5 +<!--
447.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
447.7 +*** EDIT ../build.xml INSTEAD ***
447.8 +-->
447.9 +<project name="org.netbeans.modules.jackpot30.help-impl" basedir="..">
447.10 + <fail message="Please build using Ant 1.7.1 or higher.">
447.11 + <condition>
447.12 + <not>
447.13 + <antversion atleast="1.7.1"/>
447.14 + </not>
447.15 + </condition>
447.16 + </fail>
447.17 + <property file="nbproject/private/suite-private.properties"/>
447.18 + <property file="nbproject/suite.properties"/>
447.19 + <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
447.20 + <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
447.21 + <property file="${suite.dir}/nbproject/platform.properties"/>
447.22 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
447.23 + <attribute name="name"/>
447.24 + <attribute name="value"/>
447.25 + <sequential>
447.26 + <property name="@{name}" value="${@{value}}"/>
447.27 + </sequential>
447.28 + </macrodef>
447.29 + <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
447.30 + <attribute name="property"/>
447.31 + <attribute name="value"/>
447.32 + <sequential>
447.33 + <property name="@{property}" value="@{value}"/>
447.34 + </sequential>
447.35 + </macrodef>
447.36 + <property file="${user.properties.file}"/>
447.37 + <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
447.38 + <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
447.39 + <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
447.40 + <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
447.41 + <condition>
447.42 + <not>
447.43 + <contains string="${cluster.path.evaluated}" substring="platform"/>
447.44 + </not>
447.45 + </condition>
447.46 + </fail>
447.47 + <import file="${harness.dir}/build.xml"/>
447.48 +</project>
448.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
448.2 +++ b/sandbox/old-modules/help/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
448.3 @@ -0,0 +1,8 @@
448.4 +build.xml.data.CRC32=ffaf56d3
448.5 +build.xml.script.CRC32=12cad5e6
448.6 +build.xml.stylesheet.CRC32=79c3b980@1.29.0.7
448.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
448.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
448.9 +nbproject/build-impl.xml.data.CRC32=ffaf56d3
448.10 +nbproject/build-impl.xml.script.CRC32=68ad079b
448.11 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.43
449.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
449.2 +++ b/sandbox/old-modules/help/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
449.3 @@ -0,0 +1,2 @@
449.4 +javac.source=1.5
449.5 +javac.compilerargs=-Xlint -Xlint:-serial
450.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
450.2 +++ b/sandbox/old-modules/help/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
450.3 @@ -0,0 +1,12 @@
450.4 +<?xml version="1.0" encoding="UTF-8"?>
450.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
450.6 + <type>org.netbeans.modules.apisupport.project</type>
450.7 + <configuration>
450.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
450.9 + <code-name-base>org.netbeans.modules.jackpot30.help</code-name-base>
450.10 + <suite-component/>
450.11 + <module-dependencies/>
450.12 + <public-packages/>
450.13 + </data>
450.14 + </configuration>
450.15 +</project>
451.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
451.2 +++ b/sandbox/old-modules/help/nbproject/suite.properties Mon Mar 12 21:10:10 2012 +0100
451.3 @@ -0,0 +1,1 @@
451.4 +suite.dir=${basedir}/..
452.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
452.2 +++ b/sandbox/old-modules/help/src/org/netbeans/modules/jackpot30/help/Bundle.properties Mon Mar 12 21:10:10 2012 +0100
452.3 @@ -0,0 +1,38 @@
452.4 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
452.5 +#
452.6 +# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
452.7 +#
452.8 +# The contents of this file are subject to the terms of either the GNU
452.9 +# General Public License Version 2 only ("GPL") or the Common
452.10 +# Development and Distribution License("CDDL") (collectively, the
452.11 +# "License"). You may not use this file except in compliance with the
452.12 +# License. You can obtain a copy of the License at
452.13 +# http://www.netbeans.org/cddl-gplv2.html
452.14 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
452.15 +# specific language governing permissions and limitations under the
452.16 +# License. When distributing the software, include this License Header
452.17 +# Notice in each file and include the License file at
452.18 +# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
452.19 +# particular file as subject to the "Classpath" exception as provided
452.20 +# by Sun in the GPL Version 2 section of the License file that
452.21 +# accompanied this code. If applicable, add the following below the
452.22 +# License Header, with the fields enclosed by brackets [] replaced by
452.23 +# your own identifying information:
452.24 +# "Portions Copyrighted [year] [name of copyright owner]"
452.25 +#
452.26 +# If you wish your version of this file to be governed by only the CDDL
452.27 +# or only the GPL Version 2, indicate your decision by adding
452.28 +# "[Contributor] elects to include this software in this distribution
452.29 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
452.30 +# single choice of license, a recipient has the option to distribute
452.31 +# your version of this file under either the CDDL, the GPL Version 2 or
452.32 +# to extend the choice of license to its licensees as provided above.
452.33 +# However, if you add GPL Version 2 code and therefore, elected the GPL
452.34 +# Version 2 license, then the option applies only if the new code is
452.35 +# made subject to such option by the copyright holder.
452.36 +#
452.37 +# Contributor(s):
452.38 +#
452.39 +# Portions Copyrighted 2009 Sun Microsystems, Inc.
452.40 +
452.41 +OpenIDE-Module-Name=Jackpot 3.0 Help
453.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
453.2 +++ b/sandbox/old-modules/help/src/org/netbeans/modules/jackpot30/help/CreateMap.java Mon Mar 12 21:10:10 2012 +0100
453.3 @@ -0,0 +1,196 @@
453.4 +/*
453.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
453.6 + *
453.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
453.8 + *
453.9 + * The contents of this file are subject to the terms of either the GNU
453.10 + * General Public License Version 2 only ("GPL") or the Common
453.11 + * Development and Distribution License("CDDL") (collectively, the
453.12 + * "License"). You may not use this file except in compliance with the
453.13 + * License. You can obtain a copy of the License at
453.14 + * http://www.netbeans.org/cddl-gplv2.html
453.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
453.16 + * specific language governing permissions and limitations under the
453.17 + * License. When distributing the software, include this License Header
453.18 + * Notice in each file and include the License file at
453.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
453.20 + * particular file as subject to the "Classpath" exception as provided
453.21 + * by Sun in the GPL Version 2 section of the License file that
453.22 + * accompanied this code. If applicable, add the following below the
453.23 + * License Header, with the fields enclosed by brackets [] replaced by
453.24 + * your own identifying information:
453.25 + * "Portions Copyrighted [year] [name of copyright owner]"
453.26 + *
453.27 + * Contributor(s):
453.28 + *
453.29 + * The Original Software is the LaTeX module.
453.30 + * The Initial Developer of the Original Software is Jan Lahoda.
453.31 + * Portions created by Jan Lahoda_ are Copyright (C) 2002-2009.
453.32 + * All Rights Reserved.
453.33 + *
453.34 + * If you wish your version of this file to be governed by only the CDDL
453.35 + * or only the GPL Version 2, indicate your decision by adding
453.36 + * "[Contributor] elects to include this software in this distribution
453.37 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
453.38 + * single choice of license, a recipient has the option to distribute
453.39 + * your version of this file under either the CDDL, the GPL Version 2 or
453.40 + * to extend the choice of license to its licensees as provided above.
453.41 + * However, if you add GPL Version 2 code and therefore, elected the GPL
453.42 + * Version 2 license, then the option applies only if the new code is
453.43 + * made subject to such option by the copyright holder.
453.44 + *
453.45 + * Contributor(s): Jan Lahoda.
453.46 + */
453.47 +package org.netbeans.modules.jackpot30.help;
453.48 +
453.49 +import java.io.BufferedReader;
453.50 +import java.io.File;
453.51 +import java.io.FileReader;
453.52 +import java.io.FileWriter;
453.53 +import java.io.IOException;
453.54 +import java.io.PrintWriter;
453.55 +import java.util.HashMap;
453.56 +import java.util.Map;
453.57 +
453.58 +/**
453.59 + *
453.60 + * @author Jan Lahoda
453.61 + */
453.62 +public class CreateMap {
453.63 +
453.64 + public CreateMap() {}
453.65 +
453.66 + /**
453.67 + * @param args the command line arguments
453.68 + */
453.69 + public static void main(String[] args) throws IOException {
453.70 + if (args.length != 1) {
453.71 + System.err.println("Incorrect number of arguments, one argument containing the location of the base dir is required.");
453.72 + return ;
453.73 + }
453.74 +
453.75 + File baseDir = new File(args[0]);
453.76 +
453.77 + if (!baseDir.exists()) {
453.78 + System.err.println(baseDir.getAbsolutePath() + " does not exist.");
453.79 + return ;
453.80 + }
453.81 +
453.82 + if (!baseDir.isDirectory()) {
453.83 + System.err.println(baseDir.getAbsolutePath() + " is not a directory.");
453.84 + return ;
453.85 + }
453.86 +
453.87 + File in = new File(baseDir, "labels.pl");
453.88 + File out = new File(baseDir, "jackpot30-map.xml");
453.89 +
453.90 + Map<String, String> map = createMapFile(in, out);
453.91 +
453.92 + File outTOC = new File(baseDir, "jackpot30-toc.xml");
453.93 + File inTOC = new File(baseDir, "jackpot30-help.html");
453.94 +
453.95 + createTOC(inTOC, outTOC, map);
453.96 + }
453.97 +
453.98 + private static Map<String, String> createMapFile(File in, File out) throws IOException {
453.99 + BufferedReader input = new BufferedReader(new FileReader(in));
453.100 + PrintWriter output = new PrintWriter(new FileWriter(out));
453.101 + Map<String, String> map = new HashMap<String, String>();
453.102 +
453.103 + output.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
453.104 + output.println();
453.105 + output.println("<!DOCTYPE map");
453.106 + output.println(" PUBLIC \"-//Sun Microsystems Inc.//DTD JavaHelp Map Version 1.0//EN\"");
453.107 + output.println(" \"file:///home/lahvac/netbeans/netbeans/bin/nbuser/sampledir/javahelp/map_1_0.dtd\">");
453.108 + output.println("<!--This is the original DTD: \"http://java.sun.com/products/javahelp/map_1_0.dtd\"-->");
453.109 + output.println();
453.110 + output.println("<map version=\"1.0\">");
453.111 +
453.112 + output.println("<mapID target=\"jackpot30.default\" url=\"jackpot30-help.html\" />");
453.113 +
453.114 + String line = null;
453.115 + String actualKey = null;
453.116 +
453.117 + while ((line = input.readLine()) != null) {
453.118 + if (line.startsWith("$key")) {
453.119 + actualKey = line.split("/")[1];
453.120 + actualKey = "jackpot30." + actualKey.replace(':', '.');
453.121 + }
453.122 +
453.123 + if (line.startsWith("$external_labels")) {
453.124 + String url = line.split("\\|")[1];
453.125 +
453.126 + output.print("<mapID target=\"");
453.127 + output.print(actualKey);
453.128 + output.print("\" url=\"");
453.129 + output.print(url);
453.130 + output.println("\"/>");
453.131 +
453.132 + map.put(url, actualKey);
453.133 +
453.134 + actualKey = null;
453.135 + }
453.136 + }
453.137 +
453.138 + output.println("</map>");
453.139 + output.close();
453.140 + input.close();
453.141 +
453.142 + return map;
453.143 + }
453.144 +
453.145 + private static void createTOC(File in, File out, Map<String, String> map) throws IOException {
453.146 + BufferedReader input = new BufferedReader(new FileReader(in));
453.147 + PrintWriter output = new PrintWriter(new FileWriter(out));
453.148 +
453.149 + String line = null;
453.150 + boolean noStop = false;
453.151 +
453.152 + output.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
453.153 + output.println();
453.154 + output.println("<!DOCTYPE toc");
453.155 + output.println(" PUBLIC \"-//Sun Microsystems Inc.//DTD JavaHelp TOC Version 1.0//EN\"");
453.156 + output.println(" \"file:///home/lahvac/netbeans/netbeans/bin/nbuser/sampledir/javahelp/toc_1_0.dtd\">");
453.157 + output.println("<!--This is the original DTD: \"http://java.sun.com/products/javahelp/toc_1_0.dtd\"-->");
453.158 + output.println();
453.159 + output.println("<toc version=\"1.0\">");
453.160 +
453.161 + while ((line = input.readLine()) != null && line.indexOf("<!--Table of Child-Links-->") == (-1))
453.162 + ;
453.163 +
453.164 + output.println("<tocitem text=\"Jackpot 3.0 Support Help\" target=\"jackpot30.default\">");
453.165 + while ((line = input.readLine()) != null && line.indexOf("<!--End of Table of Child-Links-->") == (-1)) {
453.166 + if (line.startsWith("<UL ")) {
453.167 + noStop = true;
453.168 + continue;
453.169 + }
453.170 +
453.171 + if (line.indexOf("HREF=\"") != (-1)) {
453.172 + if (noStop) {
453.173 + noStop = false;
453.174 + } else {
453.175 + output.println("</tocitem>");
453.176 + }
453.177 +
453.178 + String file = line.split("\"")[1];
453.179 + String name = line.split(">")[1].split("<")[0];
453.180 +
453.181 + output.println("<tocitem text=\"" + name + "\" target=\"" + (map.get(file) != null ? map.get(file) : "test") + "\">");
453.182 +
453.183 + continue;
453.184 + }
453.185 +
453.186 + if (line.startsWith("</UL>") && !noStop) {
453.187 + output.println("</tocitem>");
453.188 + continue;
453.189 + }
453.190 + }
453.191 +
453.192 + output.println("</tocitem>");
453.193 +
453.194 + output.println("</toc>");
453.195 +
453.196 + output.close();
453.197 + input.close();
453.198 + }
453.199 +}
454.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
454.2 +++ b/sandbox/old-modules/help/src/org/netbeans/modules/jackpot30/help/jackpot30-helpset.xml Mon Mar 12 21:10:10 2012 +0100
454.3 @@ -0,0 +1,3 @@
454.4 +<?xml version="1.0" encoding="UTF-8"?>
454.5 +<!DOCTYPE helpsetref PUBLIC "-//NetBeans//DTD JavaHelp Help Set Reference 1.0//EN" "http://www.netbeans.org/dtds/helpsetref-1_0.dtd">
454.6 +<helpsetref url="nbdocs:/org/netbeans/modules/jackpot30/help/docs/jackpot30-helpset.xml" />
455.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
455.2 +++ b/sandbox/old-modules/help/src/org/netbeans/modules/jackpot30/help/layer.xml Mon Mar 12 21:10:10 2012 +0100
455.3 @@ -0,0 +1,11 @@
455.4 +<?xml version="1.0" encoding="UTF-8"?>
455.5 +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
455.6 +<filesystem>
455.7 + <folder name="Services">
455.8 + <folder name="JavaHelp">
455.9 + <file name="jackpot30-helpset.xml" url="jackpot30-helpset.xml">
455.10 + <attr name="position" intvalue="3456"/>
455.11 + </file>
455.12 + </folder>
455.13 + </folder>
455.14 +</filesystem>
456.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
456.2 +++ b/sandbox/old-modules/hintsimpl/build.xml Mon Mar 12 21:10:10 2012 +0100
456.3 @@ -0,0 +1,11 @@
456.4 +<?xml version="1.0" encoding="UTF-8"?>
456.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
456.6 +<!-- for some information on what you could do (e.g. targets to override). -->
456.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
456.8 +<project name="org.netbeans.modules.jackpot30.hintsimpl" default="netbeans" basedir=".">
456.9 + <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.hintsimpl.</description>
456.10 + <import file="nbproject/build-impl.xml"/>
456.11 + <import file="${suite.dir}/findbugs-import.xml"/>
456.12 + <target name="test-coverage" />
456.13 + <target name="coverage-report" />
456.14 +</project>
457.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
457.2 +++ b/sandbox/old-modules/hintsimpl/manifest.mf Mon Mar 12 21:10:10 2012 +0100
457.3 @@ -0,0 +1,7 @@
457.4 +Manifest-Version: 1.0
457.5 +AutoUpdate-Show-In-Client: false
457.6 +OpenIDE-Module: org.netbeans.modules.jackpot30.hintsimpl
457.7 +OpenIDE-Module-Implementation-Version: 1
457.8 +OpenIDE-Module-Layer: org/netbeans/modules/jackpot30/hintsimpl/layer.xml
457.9 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/hintsimpl/Bundle.properties
457.10 +
458.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
458.2 +++ b/sandbox/old-modules/hintsimpl/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
458.3 @@ -0,0 +1,45 @@
458.4 +<?xml version="1.0" encoding="UTF-8"?>
458.5 +<!--
458.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
458.7 +*** EDIT ../build.xml INSTEAD ***
458.8 +-->
458.9 +<project name="org.netbeans.modules.jackpot30.hintsimpl-impl" basedir="..">
458.10 + <fail message="Please build using Ant 1.7.1 or higher.">
458.11 + <condition>
458.12 + <not>
458.13 + <antversion atleast="1.7.1"/>
458.14 + </not>
458.15 + </condition>
458.16 + </fail>
458.17 + <property file="nbproject/private/suite-private.properties"/>
458.18 + <property file="nbproject/suite.properties"/>
458.19 + <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
458.20 + <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
458.21 + <property file="${suite.dir}/nbproject/platform.properties"/>
458.22 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
458.23 + <attribute name="name"/>
458.24 + <attribute name="value"/>
458.25 + <sequential>
458.26 + <property name="@{name}" value="${@{value}}"/>
458.27 + </sequential>
458.28 + </macrodef>
458.29 + <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
458.30 + <attribute name="property"/>
458.31 + <attribute name="value"/>
458.32 + <sequential>
458.33 + <property name="@{property}" value="@{value}"/>
458.34 + </sequential>
458.35 + </macrodef>
458.36 + <property file="${user.properties.file}"/>
458.37 + <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
458.38 + <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
458.39 + <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
458.40 + <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
458.41 + <condition>
458.42 + <not>
458.43 + <contains string="${cluster.path.evaluated}" substring="platform"/>
458.44 + </not>
458.45 + </condition>
458.46 + </fail>
458.47 + <import file="${harness.dir}/build.xml"/>
458.48 +</project>
459.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
459.2 +++ b/sandbox/old-modules/hintsimpl/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
459.3 @@ -0,0 +1,8 @@
459.4 +build.xml.data.CRC32=772824b9
459.5 +build.xml.script.CRC32=ef577a91
459.6 +build.xml.stylesheet.CRC32=79c3b980@1.28.0.7
459.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
459.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
459.9 +nbproject/build-impl.xml.data.CRC32=2dfd5d11
459.10 +nbproject/build-impl.xml.script.CRC32=9204f652
459.11 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.47
460.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
460.2 +++ b/sandbox/old-modules/hintsimpl/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
460.3 @@ -0,0 +1,4 @@
460.4 +javac.source=1.5
460.5 +javac.compilerargs=-Xlint -Xlint:-serial
460.6 +project.license=cddl-netbeans-sun
460.7 +spec.version.base=1.16.0
461.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
461.2 +++ b/sandbox/old-modules/hintsimpl/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
461.3 @@ -0,0 +1,276 @@
461.4 +<?xml version="1.0" encoding="UTF-8"?>
461.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
461.6 + <type>org.netbeans.modules.apisupport.project</type>
461.7 + <configuration>
461.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
461.9 + <code-name-base>org.netbeans.modules.jackpot30.hintsimpl</code-name-base>
461.10 + <suite-component/>
461.11 + <module-dependencies>
461.12 + <dependency>
461.13 + <code-name-base>org.jdesktop.layout</code-name-base>
461.14 + <build-prerequisite/>
461.15 + <compile-dependency/>
461.16 + <run-dependency>
461.17 + <release-version>1</release-version>
461.18 + <specification-version>1.7.0.103</specification-version>
461.19 + </run-dependency>
461.20 + </dependency>
461.21 + <dependency>
461.22 + <code-name-base>org.netbeans.api.java.classpath</code-name-base>
461.23 + <build-prerequisite/>
461.24 + <compile-dependency/>
461.25 + <run-dependency>
461.26 + <release-version>1</release-version>
461.27 + <specification-version>1.19</specification-version>
461.28 + </run-dependency>
461.29 + </dependency>
461.30 + <dependency>
461.31 + <code-name-base>org.netbeans.api.progress</code-name-base>
461.32 + <build-prerequisite/>
461.33 + <compile-dependency/>
461.34 + <run-dependency>
461.35 + <release-version>1</release-version>
461.36 + <specification-version>1.13.0.1</specification-version>
461.37 + </run-dependency>
461.38 + </dependency>
461.39 + <dependency>
461.40 + <code-name-base>org.netbeans.libs.javacapi</code-name-base>
461.41 + <build-prerequisite/>
461.42 + <compile-dependency/>
461.43 + <run-dependency>
461.44 + <specification-version>0.8.0.1</specification-version>
461.45 + </run-dependency>
461.46 + </dependency>
461.47 + <dependency>
461.48 + <code-name-base>org.netbeans.modules.editor</code-name-base>
461.49 + <build-prerequisite/>
461.50 + <compile-dependency/>
461.51 + <run-dependency>
461.52 + <release-version>3</release-version>
461.53 + <specification-version>1.42.0.3.9.2</specification-version>
461.54 + </run-dependency>
461.55 + </dependency>
461.56 + <dependency>
461.57 + <code-name-base>org.netbeans.modules.editor.guards</code-name-base>
461.58 + <build-prerequisite/>
461.59 + <compile-dependency/>
461.60 + <run-dependency>
461.61 + <release-version>1</release-version>
461.62 + <specification-version>1.3</specification-version>
461.63 + </run-dependency>
461.64 + </dependency>
461.65 + <dependency>
461.66 + <code-name-base>org.netbeans.modules.editor.lib</code-name-base>
461.67 + <build-prerequisite/>
461.68 + <compile-dependency/>
461.69 + <run-dependency>
461.70 + <release-version>1-3</release-version>
461.71 + <specification-version>1.38.0.9.2</specification-version>
461.72 + </run-dependency>
461.73 + </dependency>
461.74 + <dependency>
461.75 + <code-name-base>org.netbeans.modules.jackpot30.api</code-name-base>
461.76 + <build-prerequisite/>
461.77 + <compile-dependency/>
461.78 + <run-dependency>
461.79 + <specification-version>1.0</specification-version>
461.80 + </run-dependency>
461.81 + </dependency>
461.82 + <dependency>
461.83 + <code-name-base>org.netbeans.modules.java.editor</code-name-base>
461.84 + <run-dependency>
461.85 + <release-version>1</release-version>
461.86 + <specification-version>2.22</specification-version>
461.87 + </run-dependency>
461.88 + </dependency>
461.89 + <dependency>
461.90 + <code-name-base>org.netbeans.modules.java.hints</code-name-base>
461.91 + <build-prerequisite/>
461.92 + <compile-dependency/>
461.93 + <run-dependency>
461.94 + <release-version>1</release-version>
461.95 + <implementation-version/>
461.96 + </run-dependency>
461.97 + </dependency>
461.98 + <dependency>
461.99 + <code-name-base>org.netbeans.modules.java.lexer</code-name-base>
461.100 + <build-prerequisite/>
461.101 + <compile-dependency/>
461.102 + <run-dependency>
461.103 + <release-version>1</release-version>
461.104 + <specification-version>1.5</specification-version>
461.105 + </run-dependency>
461.106 + </dependency>
461.107 + <dependency>
461.108 + <code-name-base>org.netbeans.modules.java.source</code-name-base>
461.109 + <build-prerequisite/>
461.110 + <compile-dependency/>
461.111 + <run-dependency>
461.112 + <specification-version>0.53</specification-version>
461.113 + </run-dependency>
461.114 + </dependency>
461.115 + <dependency>
461.116 + <code-name-base>org.netbeans.modules.lexer</code-name-base>
461.117 + <build-prerequisite/>
461.118 + <compile-dependency/>
461.119 + <run-dependency>
461.120 + <release-version>2</release-version>
461.121 + <specification-version>1.30.0.1</specification-version>
461.122 + </run-dependency>
461.123 + </dependency>
461.124 + <dependency>
461.125 + <code-name-base>org.netbeans.modules.options.api</code-name-base>
461.126 + <build-prerequisite/>
461.127 + <compile-dependency/>
461.128 + <run-dependency>
461.129 + <release-version>1</release-version>
461.130 + <specification-version>1.12</specification-version>
461.131 + </run-dependency>
461.132 + </dependency>
461.133 + <dependency>
461.134 + <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
461.135 + <build-prerequisite/>
461.136 + <compile-dependency/>
461.137 + <run-dependency>
461.138 + <release-version>1</release-version>
461.139 + <specification-version>1.12.1</specification-version>
461.140 + </run-dependency>
461.141 + </dependency>
461.142 + <dependency>
461.143 + <code-name-base>org.netbeans.modules.projectapi</code-name-base>
461.144 + <build-prerequisite/>
461.145 + <compile-dependency/>
461.146 + <run-dependency>
461.147 + <release-version>1</release-version>
461.148 + <specification-version>1.24</specification-version>
461.149 + </run-dependency>
461.150 + </dependency>
461.151 + <dependency>
461.152 + <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
461.153 + <build-prerequisite/>
461.154 + <compile-dependency/>
461.155 + <run-dependency>
461.156 + <release-version>1</release-version>
461.157 + <specification-version>1.34.0.6</specification-version>
461.158 + </run-dependency>
461.159 + </dependency>
461.160 + <dependency>
461.161 + <code-name-base>org.netbeans.modules.sendopts</code-name-base>
461.162 + <build-prerequisite/>
461.163 + <compile-dependency/>
461.164 + <run-dependency>
461.165 + <release-version>2</release-version>
461.166 + <specification-version>2.4</specification-version>
461.167 + </run-dependency>
461.168 + </dependency>
461.169 + <dependency>
461.170 + <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
461.171 + <build-prerequisite/>
461.172 + <compile-dependency/>
461.173 + <run-dependency>
461.174 + <release-version>0-1</release-version>
461.175 + <specification-version>1.7.0.7.2</specification-version>
461.176 + </run-dependency>
461.177 + </dependency>
461.178 + <dependency>
461.179 + <code-name-base>org.netbeans.spi.tasklist</code-name-base>
461.180 + <build-prerequisite/>
461.181 + <compile-dependency/>
461.182 + <run-dependency>
461.183 + <release-version>1</release-version>
461.184 + <specification-version>1.4.0.1</specification-version>
461.185 + </run-dependency>
461.186 + </dependency>
461.187 + <dependency>
461.188 + <code-name-base>org.openide.awt</code-name-base>
461.189 + <build-prerequisite/>
461.190 + <compile-dependency/>
461.191 + <run-dependency>
461.192 + <specification-version>7.7.0.1</specification-version>
461.193 + </run-dependency>
461.194 + </dependency>
461.195 + <dependency>
461.196 + <code-name-base>org.openide.dialogs</code-name-base>
461.197 + <build-prerequisite/>
461.198 + <compile-dependency/>
461.199 + <run-dependency>
461.200 + <specification-version>7.10</specification-version>
461.201 + </run-dependency>
461.202 + </dependency>
461.203 + <dependency>
461.204 + <code-name-base>org.openide.filesystems</code-name-base>
461.205 + <build-prerequisite/>
461.206 + <compile-dependency/>
461.207 + <run-dependency>
461.208 + <specification-version>7.21.0.1.1</specification-version>
461.209 + </run-dependency>
461.210 + </dependency>
461.211 + <dependency>
461.212 + <code-name-base>org.openide.loaders</code-name-base>
461.213 + <build-prerequisite/>
461.214 + <compile-dependency/>
461.215 + <run-dependency>
461.216 + <specification-version>7.5</specification-version>
461.217 + </run-dependency>
461.218 + </dependency>
461.219 + <dependency>
461.220 + <code-name-base>org.openide.nodes</code-name-base>
461.221 + <build-prerequisite/>
461.222 + <compile-dependency/>
461.223 + <run-dependency>
461.224 + <specification-version>7.9.0.1</specification-version>
461.225 + </run-dependency>
461.226 + </dependency>
461.227 + <dependency>
461.228 + <code-name-base>org.openide.text</code-name-base>
461.229 + <build-prerequisite/>
461.230 + <compile-dependency/>
461.231 + <run-dependency>
461.232 + <specification-version>6.22</specification-version>
461.233 + </run-dependency>
461.234 + </dependency>
461.235 + <dependency>
461.236 + <code-name-base>org.openide.util</code-name-base>
461.237 + <build-prerequisite/>
461.238 + <compile-dependency/>
461.239 + <run-dependency>
461.240 + <specification-version>7.22.0.1</specification-version>
461.241 + </run-dependency>
461.242 + </dependency>
461.243 + <dependency>
461.244 + <code-name-base>org.openide.windows</code-name-base>
461.245 + <build-prerequisite/>
461.246 + <compile-dependency/>
461.247 + <run-dependency>
461.248 + <specification-version>6.26</specification-version>
461.249 + </run-dependency>
461.250 + </dependency>
461.251 + </module-dependencies>
461.252 + <test-dependencies>
461.253 + <test-type>
461.254 + <name>unit</name>
461.255 + <test-dependency>
461.256 + <code-name-base>org.netbeans.libs.junit4</code-name-base>
461.257 + <compile-dependency/>
461.258 + </test-dependency>
461.259 + <test-dependency>
461.260 + <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
461.261 + <recursive/>
461.262 + <compile-dependency/>
461.263 + </test-dependency>
461.264 + <test-dependency>
461.265 + <code-name-base>org.netbeans.modules.java.hints.declarative.test</code-name-base>
461.266 + <recursive/>
461.267 + <compile-dependency/>
461.268 + </test-dependency>
461.269 + <test-dependency>
461.270 + <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
461.271 + <recursive/>
461.272 + <compile-dependency/>
461.273 + </test-dependency>
461.274 + </test-type>
461.275 + </test-dependencies>
461.276 + <public-packages/>
461.277 + </data>
461.278 + </configuration>
461.279 +</project>
462.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
462.2 +++ b/sandbox/old-modules/hintsimpl/nbproject/suite.properties Mon Mar 12 21:10:10 2012 +0100
462.3 @@ -0,0 +1,1 @@
462.4 +suite.dir=${basedir}/..
463.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
463.2 +++ b/sandbox/old-modules/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/Bundle.properties Mon Mar 12 21:10:10 2012 +0100
463.3 @@ -0,0 +1,38 @@
463.4 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
463.5 +#
463.6 +# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
463.7 +#
463.8 +# The contents of this file are subject to the terms of either the GNU
463.9 +# General Public License Version 2 only ("GPL") or the Common
463.10 +# Development and Distribution License("CDDL") (collectively, the
463.11 +# "License"). You may not use this file except in compliance with the
463.12 +# License. You can obtain a copy of the License at
463.13 +# http://www.netbeans.org/cddl-gplv2.html
463.14 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
463.15 +# specific language governing permissions and limitations under the
463.16 +# License. When distributing the software, include this License Header
463.17 +# Notice in each file and include the License file at
463.18 +# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
463.19 +# particular file as subject to the "Classpath" exception as provided
463.20 +# by Sun in the GPL Version 2 section of the License file that
463.21 +# accompanied this code. If applicable, add the following below the
463.22 +# License Header, with the fields enclosed by brackets [] replaced by
463.23 +# your own identifying information:
463.24 +# "Portions Copyrighted [year] [name of copyright owner]"
463.25 +#
463.26 +# If you wish your version of this file to be governed by only the CDDL
463.27 +# or only the GPL Version 2, indicate your decision by adding
463.28 +# "[Contributor] elects to include this software in this distribution
463.29 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
463.30 +# single choice of license, a recipient has the option to distribute
463.31 +# your version of this file under either the CDDL, the GPL Version 2 or
463.32 +# to extend the choice of license to its licensees as provided above.
463.33 +# However, if you add GPL Version 2 code and therefore, elected the GPL
463.34 +# Version 2 license, then the option applies only if the new code is
463.35 +# made subject to such option by the copyright holder.
463.36 +#
463.37 +# Contributor(s):
463.38 +#
463.39 +# Portions Copyrighted 2009 Sun Microsystems, Inc.
463.40 +
463.41 +OpenIDE-Module-Name=Hints Impl
464.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
464.2 +++ b/sandbox/old-modules/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/abstract-document.hint Mon Mar 12 21:10:10 2012 +0100
464.3 @@ -0,0 +1,37 @@
464.4 +{ $1$;
464.5 +$0.readLock();
464.6 +$stmts$;
464.7 +$0.readUnlock();
464.8 +$2$;
464.9 +}
464.10 +:: $0 instanceof javax.swing.text.AbstractDocument
464.11 +=>
464.12 +{ $1$;
464.13 +$0.readLock();
464.14 +try {
464.15 + $stmts$;
464.16 +} finally {
464.17 + $0.readUnlock();
464.18 +}
464.19 +$2$;
464.20 +}
464.21 +;;
464.22 +
464.23 +{ $1$;
464.24 +$0.writeLock();
464.25 +$stmts$;
464.26 +$0.writeUnlock();
464.27 +$2$;
464.28 +}
464.29 +:: $0 instanceof javax.swing.text.AbstractDocument
464.30 +=>
464.31 +{ $1$;
464.32 +$0.writeLock();
464.33 +try {
464.34 + $stmts$;
464.35 +} finally {
464.36 + $0.writeUnlock();
464.37 +}
464.38 +$2$;
464.39 +}
464.40 +;;
465.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
465.2 +++ b/sandbox/old-modules/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/assert2if.hint Mon Mar 12 21:10:10 2012 +0100
465.3 @@ -0,0 +1,4 @@
465.4 +'Use of assert':
465.5 +assert $1 : $2; :: $1 instanceof boolean && $2 instanceof java.lang.Object
465.6 + => if (!$1) throw new IllegalStateException($2);
465.7 + ;;
466.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
466.2 +++ b/sandbox/old-modules/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/double-checked-locking.hint Mon Mar 12 21:10:10 2012 +0100
466.3 @@ -0,0 +1,14 @@
466.4 +'Double checked locking':
466.5 +if ($var == null) {
466.6 + synchronized ($lock) {
466.7 + if ($var == null) {
466.8 + $s2$;
466.9 + }
466.10 + }
466.11 +} :: !hasModifier($var, Modifier.VOLATILE)
466.12 +=>
466.13 +synchronized ($lock) {
466.14 + if ($var == null) {
466.15 + $s2$;
466.16 + }
466.17 +};;
467.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
467.2 +++ b/sandbox/old-modules/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/jackpot/AddConditionals.hint Mon Mar 12 21:10:10 2012 +0100
467.3 @@ -0,0 +1,7 @@
467.4 +if ($a) return $b; else return $c; => return $a ? $b : $c; ;;
467.5 +if ($a) $ret = $b; else $ret = $c; => $ret = $a ? $b : $c; ;;
467.6 +if ($a) $b=$c; else if ($a2) $b = $d; => $b = $a ? $c : $a2 ? $d : $b; ;;
467.7 +$a ? ($T)$b : ($T)$c => ($T)($a ? $b : $c) ;;
467.8 +//the following hint causes BulkSearch to be extremelly slow:
467.9 +//{ $p$; $T $v; if($a) $v = $b; else $v = $c; $q$; } => { $p$; $T $v = $a ? $b : $c; $q$; } ;;
467.10 +
468.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
468.2 +++ b/sandbox/old-modules/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/jackpot/EnhancedFor.hint Mon Mar 12 21:10:10 2012 +0100
468.3 @@ -0,0 +1,43 @@
468.4 +'Convert to Enhanced For':
468.5 +for(int $i = 0; $i < $array.length; $i++) {
468.6 + $T $var = ($T) $array[$i];
468.7 + $stmts$;
468.8 +} :: !referencedIn($i, $stmts$) && sourceVersionGE(SourceVersion.RELEASE_5)
468.9 +=>
468.10 +for($T $var : $array) {
468.11 + $stmts$;
468.12 +}
468.13 +;;
468.14 +
468.15 +'Convert to Enhanced For':
468.16 +for(int $i = 0; $i < $array.length; $i++) {
468.17 + $T $var = $array[$i];
468.18 + $stmts$;
468.19 +} :: !referencedIn($i, $stmts$) && sourceVersionGE(SourceVersion.RELEASE_5)
468.20 +=>
468.21 +for($T $var : $array) {
468.22 + $stmts$;
468.23 +}
468.24 +;;
468.25 +
468.26 +'Convert to Enhanced For':
468.27 +for($I $i = $iterable.iterator(); $i.hasNext();) {
468.28 + $T $var = ($T)$i.next();
468.29 + $stmts$;
468.30 +} :: $iterable instanceof java.lang.Iterable && !referencedIn($i, $stmts$) && sourceVersionGE(SourceVersion.RELEASE_5)
468.31 +=>
468.32 +for($T $var : $iterable) {
468.33 + $stmts$;
468.34 +}
468.35 +;;
468.36 +
468.37 +'Convert to Enhanced For':
468.38 +for($I $i = $iterable.iterator(); $i.hasNext();) {
468.39 + $T $var = $i.next();
468.40 + $stmts$;
468.41 +} :: $iterable instanceof java.lang.Iterable && !referencedIn($i, $stmts$) && sourceVersionGE(SourceVersion.RELEASE_5)
468.42 +=>
468.43 +for($T $var : $iterable) {
468.44 + $stmts$;
468.45 +}
468.46 +;;
469.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
469.2 +++ b/sandbox/old-modules/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/jdk7/Bundle.properties Mon Mar 12 21:10:10 2012 +0100
469.3 @@ -0,0 +1,7 @@
469.4 +DN_org.netbeans.modules.jackpot30.hintsimpl.jdk7.ConvertToDiamondBulkHint=Convert to diamond bulk hint
469.5 +DESC_org.netbeans.modules.jackpot30.hintsimpl.jdk7.ConvertToDiamondBulkHint=Convert to diamond bulk hint
469.6 +DN_jdk7_upgrade=To JDK7
469.7 +DN_java.util.Objects=Convert to use java.util.Objects.{equals,hashCode}
469.8 +DESC_java.util.Objects=Convert to use java.util.Objects.{equals,hashCode}
469.9 +DN_org.netbeans.modules.jackpot30.hintsimpl.jdk7.SafeConvertToSwitchString=Convert to switch over Strings ignoring the eq operator
469.10 +DESC_org.netbeans.modules.jackpot30.hintsimpl.jdk7.SafeConvertToSwitchString=Convert to switch over Strings, ignoring the == operator
470.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
470.2 +++ b/sandbox/old-modules/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/jdk7/SafeConvertToSwitchString.java Mon Mar 12 21:10:10 2012 +0100
470.3 @@ -0,0 +1,80 @@
470.4 +/*
470.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
470.6 + *
470.7 + * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
470.8 + *
470.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
470.10 + * Other names may be trademarks of their respective owners.
470.11 + *
470.12 + * The contents of this file are subject to the terms of either the GNU
470.13 + * General Public License Version 2 only ("GPL") or the Common
470.14 + * Development and Distribution License("CDDL") (collectively, the
470.15 + * "License"). You may not use this file except in compliance with the
470.16 + * License. You can obtain a copy of the License at
470.17 + * http://www.netbeans.org/cddl-gplv2.html
470.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
470.19 + * specific language governing permissions and limitations under the
470.20 + * License. When distributing the software, include this License Header
470.21 + * Notice in each file and include the License file at
470.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
470.23 + * particular file as subject to the "Classpath" exception as provided
470.24 + * by Oracle in the GPL Version 2 section of the License file that
470.25 + * accompanied this code. If applicable, add the following below the
470.26 + * License Header, with the fields enclosed by brackets [] replaced by
470.27 + * your own identifying information:
470.28 + * "Portions Copyrighted [year] [name of copyright owner]"
470.29 + *
470.30 + * If you wish your version of this file to be governed by only the CDDL
470.31 + * or only the GPL Version 2, indicate your decision by adding
470.32 + * "[Contributor] elects to include this software in this distribution
470.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
470.34 + * single choice of license, a recipient has the option to distribute
470.35 + * your version of this file under either the CDDL, the GPL Version 2 or
470.36 + * to extend the choice of license to its licensees as provided above.
470.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
470.38 + * Version 2 license, then the option applies only if the new code is
470.39 + * made subject to such option by the copyright holder.
470.40 + *
470.41 + * Contributor(s):
470.42 + *
470.43 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
470.44 + */
470.45 +
470.46 +package org.netbeans.modules.jackpot30.hintsimpl.jdk7;
470.47 +
470.48 +import java.util.List;
470.49 +import java.util.prefs.Preferences;
470.50 +import org.netbeans.modules.java.hints.jackpot.code.spi.Hint;
470.51 +import org.netbeans.modules.java.hints.jackpot.code.spi.TriggerPattern;
470.52 +import org.netbeans.modules.java.hints.jackpot.impl.RulesManager;
470.53 +import org.netbeans.modules.java.hints.jackpot.spi.HintContext;
470.54 +import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata.Options;
470.55 +import org.netbeans.modules.java.hints.jdk.ConvertToStringSwitch;
470.56 +import org.netbeans.modules.java.hints.options.HintsSettings;
470.57 +import org.netbeans.spi.editor.hints.ErrorDescription;
470.58 +
470.59 +/**
470.60 + *
470.61 + * @author lahvac
470.62 + */
470.63 +@Hint(category="rules15",enabled=false, options=Options.NON_GUI)
470.64 +public class SafeConvertToSwitchString {
470.65 +
470.66 + static final String KEY_ALSO_EQ = "also-equals";
470.67 + static final boolean DEF_ALSO_EQ = true;
470.68 +
470.69 + @TriggerPattern(value="if ($cond) $body; else $else;")
470.70 + public static List<ErrorDescription> hint(HintContext ctx) {
470.71 + Preferences prefs = RulesManager.getPreferences("org.netbeans.modules.java.hints.jdk.ConvertToStringSwitch", HintsSettings.getCurrentProfileId());
470.72 + boolean old = prefs.getBoolean(KEY_ALSO_EQ, DEF_ALSO_EQ);
470.73 +
470.74 + prefs.putBoolean(KEY_ALSO_EQ, false);
470.75 +
470.76 + try {
470.77 + return ConvertToStringSwitch.hint(ctx);
470.78 + } finally {
470.79 + prefs.putBoolean(KEY_ALSO_EQ, old);
470.80 + }
470.81 + }
470.82 +
470.83 +}
471.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
471.2 +++ b/sandbox/old-modules/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/jdk7/java.util.Objects.hint Mon Mar 12 21:10:10 2012 +0100
471.3 @@ -0,0 +1,99 @@
471.4 +<!hint="java.util.Objects">
471.5 +//java.util.Objects.equals:
471.6 +($1 == null) ? ($2 != null) : !$1.equals($2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
471.7 +=>java.util.Objects.equals($1, $2)
471.8 +;;
471.9 +
471.10 +(null == $1) ? ($2 != null) : !$1.equals($2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
471.11 +=>java.util.Objects.equals($1, $2)
471.12 +;;
471.13 +
471.14 +($1 == null) ? (null != $2) : !$1.equals($2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
471.15 +=>java.util.Objects.equals($1, $2)
471.16 +;;
471.17 +
471.18 +(null == $1) ? (null != $2) : !$1.equals($2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
471.19 +=>java.util.Objects.equals($1, $2)
471.20 +;;
471.21 +
471.22 +$1 != $2 && ($1 == null || !$1.equals($2)) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
471.23 +=>java.util.Objects.equals($1, $2)
471.24 +;;
471.25 +
471.26 +$1 != $2 && (null == $1 || !$1.equals($2)) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
471.27 +=>java.util.Objects.equals($1, $2)
471.28 +;;
471.29 +
471.30 +($1 == null) ? ($2 == null) : $1.equals($2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
471.31 +=>java.util.Objects.equals($1, $2)
471.32 +;;
471.33 +
471.34 +(null == $1) ? ($2 == null) : $1.equals($2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
471.35 +=>java.util.Objects.equals($1, $2)
471.36 +;;
471.37 +
471.38 +($1 == null) ? (null == $2) : $1.equals($2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
471.39 +=>java.util.Objects.equals($1, $2)
471.40 +;;
471.41 +
471.42 +(null == $1) ? (null == $2) : $1.equals($2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
471.43 +=>java.util.Objects.equals($1, $2)
471.44 +;;
471.45 +
471.46 +($1 != null) ? $1.equals($2) : ($2 == null) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
471.47 +=>java.util.Objects.equals($1, $2)
471.48 +;;
471.49 +
471.50 +(null != $1) ? $1.equals($2) : ($2 == null) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
471.51 +=>java.util.Objects.equals($1, $2)
471.52 +;;
471.53 +
471.54 +($1 != null) ? $1.equals($2) : (null == $2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
471.55 +=>java.util.Objects.equals($1, $2)
471.56 +;;
471.57 +
471.58 +(null != $1) ? $1.equals($2) : (null == $2) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
471.59 +=>java.util.Objects.equals($1, $2)
471.60 +;;
471.61 +
471.62 +$1 == $2 && ($1 == null || $1.equals($2)) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
471.63 +=>java.util.Objects.equals($1, $2)
471.64 +;;
471.65 +
471.66 +$1 == $2 && (null == $1 || $1.equals($2)) :: $1 instanceof java.lang.Object && $2 instanceof java.lang.Object
471.67 +=>java.util.Objects.equals($1, $2)
471.68 +;;
471.69 +
471.70 +//java.util.Objects.hashCode:
471.71 +$1 != null ? $1.hashCode() : 0 :: $1 instanceof java.lang.Object
471.72 +=>java.util.Objects.hashCode($1)
471.73 +;;
471.74 +
471.75 +null != $1 ? $1.hashCode() : 0 :: $1 instanceof java.lang.Object
471.76 +=>java.util.Objects.hashCode($1)
471.77 +;;
471.78 +
471.79 +$1 == null ? 0 : $1.hashCode() :: $1 instanceof java.lang.Object
471.80 +=>java.util.Objects.hashCode($1)
471.81 +;;
471.82 +
471.83 +null == $1 ? 0 : $1.hashCode() :: $1 instanceof java.lang.Object
471.84 +=>java.util.Objects.hashCode($1)
471.85 +;;
471.86 +
471.87 +//java.util.Objects.toString:
471.88 +$1 != null ? $1.toString() : $def :: $1 instanceof java.lang.Object
471.89 +=>java.util.Objects.toString($1, $def)
471.90 +;;
471.91 +
471.92 +null != $1 ? $1.toString() : $def :: $1 instanceof java.lang.Object
471.93 +=>java.util.Objects.toString($1, $def)
471.94 +;;
471.95 +
471.96 +$1 == null ? $def : $1.hashCode() :: $1 instanceof java.lang.Object
471.97 +=>java.util.Objects.hashCode($1, $def)
471.98 +;;
471.99 +
471.100 +null == $1 ? $def : $1.hashCode() :: $1 instanceof java.lang.Object
471.101 +=>java.util.Objects.hashCode($1, $def)
471.102 +;;
472.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
472.2 +++ b/sandbox/old-modules/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/jdk7/jdk7.upgrade Mon Mar 12 21:10:10 2012 +0100
472.3 @@ -0,0 +1,12 @@
472.4 +{
472.5 + "upgradeName" : "jdk7_upgrade",
472.6 + "bundle" : "org/netbeans/modules/jackpot30/hintsimpl/jdk7/Bundle",
472.7 + "hints" : [
472.8 + "org.netbeans.modules.jackpot30.hintsimpl.jdk7.ConvertToDiamondBulkHint",
472.9 + "org.netbeans.modules.java.hints.jdk.ConvertToStringSwitch",
472.10 + "org.netbeans.modules.java.hints.jdk.ConvertToARM",
472.11 + "org.netbeans.modules.java.hints.jdk.JoinCatches",
472.12 + "org.netbeans.modules.java.hints.jdk.UseSpecificCatch",
472.13 + "java.util.Objects"
472.14 + ]
472.15 +}
473.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
473.2 +++ b/sandbox/old-modules/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/layer.xml Mon Mar 12 21:10:10 2012 +0100
473.3 @@ -0,0 +1,63 @@
473.4 +<?xml version="1.0" encoding="UTF-8"?>
473.5 +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.0//EN" "http://www.netbeans.org/dtds/filesystem-1_0.dtd">
473.6 +<!--
473.7 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
473.8 +
473.9 +Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
473.10 +
473.11 +
473.12 +The contents of this file are subject to the terms of either the GNU
473.13 +General Public License Version 2 only ("GPL") or the Common
473.14 +Development and Distribution License("CDDL") (collectively, the
473.15 +"License"). You may not use this file except in compliance with the
473.16 +License. You can obtain a copy of the License at
473.17 +http://www.netbeans.org/cddl-gplv2.html
473.18 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
473.19 +specific language governing permissions and limitations under the
473.20 +License. When distributing the software, include this License Header
473.21 +Notice in each file and include the License file at
473.22 +nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
473.23 +particular file as subject to the "Classpath" exception as provided
473.24 +by Sun in the GPL Version 2 section of the License file that
473.25 +accompanied this code. If applicable, add the following below the
473.26 +License Header, with the fields enclosed by brackets [] replaced by
473.27 +your own identifying information:
473.28 +"Portions Copyrighted [year] [name of copyright owner]"
473.29 +
473.30 +Contributor(s):
473.31 +
473.32 +The Original Software is NetBeans. The Initial Developer of the Original
473.33 +Software is Sun Microsystems, Inc. Portions Copyright 2009-2010 Sun
473.34 +Microsystems, Inc. All Rights Reserved.
473.35 +
473.36 +If you wish your version of this file to be governed by only the CDDL
473.37 +or only the GPL Version 2, indicate your decision by adding
473.38 +"[Contributor] elects to include this software in this distribution
473.39 +under the [CDDL or GPL Version 2] license." If you do not indicate a
473.40 +single choice of license, a recipient has the option to distribute
473.41 +your version of this file under either the CDDL, the GPL Version 2 or
473.42 +to extend the choice of license to its licensees as provided above.
473.43 +However, if you add GPL Version 2 code and therefore, elected the GPL
473.44 +Version 2 license, then the option applies only if the new code is
473.45 +made subject to such option by the copyright holder.
473.46 +-->
473.47 +<filesystem>
473.48 +
473.49 + <folder name="org-netbeans-modules-java-hints">
473.50 + <folder name="declarative">
473.51 + <file name="Bundle.properties" url="jdk7/Bundle.properties" /> <!--XXX-->
473.52 + <file name="assert2if.hint" url="assert2if.hint" />
473.53 + <file name="variable-decl-assignment.hint" url="variable-decl-assignment.hint" />
473.54 + <file name="double-checked-locking.hint" url="double-checked-locking.hint" />
473.55 + <file name="sync-on-non-final.hint" url="sync-on-non-final.hint" />
473.56 + <file name="abstract-document.hint" url="abstract-document.hint" />
473.57 + <file name="AddConditionals.hint" url="jackpot/AddConditionals.hint" />
473.58 + <file name="EnhancedFor.hint" url="jackpot/EnhancedFor.hint" />
473.59 + <file name="java.util.Objects.hint" url="jdk7/java.util.Objects.hint" />
473.60 + </folder>
473.61 + <folder name="upgrades">
473.62 + <file name="jdk7.upgrade" url="jdk7/jdk7.upgrade" />
473.63 + </folder>
473.64 + </folder>
473.65 +
473.66 +</filesystem>
474.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
474.2 +++ b/sandbox/old-modules/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/sync-on-non-final.hint Mon Mar 12 21:10:10 2012 +0100
474.3 @@ -0,0 +1,5 @@
474.4 +'Synchronizing on non-final field':
474.5 +synchronized($var) {
474.6 + $stmts$;
474.7 +} :: !hasModifier($var, Modifier.FINAL) && elementKindMatches($var, ElementKind.FIELD)
474.8 +;;
475.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
475.2 +++ b/sandbox/old-modules/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/variable-decl-assignment.hint Mon Mar 12 21:10:10 2012 +0100
475.3 @@ -0,0 +1,4 @@
475.4 +'Separated variable declaration and assignment':
475.5 +{ $1 $2; $2 = $3; }
475.6 + => { $1 $2 = $3; }
475.7 + ;;
476.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
476.2 +++ b/sandbox/old-modules/hintsimpl/src/org/netbeans/modules/jackpot30/hintsimpl/wrong-string-comparison.hint Mon Mar 12 21:10:10 2012 +0100
476.3 @@ -0,0 +1,31 @@
476.4 +'Wrong string comparison':
476.5 +$left == $right :: $left instanceof java.lang.String
476.6 + && $right instanceof java.lang.String
476.7 + && !isNullLiteral($left)
476.8 + && !isNullLiteral($right)
476.9 +=>$left == null ? $right == null : $left.equals($right)
476.10 +=>$left.equals($right)
476.11 +;;
476.12 +
476.13 +'Wrong string comparison':
476.14 +$left != $right :: $left instanceof java.lang.String
476.15 + && $right instanceof java.lang.String
476.16 + && !isNullLiteral($left)
476.17 + && !isNullLiteral($right)
476.18 + && !acceptGenerated($left, $right)
476.19 +=>!($left == null ? $right == null : $left.equals($right))
476.20 +=>!$left.equals($right)
476.21 +;;
476.22 +
476.23 +<?
476.24 +private boolean acceptGenerated(Variable left, Variable right) {
476.25 + Variable parent = left;
476.26 +
476.27 + while ((parent = context.parent(parent)) != null) {
476.28 + if (matcher.matches(parent, "$left != $right && ($left == null || $left.equals($right))"))
476.29 + return true;
476.30 + }
476.31 +
476.32 + return false;
476.33 +}
476.34 +?>
477.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
477.2 +++ b/sandbox/old-modules/hintsimpl/test/unit/src/org/netbeans/modules/jackpot30/hintsimpl/HintsTest.java Mon Mar 12 21:10:10 2012 +0100
477.3 @@ -0,0 +1,55 @@
477.4 +/*
477.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
477.6 + *
477.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
477.8 + *
477.9 + * The contents of this file are subject to the terms of either the GNU
477.10 + * General Public License Version 2 only ("GPL") or the Common
477.11 + * Development and Distribution License("CDDL") (collectively, the
477.12 + * "License"). You may not use this file except in compliance with the
477.13 + * License. You can obtain a copy of the License at
477.14 + * http://www.netbeans.org/cddl-gplv2.html
477.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
477.16 + * specific language governing permissions and limitations under the
477.17 + * License. When distributing the software, include this License Header
477.18 + * Notice in each file and include the License file at
477.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
477.20 + * particular file as subject to the "Classpath" exception as provided
477.21 + * by Sun in the GPL Version 2 section of the License file that
477.22 + * accompanied this code. If applicable, add the following below the
477.23 + * License Header, with the fields enclosed by brackets [] replaced by
477.24 + * your own identifying information:
477.25 + * "Portions Copyrighted [year] [name of copyright owner]"
477.26 + *
477.27 + * If you wish your version of this file to be governed by only the CDDL
477.28 + * or only the GPL Version 2, indicate your decision by adding
477.29 + * "[Contributor] elects to include this software in this distribution
477.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
477.31 + * single choice of license, a recipient has the option to distribute
477.32 + * your version of this file under either the CDDL, the GPL Version 2 or
477.33 + * to extend the choice of license to its licensees as provided above.
477.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
477.35 + * Version 2 license, then the option applies only if the new code is
477.36 + * made subject to such option by the copyright holder.
477.37 + *
477.38 + * Contributor(s):
477.39 + *
477.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
477.41 + */
477.42 +
477.43 +package org.netbeans.modules.jackpot30.hintsimpl;
477.44 +
477.45 +import junit.framework.TestSuite;
477.46 +import org.netbeans.modules.java.hints.declarative.test.api.DeclarativeHintsTestBase;
477.47 +
477.48 +/**
477.49 + *
477.50 + * @author lahvac
477.51 + */
477.52 +public class HintsTest extends DeclarativeHintsTestBase {
477.53 +
477.54 + public static TestSuite suite() {
477.55 + return suite(HintsTest.class);
477.56 + }
477.57 +
477.58 +}
478.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
478.2 +++ b/sandbox/old-modules/hintsimpl/test/unit/src/org/netbeans/modules/jackpot30/hintsimpl/abstract-document.test Mon Mar 12 21:10:10 2012 +0100
478.3 @@ -0,0 +1,46 @@
478.4 +%%TestCase simple-readlock
478.5 +package test;
478.6 +import javax.swing.text.AbstractDocument;
478.7 +public class Test {
478.8 + private void test(AbstractDocument d) {
478.9 + d.readLock();
478.10 + System.err.println(d.getText(0, d.getLength()));
478.11 + d.readUnlock();
478.12 + }
478.13 +}
478.14 +%%=>
478.15 +package test;
478.16 +import javax.swing.text.AbstractDocument;
478.17 +public class Test {
478.18 + private void test(AbstractDocument d) {
478.19 + d.readLock();
478.20 + try {
478.21 + System.err.println(d.getText(0, d.getLength()));
478.22 + } finally {
478.23 + d.readUnlock();
478.24 + }
478.25 + }
478.26 +}
478.27 +%%TestCase simple-writelock
478.28 +package test;
478.29 +import javax.swing.text.AbstractDocument;
478.30 +public class Test {
478.31 + private void test(AbstractDocument d) {
478.32 + d.writeLock();
478.33 + System.err.println(d.getText(0, d.getLength()));
478.34 + d.writeUnlock();
478.35 + }
478.36 +}
478.37 +%%=>
478.38 +package test;
478.39 +import javax.swing.text.AbstractDocument;
478.40 +public class Test {
478.41 + private void test(AbstractDocument d) {
478.42 + d.writeLock();
478.43 + try {
478.44 + System.err.println(d.getText(0, d.getLength()));
478.45 + } finally {
478.46 + d.writeUnlock();
478.47 + }
478.48 + }
478.49 +}
479.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
479.2 +++ b/sandbox/old-modules/hintsimpl/test/unit/src/org/netbeans/modules/jackpot30/hintsimpl/double-checked-locking.test Mon Mar 12 21:10:10 2012 +0100
479.3 @@ -0,0 +1,46 @@
479.4 +%%TestCase simple
479.5 +package test;
479.6 +public class Test {
479.7 + private static Object TEST;
479.8 + public static Object get() {
479.9 + if (TEST == null) {
479.10 + synchronized (Test.class) {
479.11 + if (TEST == null) {
479.12 + TEST = new Object();
479.13 + }
479.14 + }
479.15 + }
479.16 +
479.17 + return TEST;
479.18 + }
479.19 +}
479.20 +%%=>
479.21 +package test;
479.22 +public class Test {
479.23 + private static Object TEST;
479.24 + public static Object get() {
479.25 + synchronized (Test.class) {
479.26 + if (TEST == null) {
479.27 + TEST = new Object();
479.28 + }
479.29 + }
479.30 +
479.31 + return TEST;
479.32 + }
479.33 +}
479.34 +%%TestCase volatile
479.35 +package test;
479.36 +public class Test {
479.37 + private static volatile Object TEST;
479.38 + public static Object get() {
479.39 + if (TEST == null) {
479.40 + synchronized (Test.class) {
479.41 + if (TEST == null) {
479.42 + TEST = new Object();
479.43 + }
479.44 + }
479.45 + }
479.46 +
479.47 + return TEST;
479.48 + }
479.49 +}
480.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
480.2 +++ b/sandbox/old-modules/hintsimpl/test/unit/src/org/netbeans/modules/jackpot30/hintsimpl/jackpot/AddConditionals.test Mon Mar 12 21:10:10 2012 +0100
480.3 @@ -0,0 +1,87 @@
480.4 +%%TestCase simple-return
480.5 +package test;
480.6 +public class Test {
480.7 + public int test(boolean b) {
480.8 + if (b)
480.9 + return 1;
480.10 + else
480.11 + return 2;
480.12 + }
480.13 +}
480.14 +%%=>
480.15 +package test;
480.16 +public class Test {
480.17 + public int test(boolean b) {
480.18 + return b ? 1 : 2;
480.19 + }
480.20 +}
480.21 +%%TestCase blocks-return
480.22 +package test;
480.23 +public class Test {
480.24 + public int test(boolean b) {
480.25 + if (b) {
480.26 + return 1;
480.27 + } else {
480.28 + return 2;
480.29 + }
480.30 + }
480.31 +}
480.32 +%%=>
480.33 +package test;
480.34 +public class Test {
480.35 + public int test(boolean b) {
480.36 + return b ? 1 : 2;
480.37 + }
480.38 +}
480.39 +%%TestCase simple-assignment
480.40 +package test;
480.41 +public class Test {
480.42 + public void test(boolean b) {
480.43 + int q = 3;
480.44 + if (b)
480.45 + q = 1;
480.46 + else
480.47 + q = 2;
480.48 + }
480.49 +}
480.50 +%%=>
480.51 +package test;
480.52 +public class Test {
480.53 + public void test(boolean b) {
480.54 + int q = 3;
480.55 + q = b ? 1 : 2;
480.56 + }
480.57 +}
480.58 +%%TestCase simplify-conditional-with-casts
480.59 +package test;
480.60 +public class Test {
480.61 + public void test(boolean b, Object o1, Object o2) {
480.62 + String s = b ? (String) o1 : (String) o2;
480.63 + }
480.64 +}
480.65 +%%=>
480.66 +package test;
480.67 +public class Test {
480.68 + public void test(boolean b, Object o1, Object o2) {
480.69 + String s = (String) (b ? o1 : o2);
480.70 + }
480.71 +}
480.72 +%%TestCase simplify-with-declaration
480.73 +package test;
480.74 +public class Test {
480.75 + public void test(boolean b) {
480.76 + int q;
480.77 + if (b)
480.78 + q = 1;
480.79 + else
480.80 + q = 2;
480.81 + }
480.82 +}
480.83 +%%=>
480.84 +package test;
480.85 +public class Test {
480.86 + public void test(boolean b) {
480.87 + int q;
480.88 + q = b ? 1 : 2;
480.89 + }
480.90 +}
481.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
481.2 +++ b/sandbox/old-modules/hintsimpl/test/unit/src/org/netbeans/modules/jackpot30/hintsimpl/jackpot/EnhancedFor.test Mon Mar 12 21:10:10 2012 +0100
481.3 @@ -0,0 +1,64 @@
481.4 +%%TestCase simple-array
481.5 +package test;
481.6 +public class Test {
481.7 + private void test() {
481.8 + String[] a = new String[2];
481.9 +
481.10 + for (int c = 0; c < a.length; c++) {
481.11 + String s = a[c];
481.12 + System.err.println(s);
481.13 + }
481.14 + }
481.15 +}
481.16 +%%=>
481.17 +package test;
481.18 +public class Test {
481.19 + private void test() {
481.20 + String[] a = new String[2];
481.21 + for (String s : a) {
481.22 + System.err.println(s);
481.23 + }
481.24 + }
481.25 +}
481.26 +%%TestCase simple-iterable
481.27 +package test;
481.28 +import java.util.Iterator;
481.29 +public class Test {
481.30 + private void test(Iterable iterable) {
481.31 + for (Iterator it = iterable.iterator(); it.hasNext();) {
481.32 + String s = (String) it.next();
481.33 + System.err.println(s);
481.34 + }
481.35 + }
481.36 +}
481.37 +%%=>
481.38 +package test;
481.39 +import java.util.Iterator;
481.40 +public class Test {
481.41 + private void test(Iterable iterable) {
481.42 + for (String s : iterable) {
481.43 + System.err.println(s);
481.44 + }
481.45 + }
481.46 +}
481.47 +%%TestCase generified-iterable
481.48 +package test;
481.49 +import java.util.Iterator;
481.50 +public class Test {
481.51 + private void test(Iterable<? extends String> iterable) {
481.52 + for (Iterator<? extends String> it = iterable.iterator(); it.hasNext();) {
481.53 + String s = it.next();
481.54 + System.err.println(s);
481.55 + }
481.56 + }
481.57 +}
481.58 +%%=>
481.59 +package test;
481.60 +import java.util.Iterator;
481.61 +public class Test {
481.62 + private void test(Iterable<? extends String> iterable) {
481.63 + for (String s : iterable) {
481.64 + System.err.println(s);
481.65 + }
481.66 + }
481.67 +}
482.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
482.2 +++ b/sandbox/old-modules/hintsimpl/test/unit/src/org/netbeans/modules/jackpot30/hintsimpl/jdk7/java.util.Objects.test Mon Mar 12 21:10:10 2012 +0100
482.3 @@ -0,0 +1,68 @@
482.4 +%%TestCase positive-equals-1 DISABLED
482.5 +package test;
482.6 +public class Test {
482.7 + private boolean test(Object o1, Object o2) {
482.8 + return (o1 == null) ? (o2 != null) : !o1.equals(o2);
482.9 + }
482.10 +}
482.11 +%%=>
482.12 +package test;
482.13 +
482.14 +import java.util.Objects;
482.15 +
482.16 +public class Test {
482.17 + private boolean test(Object o1, Object o2) {
482.18 + return Objects.equals(o1, o2);
482.19 + }
482.20 +}
482.21 +%%TestCase positive-equals-2 DISABLED
482.22 +package test;
482.23 +public class Test {
482.24 + private boolean test(Object o1, Object o2) {
482.25 + return o1 != o2 && (o1 == null || !o1.equals(o2));
482.26 + }
482.27 +}
482.28 +%%=>
482.29 +package test;
482.30 +
482.31 +import java.util.Objects;
482.32 +
482.33 +public class Test {
482.34 + private boolean test(Object o1, Object o2) {
482.35 + return Objects.equals(o1, o2);
482.36 + }
482.37 +}
482.38 +%%TestCase positive-hashcode-1 DISABLED
482.39 +package test;
482.40 +public class Test {
482.41 + private boolean test(Object o1) {
482.42 + return (o1 != null ? o1.hashCode() : 0);
482.43 + }
482.44 +}
482.45 +%%=>
482.46 +package test;
482.47 +
482.48 +import java.util.Objects;
482.49 +
482.50 +public class Test {
482.51 + private boolean test(Object o1) {
482.52 + return Objects.hashCode(o1);
482.53 + }
482.54 +}
482.55 +%%TestCase positive-hashcode-2 DISABLED
482.56 +package test;
482.57 +public class Test {
482.58 + private boolean test(Object o1) {
482.59 + return o1 != null ? o1.hashCode() : 0;
482.60 + }
482.61 +}
482.62 +%%=>
482.63 +package test;
482.64 +
482.65 +import java.util.Objects;
482.66 +
482.67 +public class Test {
482.68 + private boolean test(Object o1) {
482.69 + return Objects.hashCode(o1);
482.70 + }
482.71 +}
483.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
483.2 +++ b/sandbox/old-modules/hintsimpl/test/unit/src/org/netbeans/modules/jackpot30/hintsimpl/wrong-string-comparison.test Mon Mar 12 21:10:10 2012 +0100
483.3 @@ -0,0 +1,56 @@
483.4 +%%TestCase simple
483.5 +package test;
483.6 +public class Test {
483.7 + public static boolean get(String s1, String s2) {
483.8 + return s1 == s2;
483.9 + }
483.10 +}
483.11 +%%=>
483.12 +package test;
483.13 +public class Test {
483.14 + public static boolean get(String s1, String s2) {
483.15 + return s1 == null ? s2 == null : s1.equals(s2);
483.16 + }
483.17 +}
483.18 +%%=>
483.19 +package test;
483.20 +public class Test {
483.21 + public static boolean get(String s1, String s2) {
483.22 + return s1.equals(s2);
483.23 + }
483.24 +}
483.25 +%%TestCase neg
483.26 +package test;
483.27 +public class Test {
483.28 + public static boolean get(String s1, String s2) {
483.29 + return s1 != s2;
483.30 + }
483.31 +}
483.32 +%%=>
483.33 +package test;
483.34 +public class Test {
483.35 + public static boolean get(String s1, String s2) {
483.36 + return !(s1 == null ? s2 == null : s1.equals(s2));
483.37 + }
483.38 +}
483.39 +%%=>
483.40 +package test;
483.41 +public class Test {
483.42 + public static boolean get(String s1, String s2) {
483.43 + return !s1.equals(s2);
483.44 + }
483.45 +}
483.46 +%%TestCase neg-accept
483.47 +package test;
483.48 +public class Test {
483.49 + public static boolean get(String s1, String s2) {
483.50 + return s1 != s2 && (s1 == null || s1.equals(s2));
483.51 + }
483.52 +}
483.53 +%%TestCase null
483.54 +package test;
483.55 +public class Test {
483.56 + public static boolean get(String s1, String s2) {
483.57 + return s1 == null;
483.58 + }
483.59 +}
484.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
484.2 +++ b/sandbox/old-modules/kit/build.xml Mon Mar 12 21:10:10 2012 +0100
484.3 @@ -0,0 +1,13 @@
484.4 +<?xml version="1.0" encoding="UTF-8"?>
484.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
484.6 +<!-- for some information on what you could do (e.g. targets to override). -->
484.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
484.8 +<project name="org.netbeans.modules.jackpot30.kit" default="netbeans" basedir=".">
484.9 + <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.kit.</description>
484.10 + <import file="nbproject/build-impl.xml"/>
484.11 +
484.12 + <target name="test" />
484.13 + <target name="test-coverage" />
484.14 + <target name="coverage-report" />
484.15 + <target name="findbugs" />
484.16 +</project>
485.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
485.2 +++ b/sandbox/old-modules/kit/manifest.mf Mon Mar 12 21:10:10 2012 +0100
485.3 @@ -0,0 +1,5 @@
485.4 +Manifest-Version: 1.0
485.5 +OpenIDE-Module: org.netbeans.modules.jackpot30.kit
485.6 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/kit/Bundle.properties
485.7 +OpenIDE-Module-Specification-Version: 1.16
485.8 +
486.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
486.2 +++ b/sandbox/old-modules/kit/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
486.3 @@ -0,0 +1,45 @@
486.4 +<?xml version="1.0" encoding="UTF-8"?>
486.5 +<!--
486.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
486.7 +*** EDIT ../build.xml INSTEAD ***
486.8 +-->
486.9 +<project name="org.netbeans.modules.jackpot30.kit-impl" basedir="..">
486.10 + <fail message="Please build using Ant 1.7.1 or higher.">
486.11 + <condition>
486.12 + <not>
486.13 + <antversion atleast="1.7.1"/>
486.14 + </not>
486.15 + </condition>
486.16 + </fail>
486.17 + <property file="nbproject/private/suite-private.properties"/>
486.18 + <property file="nbproject/suite.properties"/>
486.19 + <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
486.20 + <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
486.21 + <property file="${suite.dir}/nbproject/platform.properties"/>
486.22 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
486.23 + <attribute name="name"/>
486.24 + <attribute name="value"/>
486.25 + <sequential>
486.26 + <property name="@{name}" value="${@{value}}"/>
486.27 + </sequential>
486.28 + </macrodef>
486.29 + <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
486.30 + <attribute name="property"/>
486.31 + <attribute name="value"/>
486.32 + <sequential>
486.33 + <property name="@{property}" value="@{value}"/>
486.34 + </sequential>
486.35 + </macrodef>
486.36 + <property file="${user.properties.file}"/>
486.37 + <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
486.38 + <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
486.39 + <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
486.40 + <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
486.41 + <condition>
486.42 + <not>
486.43 + <contains string="${cluster.path.evaluated}" substring="platform"/>
486.44 + </not>
486.45 + </condition>
486.46 + </fail>
486.47 + <import file="${harness.dir}/build.xml"/>
486.48 +</project>
487.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
487.2 +++ b/sandbox/old-modules/kit/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
487.3 @@ -0,0 +1,8 @@
487.4 +build.xml.data.CRC32=719584a7
487.5 +build.xml.script.CRC32=6c4da9a3
487.6 +build.xml.stylesheet.CRC32=79c3b980@1.28.0.7
487.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
487.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
487.9 +nbproject/build-impl.xml.data.CRC32=ff5fa2e9
487.10 +nbproject/build-impl.xml.script.CRC32=c129207c
487.11 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.47
488.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
488.2 +++ b/sandbox/old-modules/kit/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
488.3 @@ -0,0 +1,2 @@
488.4 +javac.source=1.5
488.5 +javac.compilerargs=-Xlint -Xlint:-serial
489.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
489.2 +++ b/sandbox/old-modules/kit/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
489.3 @@ -0,0 +1,33 @@
489.4 +<?xml version="1.0" encoding="UTF-8"?>
489.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
489.6 + <type>org.netbeans.modules.apisupport.project</type>
489.7 + <configuration>
489.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
489.9 + <code-name-base>org.netbeans.modules.jackpot30.kit</code-name-base>
489.10 + <suite-component/>
489.11 + <module-dependencies>
489.12 + <dependency>
489.13 + <code-name-base>org.netbeans.modules.jackpot30.api</code-name-base>
489.14 + <build-prerequisite/>
489.15 + <compile-dependency/>
489.16 + <run-dependency>
489.17 + <specification-version>1.16</specification-version>
489.18 + </run-dependency>
489.19 + </dependency>
489.20 + <dependency>
489.21 + <code-name-base>org.netbeans.modules.jackpot30.hintsimpl</code-name-base>
489.22 + <run-dependency>
489.23 + <specification-version>1.16</specification-version>
489.24 + </run-dependency>
489.25 + </dependency>
489.26 + <dependency>
489.27 + <code-name-base>org.netbeans.modules.jackpot30.transformers</code-name-base>
489.28 + <run-dependency>
489.29 + <specification-version>1.16</specification-version>
489.30 + </run-dependency>
489.31 + </dependency>
489.32 + </module-dependencies>
489.33 + <public-packages/>
489.34 + </data>
489.35 + </configuration>
489.36 +</project>
490.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
490.2 +++ b/sandbox/old-modules/kit/nbproject/suite.properties Mon Mar 12 21:10:10 2012 +0100
490.3 @@ -0,0 +1,1 @@
490.4 +suite.dir=${basedir}/..
491.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
491.2 +++ b/sandbox/old-modules/kit/src/org/netbeans/modules/jackpot30/kit/Bundle.properties Mon Mar 12 21:10:10 2012 +0100
491.3 @@ -0,0 +1,38 @@
491.4 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
491.5 +#
491.6 +# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
491.7 +#
491.8 +# The contents of this file are subject to the terms of either the GNU
491.9 +# General Public License Version 2 only ("GPL") or the Common
491.10 +# Development and Distribution License("CDDL") (collectively, the
491.11 +# "License"). You may not use this file except in compliance with the
491.12 +# License. You can obtain a copy of the License at
491.13 +# http://www.netbeans.org/cddl-gplv2.html
491.14 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
491.15 +# specific language governing permissions and limitations under the
491.16 +# License. When distributing the software, include this License Header
491.17 +# Notice in each file and include the License file at
491.18 +# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
491.19 +# particular file as subject to the "Classpath" exception as provided
491.20 +# by Sun in the GPL Version 2 section of the License file that
491.21 +# accompanied this code. If applicable, add the following below the
491.22 +# License Header, with the fields enclosed by brackets [] replaced by
491.23 +# your own identifying information:
491.24 +# "Portions Copyrighted [year] [name of copyright owner]"
491.25 +#
491.26 +# If you wish your version of this file to be governed by only the CDDL
491.27 +# or only the GPL Version 2, indicate your decision by adding
491.28 +# "[Contributor] elects to include this software in this distribution
491.29 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
491.30 +# single choice of license, a recipient has the option to distribute
491.31 +# your version of this file under either the CDDL, the GPL Version 2 or
491.32 +# to extend the choice of license to its licensees as provided above.
491.33 +# However, if you add GPL Version 2 code and therefore, elected the GPL
491.34 +# Version 2 license, then the option applies only if the new code is
491.35 +# made subject to such option by the copyright holder.
491.36 +#
491.37 +# Contributor(s):
491.38 +#
491.39 +# Portions Copyrighted 2009 Sun Microsystems, Inc.
491.40 +
491.41 +OpenIDE-Module-Name=Jackpot 3.0
492.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
492.2 +++ b/sandbox/old-modules/overlays/netbeans Mon Mar 12 21:10:10 2012 +0100
492.3 @@ -0,0 +1,307 @@
492.4 +diff --git a/openide.filesystems/src/META-INF/upgrade/org.openide.filesystems.FileObject.hint b/openide.filesystems/src/META-INF/upgrade/org.openide.filesystems.FileObject.hint
492.5 +new file mode 100644
492.6 +--- /dev/null
492.7 ++++ b/openide.filesystems/src/META-INF/upgrade/org.openide.filesystems.FileObject.hint
492.8 +@@ -0,0 +1,23 @@
492.9 ++'FileObject.getPackageNameExt(char, char) is deprecated':
492.10 ++ $0.getPackageNameExt('/', '.') :: $0 instanceof org.openide.FileObject
492.11 ++=> $0.getPath()
492.12 ++;;
492.13 ++'FileObject.getPackageNameExt(char, char) is deprecated':
492.14 ++ $0.getPackageNameExt($1, '.') :: $0 instanceof org.openide.FileObject && $1 instanceof char
492.15 ++=> $0.getPath().replace('/', $1)
492.16 ++;;
492.17 ++
492.18 ++'FileObject.isReadOnly() is deprecated':
492.19 ++ $0.isReadOnly() :: $0 instanceof org.openide.FileObject
492.20 ++=> !$0.canWrite()
492.21 ++;;
492.22 ++
492.23 ++'Repository.getDefaultFileSystem()':
492.24 ++ org.openide.filesystems.Repository.getDefault.getDefaultFileSystem()
492.25 ++=> org.openide.filesystems.FileUtil.getConfigRoot()
492.26 ++;;
492.27 ++
492.28 ++'Repository.getDefaultFileSystem()':
492.29 ++ org.openide.filesystems.Repository.getDefault.getDefaultFileSystem().findResource($path) :: $path instanceof java.lang.String
492.30 ++=> org.openide.filesystems.FileUtil.getConfigFile($path)
492.31 ++;;
492.32 +diff --git a/openide.loaders/src/META-INF/upgrade/org.openide.loaders.DataObject.hint b/openide.loaders/src/META-INF/upgrade/org.openide.loaders.DataObject.hint
492.33 +new file mode 100644
492.34 +--- /dev/null
492.35 ++++ b/openide.loaders/src/META-INF/upgrade/org.openide.loaders.DataObject.hint
492.36 +@@ -0,0 +1,3 @@
492.37 ++'DataObject.getCookie is obsolette':
492.38 ++$this.getCookie($1) :: $this instanceof org.openide.loaders.DataObject && $1 instanceof java.lang.Class
492.39 ++ => $this.getLookup().lookup($1) ;;
492.40 +diff --git a/openide.nodes/src/META-INF/upgrade/org.openide.nodes.Node.hint b/openide.nodes/src/META-INF/upgrade/org.openide.nodes.Node.hint
492.41 +new file mode 100644
492.42 +--- /dev/null
492.43 ++++ b/openide.nodes/src/META-INF/upgrade/org.openide.nodes.Node.hint
492.44 +@@ -0,0 +1,3 @@
492.45 ++'Node.getCookie is obsolette':
492.46 ++$this.getCookie($1) :: $this instanceof org.openide.loaders.DataObject && $1 instanceof java.lang.Class
492.47 ++ => $this.getLookup().lookup($1) ;;
492.48 +diff --git a/openide.text/src/META-INF/upgrade/org.openide.text.Line.hint b/openide.text/src/META-INF/upgrade/org.openide.text.Line.hint
492.49 +new file mode 100644
492.50 +--- /dev/null
492.51 ++++ b/openide.text/src/META-INF/upgrade/org.openide.text.Line.hint
492.52 +@@ -0,0 +1,12 @@
492.53 ++'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_TRY_SHOW, $1) :: $1 instanceof int && $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.NONE, org.openide.text.Line.ShowVisibilityType.NONE, $1) ;;
492.54 ++'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_SHOW, $1) :: $1 instanceof int && $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.OPEN, org.openide.text.Line.ShowVisibilityType.NONE, $1) ;;
492.55 ++'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_GOTO, $1) :: $1 instanceof int && $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.OPEN, org.openide.text.Line.ShowVisibilityType.FOCUS, $1) ;;
492.56 ++'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_TOFRONT, $1) :: $1 instanceof int && $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.OPEN, org.openide.text.Line.ShowVisibilityType.FRONT, $1) ;;
492.57 ++'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_REUSE, $1) :: $1 instanceof int && $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.REUSE, org.openide.text.Line.ShowVisibilityType.FOCUS, $1) ;;
492.58 ++'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_REUSE_NEW, $1) :: $1 instanceof int && $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.REUSE_NEW, org.openide.text.Line.ShowVisibilityType.FOCUS, $1) ;;
492.59 ++'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_TRY_SHOW) :: $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.NONE, org.openide.text.Line.ShowVisibilityType.NONE) ;;
492.60 ++'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_SHOW) :: $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.OPEN, org.openide.text.Line.ShowVisibilityType.NONE) ;;
492.61 ++'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_GOTO) :: $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.OPEN, org.openide.text.Line.ShowVisibilityType.FOCUS) ;;
492.62 ++'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_TOFRONT) :: $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.OPEN, org.openide.text.Line.ShowVisibilityType.FRONT) ;;
492.63 ++'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_REUSE) :: $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.REUSE, org.openide.text.Line.ShowVisibilityType.FOCUS) ;;
492.64 ++'Line.show is deprecated': $this.show(org.openide.text.Line.SHOW_REUSE_NEW) :: $this instanceof org.openide.text.Line => $this.show(org.openide.text.Line.ShowOpenType.REUSE_NEW, org.openide.text.Line.ShowVisibilityType.FOCUS) ;;
492.65 +diff --git a/openide.util/src/META-INF/upgrade/org.openide.ErrorManager.hint b/openide.util/src/META-INF/upgrade/org.openide.ErrorManager.hint
492.66 +new file mode 100644
492.67 +--- /dev/null
492.68 ++++ b/openide.util/src/META-INF/upgrade/org.openide.ErrorManager.hint
492.69 +@@ -0,0 +1,104 @@
492.70 ++'ErrorManager.notify is deprecated':
492.71 ++$this.notify(org.openide.ErrorManager.UNKNOWN, $1) :: $1 instanceof java.lang.Throwable && $this instanceof org.openide.ErrorManager
492.72 ++ =>org.openide.util.Exceptions.printStackTrace($1)
492.73 ++ ;;
492.74 ++
492.75 ++'ErrorManager.notify is deprecated':
492.76 ++org.openide.ErrorManager.getDefault().notify(org.openide.ErrorManager.EXCEPTION, $1) :: $1 instanceof java.lang.Throwable && $this instanceof org.openide.ErrorManager
492.77 ++ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.WARNING, null, $1)
492.78 ++ ;;
492.79 ++
492.80 ++'ErrorManager.notify is deprecated':
492.81 ++org.openide.ErrorManager.getDefault().notify(org.openide.ErrorManager.EXCEPTION, $1) :: $1 instanceof java.lang.Throwable && $this instanceof org.openide.ErrorManager
492.82 ++ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.WARNING, null, $1)
492.83 ++ ;;
492.84 ++
492.85 ++'ErrorManager.notify is deprecated':
492.86 ++org.openide.ErrorManager.getDefault().notify(org.openide.ErrorManager.INFORMATIONAL, $1) :: $1 instanceof java.lang.Throwable && $this instanceof org.openide.ErrorManager
492.87 ++ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.INFO, null, $1)
492.88 ++ ;;
492.89 ++
492.90 ++'ErrorManager.notify is deprecated':
492.91 ++org.openide.ErrorManager.getDefault().notify(org.openide.ErrorManager.USER, $1) :: $1 instanceof java.lang.Throwable && $this instanceof org.openide.ErrorManager
492.92 ++ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.WARNING, null, $1)
492.93 ++ ;;
492.94 ++
492.95 ++'ErrorManager.notify is deprecated':
492.96 ++org.openide.ErrorManager.getDefault().notify(org.openide.ErrorManager.WARNING, $1) :: $1 instanceof java.lang.Throwable && $this instanceof org.openide.ErrorManager
492.97 ++ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.WARNING, null, $1)
492.98 ++ ;;
492.99 ++
492.100 ++'ErrorManager.notify is deprecated':
492.101 ++$this.notify($1) :: $1 instanceof java.lang.Throwable && $this instanceof org.openide.ErrorManager
492.102 ++ =>org.openide.util.Exceptions.printStackTrace($1)
492.103 ++ ;;
492.104 ++
492.105 ++'ErrorManager.log is deprecated':
492.106 ++org.openide.ErrorManager.getDefault().log(org.openide.ErrorManager.UNKNOWN, $1) :: $1 instanceof java.lang.String && $this instanceof org.openide.ErrorManager
492.107 ++ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.INFO, $1)
492.108 ++ ;;
492.109 ++
492.110 ++'ErrorManager.log is deprecated':
492.111 ++org.openide.ErrorManager.getDefault().log(org.openide.ErrorManager.ERROR, $1) :: $1 instanceof java.lang.String && $this instanceof org.openide.ErrorManager
492.112 ++ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.SEVERE, $1)
492.113 ++ ;;
492.114 ++
492.115 ++'ErrorManager.log is deprecated':
492.116 ++org.openide.ErrorManager.getDefault().log(org.openide.ErrorManager.EXCEPTION, $1) :: $1 instanceof java.lang.String && $this instanceof org.openide.ErrorManager
492.117 ++ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.SEVERE, $1)
492.118 ++ ;;
492.119 ++
492.120 ++'ErrorManager.log is deprecated':
492.121 ++org.openide.ErrorManager.getDefault().log(org.openide.ErrorManager.INFORMATIONAL, $1) :: $1 instanceof java.lang.String && $this instanceof org.openide.ErrorManager
492.122 ++ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.FINE, $1)
492.123 ++ ;;
492.124 ++
492.125 ++'ErrorManager.log is deprecated':
492.126 ++org.openide.ErrorManager.getDefault().log(org.openide.ErrorManager.USER, $1) :: $1 instanceof java.lang.String && $this instanceof org.openide.ErrorManager
492.127 ++ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.WARNING, $1)
492.128 ++ ;;
492.129 ++
492.130 ++'ErrorManager.log is deprecated':
492.131 ++org.openide.ErrorManager.getDefault().log(org.openide.ErrorManager.WARNING, $1) :: $1 instanceof java.lang.String && $this instanceof org.openide.ErrorManager
492.132 ++ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.WARNING, $1)
492.133 ++ ;;
492.134 ++
492.135 ++'ErrorManager.log is deprecated':
492.136 ++org.openide.ErrorManager.getDefault().log($1) :: $1 instanceof java.lang.String && $this instanceof org.openide.ErrorManager
492.137 ++ =>java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.FINE, $1)
492.138 ++ ;;
492.139 ++
492.140 ++'ErrorManager.isLoggable is deprecated':
492.141 ++org.openide.ErrorManager.getDefault().isLoggable(org.openide.ErrorManager.UNKNOWN) :: $this instanceof org.openide.ErrorManager
492.142 ++ =>java.util.logging.Logger.getLogger("global").isLoggable(java.util.logging.Level.INFO)
492.143 ++ ;;
492.144 ++
492.145 ++'ErrorManager.isLoggable is deprecated':
492.146 ++org.openide.ErrorManager.getDefault().isLoggable(org.openide.ErrorManager.ERROR) :: $this instanceof org.openide.ErrorManager
492.147 ++ =>java.util.logging.Logger.getLogger("global").isLoggable(java.util.logging.Level.SEVERE)
492.148 ++ ;;
492.149 ++
492.150 ++'ErrorManager.isLoggable is deprecated':
492.151 ++org.openide.ErrorManager.getDefault().isLoggable(org.openide.ErrorManager.EXCEPTION) :: $this instanceof org.openide.ErrorManager
492.152 ++ =>java.util.logging.Logger.getLogger("global").isLoggable(java.util.logging.Level.SEVERE)
492.153 ++ ;;
492.154 ++
492.155 ++'ErrorManager.isLoggable is deprecated':
492.156 ++org.openide.ErrorManager.getDefault().isLoggable(org.openide.ErrorManager.INFORMATIONAL) :: $this instanceof org.openide.ErrorManager
492.157 ++ =>java.util.logging.Logger.getLogger("global").isLoggable(java.util.logging.Level.FINE)
492.158 ++ ;;
492.159 ++
492.160 ++'ErrorManager.isLoggable is deprecated':
492.161 ++org.openide.ErrorManager.getDefault().isLoggable(org.openide.ErrorManager.USER) :: $this instanceof org.openide.ErrorManager
492.162 ++ =>java.util.logging.Logger.getLogger("global").isLoggable(java.util.logging.Level.WARNING)
492.163 ++ ;;
492.164 ++
492.165 ++'ErrorManager.isLoggable is deprecated':
492.166 ++org.openide.ErrorManager.getDefault().isLoggable(org.openide.ErrorManager.WARNING) :: $this instanceof org.openide.ErrorManager
492.167 ++ =>java.util.logging.Logger.getLogger("global").isLoggable(java.util.logging.Level.WARNING)
492.168 ++ ;;
492.169 ++
492.170 ++'ErrorManager.annotate is deprecated':
492.171 ++$this.annotate($1, $2) :: $1 instanceof java.lang.Throwable && $2 instanceof java.lang.String && $this instanceof org.openide.ErrorManager
492.172 ++ =>org.openide.util.Exceptions.attachLocalizedMessage($1, $2)
492.173 ++ ;;
492.174 +diff --git a/openide.util/src/META-INF/upgrade/org.openide.util.Lookup.hint b/openide.util/src/META-INF/upgrade/org.openide.util.Lookup.hint
492.175 +new file mode 100644
492.176 +--- /dev/null
492.177 ++++ b/openide.util/src/META-INF/upgrade/org.openide.util.Lookup.hint
492.178 +@@ -0,0 +1,17 @@
492.179 ++'Lookup.lookupAll can be used instead':
492.180 ++$0.lookup(new org.openide.util.Lookup.Template($1)).allInstances() :: $0 instanceof org.openide.util.Lookup && $1 instanceof java.lang.Class
492.181 ++=>
492.182 ++$0.lookupAll($1)
492.183 ++;;
492.184 ++
492.185 ++'Lookup.lookupResult can be used instead':
492.186 ++$0.lookup(new org.openide.util.Lookup.Template($1)) :: $0 instanceof org.openide.util.Lookup && $1 instanceof java.lang.Class && !parentMatches("$_.allInstances()")
492.187 ++=>
492.188 ++$0.lookupResult($1)
492.189 ++;;
492.190 ++
492.191 ++'Lookup.Template() is deprecated':
492.192 ++new org.openide.util.Lookup.Template()
492.193 ++=>
492.194 ++new org.openide.util.Lookup.Template(java.lang.Object.class)
492.195 ++;;
492.196 +diff --git a/openide.util/src/META-INF/upgrade/org.openide.util.Utilities.hint b/openide.util/src/META-INF/upgrade/org.openide.util.Utilities.hint
492.197 +new file mode 100644
492.198 +--- /dev/null
492.199 ++++ b/openide.util/src/META-INF/upgrade/org.openide.util.Utilities.hint
492.200 +@@ -0,0 +1,19 @@
492.201 ++'Utilities.mergeImages is deprecated':
492.202 ++ org.openide.util.Utilities.mergeImages($1, $2, $3, $4) :: $1 instanceof java.awt.Image && $2 instanceof java.awt.Image && $3 instanceof int && $4 instanceof int
492.203 ++=> org.openide.util.ImageUtilities.mergeImages($1, $2, $3, $4)
492.204 ++;;
492.205 ++
492.206 ++'Utilities.loadImage is deprecated':
492.207 ++ org.openide.util.Utilities.loadImage($1) :: $1 instanceof String
492.208 ++=> org.openide.util.ImageUtilities.loadImage($1)
492.209 ++;;
492.210 ++
492.211 ++'Utilities.icon2Image is deprecated':
492.212 ++ org.openide.util.Utilities.icon2Image($1) :: $1 instanceof javax.swing.Icon
492.213 ++=> org.openide.util.ImageUtilities.icon2Image($1)
492.214 ++;;
492.215 ++
492.216 ++'Utilities.image2Icon can be used instead of new ImageIcon':
492.217 ++ new javax.swing.ImageIcon($1) :: $1 instanceof java.awt.Image
492.218 ++=> org.openide.util.ImageUtilities.image2Icon($1)
492.219 ++;;
492.220 +diff --git a/openide.util/test/unit/src/META-INF/upgrade/org.openide.util.Utilities.test b/openide.util/test/unit/src/META-INF/upgrade/org.openide.util.Utilities.test
492.221 +new file mode 100644
492.222 +--- /dev/null
492.223 ++++ b/openide.util/test/unit/src/META-INF/upgrade/org.openide.util.Utilities.test
492.224 +@@ -0,0 +1,86 @@
492.225 ++%%TestCase mergeImages1
492.226 ++package test;
492.227 ++import java.awt.Image;
492.228 ++import org.openide.util.Utilities;
492.229 ++public class Test {
492.230 ++ private void test() {
492.231 ++ Image i1 = null, i2 = null;
492.232 ++ Utilities.mergeImages(i1, i2, -9, 34);
492.233 ++ }
492.234 ++}
492.235 ++%%=>
492.236 ++package test;
492.237 ++import java.awt.Image;
492.238 ++import org.openide.util.ImageUtilities;
492.239 ++import org.openide.util.Utilities;
492.240 ++public class Test {
492.241 ++ private void test() {
492.242 ++ Image i1 = null, i2 = null;
492.243 ++ ImageUtilities.mergeImages(i1, i2, -9, 34);
492.244 ++ }
492.245 ++}
492.246 ++%%TestCase loadImage1
492.247 ++package test;
492.248 ++import java.awt.Image;
492.249 ++import org.openide.util.Utilities;
492.250 ++public class Test {
492.251 ++ private void test() {
492.252 ++ Utilities.loadImage("foobar");
492.253 ++ }
492.254 ++}
492.255 ++%%=>
492.256 ++package test;
492.257 ++import java.awt.Image;
492.258 ++import org.openide.util.ImageUtilities;
492.259 ++import org.openide.util.Utilities;
492.260 ++public class Test {
492.261 ++ private void test() {
492.262 ++ ImageUtilities.loadImage("foobar");
492.263 ++ }
492.264 ++}
492.265 ++%%TestCase icon2Image1
492.266 ++package test;
492.267 ++import javax.swing.Icon;
492.268 ++import org.openide.util.Utilities;
492.269 ++public class Test {
492.270 ++ private void test() {
492.271 ++ Icon i = null;
492.272 ++ Utilities.icon2Image(i);
492.273 ++ }
492.274 ++}
492.275 ++%%=>
492.276 ++package test;
492.277 ++import javax.swing.Icon;
492.278 ++import org.openide.util.ImageUtilities;
492.279 ++import org.openide.util.Utilities;
492.280 ++public class Test {
492.281 ++ private void test() {
492.282 ++ Icon i = null;
492.283 ++ ImageUtilities.icon2Image(i);
492.284 ++ }
492.285 ++}
492.286 ++%%TestCase image2Icon1
492.287 ++package test;
492.288 ++import java.awt.Image;
492.289 ++import javax.swing.Icon;
492.290 ++import javax.swing.ImageIcon;
492.291 ++import org.openide.util.Utilities;
492.292 ++public class Test {
492.293 ++ private void test() {
492.294 ++ Image img = null;
492.295 ++ Icon i = new ImageIcon(img);
492.296 ++ }
492.297 ++}
492.298 ++%%=>
492.299 ++package test;
492.300 ++import java.awt.Image;
492.301 ++import javax.swing.Icon;
492.302 ++import javax.swing.ImageIcon;
492.303 ++import org.openide.util.ImageUtilities;
492.304 ++import org.openide.util.Utilities;
492.305 ++public class Test {
492.306 ++ private void test() {
492.307 ++ Image img = null;
492.308 ++ Icon i = ImageUtilities.image2Icon(img);
492.309 ++ }
492.310 ++}
493.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
493.2 +++ b/sandbox/old-modules/server/do-indexing Mon Mar 12 21:10:10 2012 +0100
493.3 @@ -0,0 +1,27 @@
493.4 +#!/bin/bash -x
493.5 +
493.6 +performIndexing() {
493.7 + name=`basename $1`;
493.8 + if [ -d $name ] ; then
493.9 + HG_OUT=$(tempfile) || exit
493.10 + trap "rm -f -- '$HG_OUT'" EXIT
493.11 + MODIFIED=$(tempfile) || exit
493.12 + trap "rm -f -- '$HG_OUT' '$MODIFIED'" EXIT
493.13 + REMOVED=$(tempfile) || exit
493.14 + trap "rm -f -- '$HG_OUT' '$MODIFIED' '$REMOVED'" EXIT
493.15 +
493.16 + (cd $name; hg pull; hg --verbose up >$HG_OUT; grep <$HG_OUT "^getting " | cut -d ' ' -f 2- >$MODIFIED; grep <$HG_OUT "^removing " | cut -d ' ' -f 2- >$REMOVED;)
493.17 + java -Xbootclasspath/p:lib/javac-api-nb-7.0-b07.jar -jar indexer.jar $ADDITIONAL_INDEXING_PARAMS $name $2 "$MODIFIED" "$REMOVED"
493.18 + else
493.19 + hg clone $1
493.20 + java -Xbootclasspath/p:lib/javac-api-nb-7.0-b07.jar -jar indexer.jar $ADDITIONAL_INDEXING_PARAMS $name $2
493.21 + fi;
493.22 +}
493.23 +
493.24 +mkdir -p cache
493.25 +
493.26 +for f in `echo $1 | tr ',' '\n'`; do
493.27 + performIndexing $f cache
493.28 +done
493.29 +
493.30 +exit
494.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
494.2 +++ b/sandbox/old-modules/server/indexer/build.xml Mon Mar 12 21:10:10 2012 +0100
494.3 @@ -0,0 +1,86 @@
494.4 +<?xml version="1.0" encoding="UTF-8"?>
494.5 +<!-- You may freely edit this file. See commented blocks below for -->
494.6 +<!-- some examples of how to customize the build. -->
494.7 +<!-- (If you delete it and reopen the project it will be recreated.) -->
494.8 +<!-- By default, only the Clean and Build commands use this build script. -->
494.9 +<!-- Commands such as Run, Debug, and Test only use this build script if -->
494.10 +<!-- the Compile on Save feature is turned off for the project. -->
494.11 +<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
494.12 +<!-- in the project's Project Properties dialog box.-->
494.13 +<project name="indexer" default="default" basedir=".">
494.14 + <description>Builds, tests, and runs the project indexer.</description>
494.15 + <import file="../download.xml"/>
494.16 + <import file="nbproject/build-impl.xml"/>
494.17 + <!--
494.18 +
494.19 + There exist several targets which are by default empty and which can be
494.20 + used for execution of your tasks. These targets are usually executed
494.21 + before and after some main targets. They are:
494.22 +
494.23 + -pre-init: called before initialization of project properties
494.24 + -post-init: called after initialization of project properties
494.25 + -pre-compile: called before javac compilation
494.26 + -post-compile: called after javac compilation
494.27 + -pre-compile-single: called before javac compilation of single file
494.28 + -post-compile-single: called after javac compilation of single file
494.29 + -pre-compile-test: called before javac compilation of JUnit tests
494.30 + -post-compile-test: called after javac compilation of JUnit tests
494.31 + -pre-compile-test-single: called before javac compilation of single JUnit test
494.32 + -post-compile-test-single: called after javac compilation of single JUunit test
494.33 + -pre-jar: called before JAR building
494.34 + -post-jar: called after JAR building
494.35 + -post-clean: called after cleaning build products
494.36 +
494.37 + (Targets beginning with '-' are not intended to be called on their own.)
494.38 +
494.39 + Example of inserting an obfuscator after compilation could look like this:
494.40 +
494.41 + <target name="-post-compile">
494.42 + <obfuscate>
494.43 + <fileset dir="${build.classes.dir}"/>
494.44 + </obfuscate>
494.45 + </target>
494.46 +
494.47 + For list of available properties check the imported
494.48 + nbproject/build-impl.xml file.
494.49 +
494.50 +
494.51 + Another way to customize the build is by overriding existing main targets.
494.52 + The targets of interest are:
494.53 +
494.54 + -init-macrodef-javac: defines macro for javac compilation
494.55 + -init-macrodef-junit: defines macro for junit execution
494.56 + -init-macrodef-debug: defines macro for class debugging
494.57 + -init-macrodef-java: defines macro for class execution
494.58 + -do-jar-with-manifest: JAR building (if you are using a manifest)
494.59 + -do-jar-without-manifest: JAR building (if you are not using a manifest)
494.60 + run: execution of project
494.61 + -javadoc-build: Javadoc generation
494.62 + test-report: JUnit report generation
494.63 +
494.64 + An example of overriding the target for project execution could look like this:
494.65 +
494.66 + <target name="run" depends="indexer-impl.jar">
494.67 + <exec dir="bin" executable="launcher.exe">
494.68 + <arg file="${dist.jar}"/>
494.69 + </exec>
494.70 + </target>
494.71 +
494.72 + Notice that the overridden target depends on the jar target and not only on
494.73 + the compile target as the regular run target does. Again, for a list of available
494.74 + properties which you can use, check the target you are overriding in the
494.75 + nbproject/build-impl.xml file.
494.76 +
494.77 + -->
494.78 +
494.79 + <target name="copy-to-hudson" depends="jar">
494.80 + <mkdir dir="${hudson.compiler.dir}" /> <!--only to be sure, should exist-->
494.81 + <copy todir="${hudson.compiler.dir}/indexer">
494.82 + <fileset dir="${dist.dir}"/>
494.83 + </copy>
494.84 + </target>
494.85 +
494.86 + <target name="-post-clean">
494.87 + <delete dir="${hudson.compiler.dir}/indexer"/>
494.88 + </target>
494.89 +</project>
495.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
495.2 +++ b/sandbox/old-modules/server/indexer/manifest.mf Mon Mar 12 21:10:10 2012 +0100
495.3 @@ -0,0 +1,3 @@
495.4 +Manifest-Version: 1.0
495.5 +X-COMMENT: Main-Class will be added automatically by build
495.6 +
496.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
496.2 +++ b/sandbox/old-modules/server/indexer/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
496.3 @@ -0,0 +1,914 @@
496.4 +<?xml version="1.0" encoding="UTF-8"?>
496.5 +<!--
496.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
496.7 +*** EDIT ../build.xml INSTEAD ***
496.8 +
496.9 +For the purpose of easier reading the script
496.10 +is divided into following sections:
496.11 +
496.12 + - initialization
496.13 + - compilation
496.14 + - jar
496.15 + - execution
496.16 + - debugging
496.17 + - javadoc
496.18 + - junit compilation
496.19 + - junit execution
496.20 + - junit debugging
496.21 + - applet
496.22 + - cleanup
496.23 +
496.24 + -->
496.25 +<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="indexer-impl">
496.26 + <fail message="Please build using Ant 1.7.1 or higher.">
496.27 + <condition>
496.28 + <not>
496.29 + <antversion atleast="1.7.1"/>
496.30 + </not>
496.31 + </condition>
496.32 + </fail>
496.33 + <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
496.34 + <!--
496.35 + ======================
496.36 + INITIALIZATION SECTION
496.37 + ======================
496.38 + -->
496.39 + <target name="-pre-init">
496.40 + <!-- Empty placeholder for easier customization. -->
496.41 + <!-- You can override this target in the ../build.xml file. -->
496.42 + </target>
496.43 + <target depends="-pre-init" name="-init-private">
496.44 + <property file="nbproject/private/config.properties"/>
496.45 + <property file="nbproject/private/configs/${config}.properties"/>
496.46 + <property file="nbproject/private/private.properties"/>
496.47 + </target>
496.48 + <target name="-pre-init-libraries">
496.49 + <property location="../lib/nblibraries.properties" name="libraries.path"/>
496.50 + <dirname file="${libraries.path}" property="libraries.dir.nativedirsep"/>
496.51 + <pathconvert dirsep="/" property="libraries.dir">
496.52 + <path path="${libraries.dir.nativedirsep}"/>
496.53 + </pathconvert>
496.54 + <basename file="${libraries.path}" property="libraries.basename" suffix=".properties"/>
496.55 + <available file="${libraries.dir}/${libraries.basename}-private.properties" property="private.properties.available"/>
496.56 + </target>
496.57 + <target depends="-pre-init-libraries" if="private.properties.available" name="-init-private-libraries">
496.58 + <loadproperties encoding="ISO-8859-1" srcfile="${libraries.dir}/${libraries.basename}-private.properties">
496.59 + <filterchain>
496.60 + <replacestring from="$${base}" to="${libraries.dir}"/>
496.61 + <escapeunicode/>
496.62 + </filterchain>
496.63 + </loadproperties>
496.64 + </target>
496.65 + <target depends="-pre-init,-init-private,-init-private-libraries" name="-init-libraries">
496.66 + <loadproperties encoding="ISO-8859-1" srcfile="${libraries.path}">
496.67 + <filterchain>
496.68 + <replacestring from="$${base}" to="${libraries.dir}"/>
496.69 + <escapeunicode/>
496.70 + </filterchain>
496.71 + </loadproperties>
496.72 + </target>
496.73 + <target depends="-pre-init,-init-private,-init-libraries" name="-init-user">
496.74 + <property file="${user.properties.file}"/>
496.75 + <!-- The two properties below are usually overridden -->
496.76 + <!-- by the active platform. Just a fallback. -->
496.77 + <property name="default.javac.source" value="1.4"/>
496.78 + <property name="default.javac.target" value="1.4"/>
496.79 + </target>
496.80 + <target depends="-pre-init,-init-private,-init-libraries,-init-user" name="-init-project">
496.81 + <property file="nbproject/configs/${config}.properties"/>
496.82 + <property file="nbproject/project.properties"/>
496.83 + </target>
496.84 + <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-init-macrodef-property" name="-do-init">
496.85 + <available file="${manifest.file}" property="manifest.available"/>
496.86 + <condition property="main.class.available">
496.87 + <and>
496.88 + <isset property="main.class"/>
496.89 + <not>
496.90 + <equals arg1="${main.class}" arg2="" trim="true"/>
496.91 + </not>
496.92 + </and>
496.93 + </condition>
496.94 + <condition property="manifest.available+main.class">
496.95 + <and>
496.96 + <isset property="manifest.available"/>
496.97 + <isset property="main.class.available"/>
496.98 + </and>
496.99 + </condition>
496.100 + <condition property="do.mkdist">
496.101 + <and>
496.102 + <isset property="libs.CopyLibs.classpath"/>
496.103 + <not>
496.104 + <istrue value="${mkdist.disabled}"/>
496.105 + </not>
496.106 + </and>
496.107 + </condition>
496.108 + <condition property="manifest.available+main.class+mkdist.available">
496.109 + <and>
496.110 + <istrue value="${manifest.available+main.class}"/>
496.111 + <isset property="do.mkdist"/>
496.112 + </and>
496.113 + </condition>
496.114 + <condition property="manifest.available+mkdist.available">
496.115 + <and>
496.116 + <istrue value="${manifest.available}"/>
496.117 + <isset property="do.mkdist"/>
496.118 + </and>
496.119 + </condition>
496.120 + <condition property="manifest.available-mkdist.available">
496.121 + <or>
496.122 + <istrue value="${manifest.available}"/>
496.123 + <isset property="do.mkdist"/>
496.124 + </or>
496.125 + </condition>
496.126 + <condition property="manifest.available+main.class-mkdist.available">
496.127 + <or>
496.128 + <istrue value="${manifest.available+main.class}"/>
496.129 + <isset property="do.mkdist"/>
496.130 + </or>
496.131 + </condition>
496.132 + <condition property="have.tests">
496.133 + <or>
496.134 + <available file="${test.src.dir}"/>
496.135 + </or>
496.136 + </condition>
496.137 + <condition property="have.sources">
496.138 + <or>
496.139 + <available file="${src.dir}"/>
496.140 + </or>
496.141 + </condition>
496.142 + <condition property="netbeans.home+have.tests">
496.143 + <and>
496.144 + <isset property="netbeans.home"/>
496.145 + <isset property="have.tests"/>
496.146 + </and>
496.147 + </condition>
496.148 + <condition property="no.javadoc.preview">
496.149 + <and>
496.150 + <isset property="javadoc.preview"/>
496.151 + <isfalse value="${javadoc.preview}"/>
496.152 + </and>
496.153 + </condition>
496.154 + <property name="run.jvmargs" value=""/>
496.155 + <property name="javac.compilerargs" value=""/>
496.156 + <property name="work.dir" value="${basedir}"/>
496.157 + <condition property="no.deps">
496.158 + <and>
496.159 + <istrue value="${no.dependencies}"/>
496.160 + </and>
496.161 + </condition>
496.162 + <property name="javac.debug" value="true"/>
496.163 + <property name="javadoc.preview" value="true"/>
496.164 + <property name="application.args" value=""/>
496.165 + <property name="source.encoding" value="${file.encoding}"/>
496.166 + <property name="runtime.encoding" value="${source.encoding}"/>
496.167 + <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
496.168 + <and>
496.169 + <isset property="javadoc.encoding"/>
496.170 + <not>
496.171 + <equals arg1="${javadoc.encoding}" arg2=""/>
496.172 + </not>
496.173 + </and>
496.174 + </condition>
496.175 + <property name="javadoc.encoding.used" value="${source.encoding}"/>
496.176 + <property name="includes" value="**"/>
496.177 + <property name="excludes" value=""/>
496.178 + <property name="do.depend" value="false"/>
496.179 + <condition property="do.depend.true">
496.180 + <istrue value="${do.depend}"/>
496.181 + </condition>
496.182 + <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
496.183 + <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
496.184 + <length length="0" string="${endorsed.classpath}" when="greater"/>
496.185 + </condition>
496.186 + <property name="javac.fork" value="false"/>
496.187 + </target>
496.188 + <target name="-post-init">
496.189 + <!-- Empty placeholder for easier customization. -->
496.190 + <!-- You can override this target in the ../build.xml file. -->
496.191 + </target>
496.192 + <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init" name="-init-check">
496.193 + <fail unless="src.dir">Must set src.dir</fail>
496.194 + <fail unless="test.src.dir">Must set test.src.dir</fail>
496.195 + <fail unless="build.dir">Must set build.dir</fail>
496.196 + <fail unless="dist.dir">Must set dist.dir</fail>
496.197 + <fail unless="build.classes.dir">Must set build.classes.dir</fail>
496.198 + <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
496.199 + <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
496.200 + <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
496.201 + <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
496.202 + <fail unless="dist.jar">Must set dist.jar</fail>
496.203 + </target>
496.204 + <target name="-init-macrodef-property">
496.205 + <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
496.206 + <attribute name="name"/>
496.207 + <attribute name="value"/>
496.208 + <sequential>
496.209 + <property name="@{name}" value="${@{value}}"/>
496.210 + </sequential>
496.211 + </macrodef>
496.212 + </target>
496.213 + <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors">
496.214 + <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
496.215 + <attribute default="${src.dir}" name="srcdir"/>
496.216 + <attribute default="${build.classes.dir}" name="destdir"/>
496.217 + <attribute default="${javac.classpath}" name="classpath"/>
496.218 + <attribute default="${javac.processorpath}" name="processorpath"/>
496.219 + <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
496.220 + <attribute default="${includes}" name="includes"/>
496.221 + <attribute default="${excludes}" name="excludes"/>
496.222 + <attribute default="${javac.debug}" name="debug"/>
496.223 + <attribute default="${empty.dir}" name="sourcepath"/>
496.224 + <attribute default="${empty.dir}" name="gensrcdir"/>
496.225 + <element name="customize" optional="true"/>
496.226 + <sequential>
496.227 + <property location="${build.dir}/empty" name="empty.dir"/>
496.228 + <mkdir dir="${empty.dir}"/>
496.229 + <mkdir dir="@{apgeneratedsrcdir}"/>
496.230 + <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
496.231 + <src>
496.232 + <dirset dir="@{gensrcdir}" erroronmissingdir="false">
496.233 + <include name="*"/>
496.234 + </dirset>
496.235 + </src>
496.236 + <classpath>
496.237 + <path path="@{classpath}"/>
496.238 + </classpath>
496.239 + <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
496.240 + <compilerarg line="${javac.compilerargs}"/>
496.241 + <compilerarg value="-processorpath"/>
496.242 + <compilerarg path="@{processorpath}"/>
496.243 + <compilerarg line="${ap.processors.internal}"/>
496.244 + <compilerarg value="-s"/>
496.245 + <compilerarg path="@{apgeneratedsrcdir}"/>
496.246 + <compilerarg line="${ap.proc.none.internal}"/>
496.247 + <customize/>
496.248 + </javac>
496.249 + </sequential>
496.250 + </macrodef>
496.251 + </target>
496.252 + <target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal">
496.253 + <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
496.254 + <attribute default="${src.dir}" name="srcdir"/>
496.255 + <attribute default="${build.classes.dir}" name="destdir"/>
496.256 + <attribute default="${javac.classpath}" name="classpath"/>
496.257 + <attribute default="${javac.processorpath}" name="processorpath"/>
496.258 + <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
496.259 + <attribute default="${includes}" name="includes"/>
496.260 + <attribute default="${excludes}" name="excludes"/>
496.261 + <attribute default="${javac.debug}" name="debug"/>
496.262 + <attribute default="${empty.dir}" name="sourcepath"/>
496.263 + <attribute default="${empty.dir}" name="gensrcdir"/>
496.264 + <element name="customize" optional="true"/>
496.265 + <sequential>
496.266 + <property location="${build.dir}/empty" name="empty.dir"/>
496.267 + <mkdir dir="${empty.dir}"/>
496.268 + <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
496.269 + <src>
496.270 + <dirset dir="@{gensrcdir}" erroronmissingdir="false">
496.271 + <include name="*"/>
496.272 + </dirset>
496.273 + </src>
496.274 + <classpath>
496.275 + <path path="@{classpath}"/>
496.276 + </classpath>
496.277 + <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
496.278 + <compilerarg line="${javac.compilerargs}"/>
496.279 + <customize/>
496.280 + </javac>
496.281 + </sequential>
496.282 + </macrodef>
496.283 + </target>
496.284 + <target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac">
496.285 + <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
496.286 + <attribute default="${src.dir}" name="srcdir"/>
496.287 + <attribute default="${build.classes.dir}" name="destdir"/>
496.288 + <attribute default="${javac.classpath}" name="classpath"/>
496.289 + <sequential>
496.290 + <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
496.291 + <classpath>
496.292 + <path path="@{classpath}"/>
496.293 + </classpath>
496.294 + </depend>
496.295 + </sequential>
496.296 + </macrodef>
496.297 + <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
496.298 + <attribute default="${build.classes.dir}" name="destdir"/>
496.299 + <sequential>
496.300 + <fail unless="javac.includes">Must set javac.includes</fail>
496.301 + <pathconvert pathsep="," property="javac.includes.binary">
496.302 + <path>
496.303 + <filelist dir="@{destdir}" files="${javac.includes}"/>
496.304 + </path>
496.305 + <globmapper from="*.java" to="*.class"/>
496.306 + </pathconvert>
496.307 + <delete>
496.308 + <files includes="${javac.includes.binary}"/>
496.309 + </delete>
496.310 + </sequential>
496.311 + </macrodef>
496.312 + </target>
496.313 + <target name="-init-macrodef-junit">
496.314 + <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
496.315 + <attribute default="${includes}" name="includes"/>
496.316 + <attribute default="${excludes}" name="excludes"/>
496.317 + <attribute default="**" name="testincludes"/>
496.318 + <sequential>
496.319 + <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}">
496.320 + <batchtest todir="${build.test.results.dir}">
496.321 + <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
496.322 + <filename name="@{testincludes}"/>
496.323 + </fileset>
496.324 + </batchtest>
496.325 + <classpath>
496.326 + <path path="${run.test.classpath}"/>
496.327 + </classpath>
496.328 + <syspropertyset>
496.329 + <propertyref prefix="test-sys-prop."/>
496.330 + <mapper from="test-sys-prop.*" to="*" type="glob"/>
496.331 + </syspropertyset>
496.332 + <formatter type="brief" usefile="false"/>
496.333 + <formatter type="xml"/>
496.334 + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
496.335 + <jvmarg line="${run.jvmargs}"/>
496.336 + </junit>
496.337 + </sequential>
496.338 + </macrodef>
496.339 + </target>
496.340 + <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
496.341 + <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
496.342 + <attribute default="${main.class}" name="name"/>
496.343 + <attribute default="${debug.classpath}" name="classpath"/>
496.344 + <attribute default="" name="stopclassname"/>
496.345 + <sequential>
496.346 + <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
496.347 + <classpath>
496.348 + <path path="@{classpath}"/>
496.349 + </classpath>
496.350 + </nbjpdastart>
496.351 + </sequential>
496.352 + </macrodef>
496.353 + <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
496.354 + <attribute default="${build.classes.dir}" name="dir"/>
496.355 + <sequential>
496.356 + <nbjpdareload>
496.357 + <fileset dir="@{dir}" includes="${fix.classes}">
496.358 + <include name="${fix.includes}*.class"/>
496.359 + </fileset>
496.360 + </nbjpdareload>
496.361 + </sequential>
496.362 + </macrodef>
496.363 + </target>
496.364 + <target name="-init-debug-args">
496.365 + <property name="version-output" value="java version "${ant.java.version}"/>
496.366 + <condition property="have-jdk-older-than-1.4">
496.367 + <or>
496.368 + <contains string="${version-output}" substring="java version "1.0"/>
496.369 + <contains string="${version-output}" substring="java version "1.1"/>
496.370 + <contains string="${version-output}" substring="java version "1.2"/>
496.371 + <contains string="${version-output}" substring="java version "1.3"/>
496.372 + </or>
496.373 + </condition>
496.374 + <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
496.375 + <istrue value="${have-jdk-older-than-1.4}"/>
496.376 + </condition>
496.377 + <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
496.378 + <os family="windows"/>
496.379 + </condition>
496.380 + <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
496.381 + <isset property="debug.transport"/>
496.382 + </condition>
496.383 + </target>
496.384 + <target depends="-init-debug-args" name="-init-macrodef-debug">
496.385 + <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
496.386 + <attribute default="${main.class}" name="classname"/>
496.387 + <attribute default="${debug.classpath}" name="classpath"/>
496.388 + <element name="customize" optional="true"/>
496.389 + <sequential>
496.390 + <java classname="@{classname}" dir="${work.dir}" fork="true">
496.391 + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
496.392 + <jvmarg line="${debug-args-line}"/>
496.393 + <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
496.394 + <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
496.395 + <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
496.396 + <jvmarg line="${run.jvmargs}"/>
496.397 + <classpath>
496.398 + <path path="@{classpath}"/>
496.399 + </classpath>
496.400 + <syspropertyset>
496.401 + <propertyref prefix="run-sys-prop."/>
496.402 + <mapper from="run-sys-prop.*" to="*" type="glob"/>
496.403 + </syspropertyset>
496.404 + <customize/>
496.405 + </java>
496.406 + </sequential>
496.407 + </macrodef>
496.408 + </target>
496.409 + <target name="-init-macrodef-java">
496.410 + <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
496.411 + <attribute default="${main.class}" name="classname"/>
496.412 + <attribute default="${run.classpath}" name="classpath"/>
496.413 + <element name="customize" optional="true"/>
496.414 + <sequential>
496.415 + <java classname="@{classname}" dir="${work.dir}" fork="true">
496.416 + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
496.417 + <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
496.418 + <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
496.419 + <jvmarg line="${run.jvmargs}"/>
496.420 + <classpath>
496.421 + <path path="@{classpath}"/>
496.422 + </classpath>
496.423 + <syspropertyset>
496.424 + <propertyref prefix="run-sys-prop."/>
496.425 + <mapper from="run-sys-prop.*" to="*" type="glob"/>
496.426 + </syspropertyset>
496.427 + <customize/>
496.428 + </java>
496.429 + </sequential>
496.430 + </macrodef>
496.431 + </target>
496.432 + <target name="-init-presetdef-jar">
496.433 + <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
496.434 + <jar compress="${jar.compress}" jarfile="${dist.jar}">
496.435 + <j2seproject1:fileset dir="${build.classes.dir}"/>
496.436 + </jar>
496.437 + </presetdef>
496.438 + </target>
496.439 + <target name="-init-ap-cmdline-properties">
496.440 + <property name="annotation.processing.enabled" value="true"/>
496.441 + <property name="annotation.processing.processors.list" value=""/>
496.442 + <property name="annotation.processing.run.all.processors" value="true"/>
496.443 + <property name="javac.processorpath" value="${javac.classpath}"/>
496.444 + <property name="javac.test.processorpath" value="${javac.test.classpath}"/>
496.445 + <condition property="ap.supported.internal" value="true">
496.446 + <not>
496.447 + <matches pattern="1\.[0-5](\..*)?" string="${javac.source}"/>
496.448 + </not>
496.449 + </condition>
496.450 + </target>
496.451 + <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-ap-cmdline-supported">
496.452 + <condition else="" property="ap.processors.internal" value="-processor ${annotation.processing.processors.list}">
496.453 + <isfalse value="${annotation.processing.run.all.processors}"/>
496.454 + </condition>
496.455 + <condition else="" property="ap.proc.none.internal" value="-proc:none">
496.456 + <isfalse value="${annotation.processing.enabled}"/>
496.457 + </condition>
496.458 + </target>
496.459 + <target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
496.460 + <property name="ap.cmd.line.internal" value=""/>
496.461 + </target>
496.462 + <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
496.463 + <!--
496.464 + ===================
496.465 + COMPILATION SECTION
496.466 + ===================
496.467 + -->
496.468 + <target name="-deps-jar-init" unless="built-jar.properties">
496.469 + <property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>
496.470 + <delete file="${built-jar.properties}" quiet="true"/>
496.471 + </target>
496.472 + <target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
496.473 + <echo level="warn" message="Cycle detected: indexer was already built"/>
496.474 + </target>
496.475 + <target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
496.476 + <mkdir dir="${build.dir}"/>
496.477 + <touch file="${built-jar.properties}" verbose="false"/>
496.478 + <property file="${built-jar.properties}" prefix="already.built.jar."/>
496.479 + <antcall target="-warn-already-built-jar"/>
496.480 + <propertyfile file="${built-jar.properties}">
496.481 + <entry key="${basedir}" value=""/>
496.482 + </propertyfile>
496.483 + <antcall target="-maybe-call-dep">
496.484 + <param name="call.built.properties" value="${built-jar.properties}"/>
496.485 + <param location="${project.org_netbeans_modules_jackpot30_api}" name="call.subproject"/>
496.486 + <param location="${project.org_netbeans_modules_jackpot30_api}/build.xml" name="call.script"/>
496.487 + <param name="call.target" value="netbeans"/>
496.488 + <param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
496.489 + </antcall>
496.490 + </target>
496.491 + <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
496.492 + <target depends="init" name="-check-automatic-build">
496.493 + <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
496.494 + </target>
496.495 + <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
496.496 + <antcall target="clean"/>
496.497 + </target>
496.498 + <target depends="init,deps-jar" name="-pre-pre-compile">
496.499 + <mkdir dir="${build.classes.dir}"/>
496.500 + </target>
496.501 + <target name="-pre-compile">
496.502 + <!-- Empty placeholder for easier customization. -->
496.503 + <!-- You can override this target in the ../build.xml file. -->
496.504 + </target>
496.505 + <target if="do.depend.true" name="-compile-depend">
496.506 + <pathconvert property="build.generated.subdirs">
496.507 + <dirset dir="${build.generated.sources.dir}" erroronmissingdir="false">
496.508 + <include name="*"/>
496.509 + </dirset>
496.510 + </pathconvert>
496.511 + <j2seproject3:depend srcdir="${src.dir}:${build.generated.subdirs}"/>
496.512 + </target>
496.513 + <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
496.514 + <j2seproject3:javac gensrcdir="${build.generated.sources.dir}"/>
496.515 + <copy todir="${build.classes.dir}">
496.516 + <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
496.517 + </copy>
496.518 + </target>
496.519 + <target name="-post-compile">
496.520 + <!-- Empty placeholder for easier customization. -->
496.521 + <!-- You can override this target in the ../build.xml file. -->
496.522 + </target>
496.523 + <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
496.524 + <target name="-pre-compile-single">
496.525 + <!-- Empty placeholder for easier customization. -->
496.526 + <!-- You can override this target in the ../build.xml file. -->
496.527 + </target>
496.528 + <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
496.529 + <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
496.530 + <j2seproject3:force-recompile/>
496.531 + <j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.dir}"/>
496.532 + </target>
496.533 + <target name="-post-compile-single">
496.534 + <!-- Empty placeholder for easier customization. -->
496.535 + <!-- You can override this target in the ../build.xml file. -->
496.536 + </target>
496.537 + <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
496.538 + <!--
496.539 + ====================
496.540 + JAR BUILDING SECTION
496.541 + ====================
496.542 + -->
496.543 + <target depends="init" name="-pre-pre-jar">
496.544 + <dirname file="${dist.jar}" property="dist.jar.dir"/>
496.545 + <mkdir dir="${dist.jar.dir}"/>
496.546 + </target>
496.547 + <target name="-pre-jar">
496.548 + <!-- Empty placeholder for easier customization. -->
496.549 + <!-- You can override this target in the ../build.xml file. -->
496.550 + </target>
496.551 + <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available-mkdist.available">
496.552 + <j2seproject1:jar/>
496.553 + </target>
496.554 + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class-mkdist.available">
496.555 + <j2seproject1:jar manifest="${manifest.file}"/>
496.556 + </target>
496.557 + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
496.558 + <j2seproject1:jar manifest="${manifest.file}">
496.559 + <j2seproject1:manifest>
496.560 + <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
496.561 + </j2seproject1:manifest>
496.562 + </j2seproject1:jar>
496.563 + <echo>To run this application from the command line without Ant, try:</echo>
496.564 + <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
496.565 + <property location="${dist.jar}" name="dist.jar.resolved"/>
496.566 + <pathconvert property="run.classpath.with.dist.jar">
496.567 + <path path="${run.classpath}"/>
496.568 + <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
496.569 + </pathconvert>
496.570 + <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
496.571 + </target>
496.572 + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
496.573 + <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
496.574 + <pathconvert property="run.classpath.without.build.classes.dir">
496.575 + <path path="${run.classpath}"/>
496.576 + <map from="${build.classes.dir.resolved}" to=""/>
496.577 + </pathconvert>
496.578 + <pathconvert pathsep=" " property="jar.classpath">
496.579 + <path path="${run.classpath.without.build.classes.dir}"/>
496.580 + <chainedmapper>
496.581 + <flattenmapper/>
496.582 + <globmapper from="*" to="lib/*"/>
496.583 + </chainedmapper>
496.584 + </pathconvert>
496.585 + <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
496.586 + <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
496.587 + <fileset dir="${build.classes.dir}"/>
496.588 + <manifest>
496.589 + <attribute name="Main-Class" value="${main.class}"/>
496.590 + <attribute name="Class-Path" value="${jar.classpath}"/>
496.591 + </manifest>
496.592 + </copylibs>
496.593 + <echo>To run this application from the command line without Ant, try:</echo>
496.594 + <property location="${dist.jar}" name="dist.jar.resolved"/>
496.595 + <echo>java -jar "${dist.jar.resolved}"</echo>
496.596 + </target>
496.597 + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+mkdist.available" name="-do-jar-with-libraries-without-mainclass" unless="main.class.available">
496.598 + <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
496.599 + <pathconvert property="run.classpath.without.build.classes.dir">
496.600 + <path path="${run.classpath}"/>
496.601 + <map from="${build.classes.dir.resolved}" to=""/>
496.602 + </pathconvert>
496.603 + <pathconvert pathsep=" " property="jar.classpath">
496.604 + <path path="${run.classpath.without.build.classes.dir}"/>
496.605 + <chainedmapper>
496.606 + <flattenmapper/>
496.607 + <globmapper from="*" to="lib/*"/>
496.608 + </chainedmapper>
496.609 + </pathconvert>
496.610 + <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
496.611 + <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
496.612 + <fileset dir="${build.classes.dir}"/>
496.613 + <manifest>
496.614 + <attribute name="Class-Path" value="${jar.classpath}"/>
496.615 + </manifest>
496.616 + </copylibs>
496.617 + </target>
496.618 + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.mkdist" name="-do-jar-with-libraries-without-manifest" unless="manifest.available">
496.619 + <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
496.620 + <pathconvert property="run.classpath.without.build.classes.dir">
496.621 + <path path="${run.classpath}"/>
496.622 + <map from="${build.classes.dir.resolved}" to=""/>
496.623 + </pathconvert>
496.624 + <pathconvert pathsep=" " property="jar.classpath">
496.625 + <path path="${run.classpath.without.build.classes.dir}"/>
496.626 + <chainedmapper>
496.627 + <flattenmapper/>
496.628 + <globmapper from="*" to="lib/*"/>
496.629 + </chainedmapper>
496.630 + </pathconvert>
496.631 + <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
496.632 + <copylibs compress="${jar.compress}" jarfile="${dist.jar}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
496.633 + <fileset dir="${build.classes.dir}"/>
496.634 + <manifest>
496.635 + <attribute name="Class-Path" value="${jar.classpath}"/>
496.636 + </manifest>
496.637 + </copylibs>
496.638 + </target>
496.639 + <target name="-post-jar">
496.640 + <!-- Empty placeholder for easier customization. -->
496.641 + <!-- You can override this target in the ../build.xml file. -->
496.642 + </target>
496.643 + <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-do-jar-with-libraries-without-mainclass,-do-jar-with-libraries-without-manifest,-post-jar" description="Build JAR." name="jar"/>
496.644 + <!--
496.645 + =================
496.646 + EXECUTION SECTION
496.647 + =================
496.648 + -->
496.649 + <target depends="init,compile" description="Run a main class." name="run">
496.650 + <j2seproject1:java>
496.651 + <customize>
496.652 + <arg line="${application.args}"/>
496.653 + </customize>
496.654 + </j2seproject1:java>
496.655 + </target>
496.656 + <target name="-do-not-recompile">
496.657 + <property name="javac.includes.binary" value=""/>
496.658 + </target>
496.659 + <target depends="init,compile-single" name="run-single">
496.660 + <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
496.661 + <j2seproject1:java classname="${run.class}"/>
496.662 + </target>
496.663 + <target depends="init,compile-test-single" name="run-test-with-main">
496.664 + <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
496.665 + <j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
496.666 + </target>
496.667 + <!--
496.668 + =================
496.669 + DEBUGGING SECTION
496.670 + =================
496.671 + -->
496.672 + <target depends="init" if="netbeans.home" name="-debug-start-debugger">
496.673 + <j2seproject1:nbjpdastart name="${debug.class}"/>
496.674 + </target>
496.675 + <target depends="init" if="netbeans.home" name="-debug-start-debugger-main-test">
496.676 + <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${debug.class}"/>
496.677 + </target>
496.678 + <target depends="init,compile" name="-debug-start-debuggee">
496.679 + <j2seproject3:debug>
496.680 + <customize>
496.681 + <arg line="${application.args}"/>
496.682 + </customize>
496.683 + </j2seproject3:debug>
496.684 + </target>
496.685 + <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
496.686 + <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
496.687 + <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
496.688 + </target>
496.689 + <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
496.690 + <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
496.691 + <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
496.692 + <j2seproject3:debug classname="${debug.class}"/>
496.693 + </target>
496.694 + <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
496.695 + <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">
496.696 + <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
496.697 + <j2seproject3:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>
496.698 + </target>
496.699 + <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
496.700 + <target depends="init" name="-pre-debug-fix">
496.701 + <fail unless="fix.includes">Must set fix.includes</fail>
496.702 + <property name="javac.includes" value="${fix.includes}.java"/>
496.703 + </target>
496.704 + <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
496.705 + <j2seproject1:nbjpdareload/>
496.706 + </target>
496.707 + <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
496.708 + <!--
496.709 + ===============
496.710 + JAVADOC SECTION
496.711 + ===============
496.712 + -->
496.713 + <target depends="init" name="-javadoc-build">
496.714 + <mkdir dir="${dist.javadoc.dir}"/>
496.715 + <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
496.716 + <classpath>
496.717 + <path path="${javac.classpath}"/>
496.718 + </classpath>
496.719 + <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
496.720 + <filename name="**/*.java"/>
496.721 + </fileset>
496.722 + <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
496.723 + <include name="**/*.java"/>
496.724 + </fileset>
496.725 + </javadoc>
496.726 + </target>
496.727 + <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
496.728 + <nbbrowse file="${dist.javadoc.dir}/index.html"/>
496.729 + </target>
496.730 + <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
496.731 + <!--
496.732 + =========================
496.733 + JUNIT COMPILATION SECTION
496.734 + =========================
496.735 + -->
496.736 + <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
496.737 + <mkdir dir="${build.test.classes.dir}"/>
496.738 + </target>
496.739 + <target name="-pre-compile-test">
496.740 + <!-- Empty placeholder for easier customization. -->
496.741 + <!-- You can override this target in the ../build.xml file. -->
496.742 + </target>
496.743 + <target if="do.depend.true" name="-compile-test-depend">
496.744 + <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
496.745 + </target>
496.746 + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
496.747 + <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.src.dir}"/>
496.748 + <copy todir="${build.test.classes.dir}">
496.749 + <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
496.750 + </copy>
496.751 + </target>
496.752 + <target name="-post-compile-test">
496.753 + <!-- Empty placeholder for easier customization. -->
496.754 + <!-- You can override this target in the ../build.xml file. -->
496.755 + </target>
496.756 + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
496.757 + <target name="-pre-compile-test-single">
496.758 + <!-- Empty placeholder for easier customization. -->
496.759 + <!-- You can override this target in the ../build.xml file. -->
496.760 + </target>
496.761 + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
496.762 + <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
496.763 + <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
496.764 + <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
496.765 + <copy todir="${build.test.classes.dir}">
496.766 + <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
496.767 + </copy>
496.768 + </target>
496.769 + <target name="-post-compile-test-single">
496.770 + <!-- Empty placeholder for easier customization. -->
496.771 + <!-- You can override this target in the ../build.xml file. -->
496.772 + </target>
496.773 + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
496.774 + <!--
496.775 + =======================
496.776 + JUNIT EXECUTION SECTION
496.777 + =======================
496.778 + -->
496.779 + <target depends="init" if="have.tests" name="-pre-test-run">
496.780 + <mkdir dir="${build.test.results.dir}"/>
496.781 + </target>
496.782 + <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
496.783 + <j2seproject3:junit testincludes="**/*Test.java"/>
496.784 + </target>
496.785 + <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
496.786 + <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
496.787 + </target>
496.788 + <target depends="init" if="have.tests" name="test-report"/>
496.789 + <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
496.790 + <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
496.791 + <target depends="init" if="have.tests" name="-pre-test-run-single">
496.792 + <mkdir dir="${build.test.results.dir}"/>
496.793 + </target>
496.794 + <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
496.795 + <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
496.796 + <j2seproject3:junit excludes="" includes="${test.includes}"/>
496.797 + </target>
496.798 + <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
496.799 + <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
496.800 + </target>
496.801 + <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
496.802 + <!--
496.803 + =======================
496.804 + JUNIT DEBUGGING SECTION
496.805 + =======================
496.806 + -->
496.807 + <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
496.808 + <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
496.809 + <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
496.810 + <delete file="${test.report.file}"/>
496.811 + <mkdir dir="${build.test.results.dir}"/>
496.812 + <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
496.813 + <customize>
496.814 + <syspropertyset>
496.815 + <propertyref prefix="test-sys-prop."/>
496.816 + <mapper from="test-sys-prop.*" to="*" type="glob"/>
496.817 + </syspropertyset>
496.818 + <arg value="${test.class}"/>
496.819 + <arg value="showoutput=true"/>
496.820 + <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
496.821 + <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
496.822 + </customize>
496.823 + </j2seproject3:debug>
496.824 + </target>
496.825 + <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
496.826 + <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
496.827 + </target>
496.828 + <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
496.829 + <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
496.830 + <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
496.831 + </target>
496.832 + <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
496.833 + <!--
496.834 + =========================
496.835 + APPLET EXECUTION SECTION
496.836 + =========================
496.837 + -->
496.838 + <target depends="init,compile-single" name="run-applet">
496.839 + <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
496.840 + <j2seproject1:java classname="sun.applet.AppletViewer">
496.841 + <customize>
496.842 + <arg value="${applet.url}"/>
496.843 + </customize>
496.844 + </j2seproject1:java>
496.845 + </target>
496.846 + <!--
496.847 + =========================
496.848 + APPLET DEBUGGING SECTION
496.849 + =========================
496.850 + -->
496.851 + <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
496.852 + <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
496.853 + <j2seproject3:debug classname="sun.applet.AppletViewer">
496.854 + <customize>
496.855 + <arg value="${applet.url}"/>
496.856 + </customize>
496.857 + </j2seproject3:debug>
496.858 + </target>
496.859 + <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
496.860 + <!--
496.861 + ===============
496.862 + CLEANUP SECTION
496.863 + ===============
496.864 + -->
496.865 + <target name="-deps-clean-init" unless="built-clean.properties">
496.866 + <property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>
496.867 + <delete file="${built-clean.properties}" quiet="true"/>
496.868 + </target>
496.869 + <target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
496.870 + <echo level="warn" message="Cycle detected: indexer was already built"/>
496.871 + </target>
496.872 + <target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
496.873 + <mkdir dir="${build.dir}"/>
496.874 + <touch file="${built-clean.properties}" verbose="false"/>
496.875 + <property file="${built-clean.properties}" prefix="already.built.clean."/>
496.876 + <antcall target="-warn-already-built-clean"/>
496.877 + <propertyfile file="${built-clean.properties}">
496.878 + <entry key="${basedir}" value=""/>
496.879 + </propertyfile>
496.880 + <antcall target="-maybe-call-dep">
496.881 + <param name="call.built.properties" value="${built-clean.properties}"/>
496.882 + <param location="${project.org_netbeans_modules_jackpot30_api}" name="call.subproject"/>
496.883 + <param location="${project.org_netbeans_modules_jackpot30_api}/build.xml" name="call.script"/>
496.884 + <param name="call.target" value="clean"/>
496.885 + <param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
496.886 + </antcall>
496.887 + </target>
496.888 + <target depends="init" name="-do-clean">
496.889 + <delete dir="${build.dir}"/>
496.890 + <delete dir="${dist.dir}" followsymlinks="false" includeemptydirs="true"/>
496.891 + </target>
496.892 + <target name="-post-clean">
496.893 + <!-- Empty placeholder for easier customization. -->
496.894 + <!-- You can override this target in the ../build.xml file. -->
496.895 + </target>
496.896 + <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
496.897 + <target name="-check-call-dep">
496.898 + <property file="${call.built.properties}" prefix="already.built."/>
496.899 + <condition property="should.call.dep">
496.900 + <not>
496.901 + <isset property="already.built.${call.subproject}"/>
496.902 + </not>
496.903 + </condition>
496.904 + <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
496.905 + <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:${toString:endorsed.classpath.path}">
496.906 + <length length="0" string="${endorsed.classpath}" when="greater"/>
496.907 + </condition>
496.908 + </target>
496.909 + <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
496.910 + <ant antfile="${call.script}" inheritall="false" target="${call.target}">
496.911 + <propertyset>
496.912 + <propertyref prefix="transfer."/>
496.913 + <mapper from="transfer.*" to="*" type="glob"/>
496.914 + </propertyset>
496.915 + </ant>
496.916 + </target>
496.917 +</project>
497.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
497.2 +++ b/sandbox/old-modules/server/indexer/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
497.3 @@ -0,0 +1,8 @@
497.4 +build.xml.data.CRC32=8f49f787
497.5 +build.xml.script.CRC32=48d52495
497.6 +build.xml.stylesheet.CRC32=958a1d3e@1.27.0.45
497.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
497.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
497.9 +nbproject/build-impl.xml.data.CRC32=8f49f787
497.10 +nbproject/build-impl.xml.script.CRC32=81f22719
497.11 +nbproject/build-impl.xml.stylesheet.CRC32=1cdc5be9@1.35.0.45
498.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
498.2 +++ b/sandbox/old-modules/server/indexer/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
498.3 @@ -0,0 +1,95 @@
498.4 +annotation.processing.enabled=true
498.5 +annotation.processing.enabled.in.editor=false
498.6 +annotation.processing.run.all.processors=true
498.7 +application.title=indexer
498.8 +application.vendor=lahvac
498.9 +build.classes.dir=${build.dir}/classes
498.10 +build.classes.excludes=**/*.java,**/*.form
498.11 +# This directory is removed when the project is cleaned:
498.12 +build.dir=build
498.13 +build.generated.dir=${build.dir}/generated
498.14 +build.generated.sources.dir=${build.dir}/generated-sources
498.15 +# Only compile against the classpath explicitly listed here:
498.16 +build.sysclasspath=ignore
498.17 +build.test.classes.dir=${build.dir}/test/classes
498.18 +build.test.results.dir=${build.dir}/test/results
498.19 +# Uncomment to specify the preferred debugger connection transport:
498.20 +#debug.transport=dt_socket
498.21 +debug.classpath=\
498.22 + ${run.classpath}
498.23 +debug.test.classpath=\
498.24 + ${run.test.classpath}
498.25 +# This directory is removed when the project is cleaned:
498.26 +dist.dir=dist
498.27 +dist.jar=${dist.dir}/indexer.jar
498.28 +dist.javadoc.dir=${dist.dir}/javadoc
498.29 +endorsed.classpath=\
498.30 + ${libs.javac.classpath}
498.31 +excludes=
498.32 +file.reference.org-netbeans-modules-java-hints.jar=../lib/org-netbeans-modules-java-hints.jar
498.33 +file.reference.org-netbeans-modules-java-source.jar=../lib/org-netbeans-modules-java-source.jar
498.34 +file.reference.org-netbeans-spi-editor-hints.jar=../lib/org-netbeans-spi-editor-hints.jar
498.35 +file.reference.org-openide-filesystems.jar=../lib/org-openide-filesystems.jar
498.36 +file.reference.org-openide-util-lookup.jar=../lib/org-openide-util-lookup.jar
498.37 +file.reference.org-openide-util.jar=../lib/org-openide-util.jar
498.38 +file.reference.util-commons.jar-1=../../remoting/ide/api/external/util-commons.jar
498.39 +file.reference.util-pojson.jar-1=../../remoting/ide/api/external/util-pojson.jar
498.40 +includes=**
498.41 +jar.compress=false
498.42 +javac.classpath=\
498.43 + ${reference.org_netbeans_modules_jackpot30_api.module}:\
498.44 + ${libs.lucene.classpath}:\
498.45 + ${libs.javac.classpath}:\
498.46 + ${file.reference.org-netbeans-modules-java-source.jar}:\
498.47 + ${file.reference.org-openide-filesystems.jar}:\
498.48 + ${file.reference.org-openide-util.jar}:\
498.49 + ${file.reference.org-openide-util-lookup.jar}:\
498.50 + ${file.reference.org-netbeans-spi-editor-hints.jar}:\
498.51 + ${file.reference.org-netbeans-modules-java-hints.jar}:\
498.52 + ${file.reference.util-commons.jar-1}:\
498.53 + ${file.reference.util-pojson.jar-1}
498.54 +# Space-separated list of extra javac options
498.55 +javac.compilerargs=
498.56 +javac.deprecation=false
498.57 +javac.processorpath=\
498.58 + ${javac.classpath}
498.59 +javac.source=1.5
498.60 +javac.target=1.5
498.61 +javac.test.classpath=\
498.62 + ${javac.classpath}:\
498.63 + ${build.classes.dir}:\
498.64 + ${libs.junit_4.classpath}
498.65 +javadoc.additionalparam=
498.66 +javadoc.author=false
498.67 +javadoc.encoding=${source.encoding}
498.68 +javadoc.noindex=false
498.69 +javadoc.nonavbar=false
498.70 +javadoc.notree=false
498.71 +javadoc.private=false
498.72 +javadoc.splitindex=true
498.73 +javadoc.use=true
498.74 +javadoc.version=false
498.75 +javadoc.windowtitle=
498.76 +jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api"
498.77 +main.class=org.netbeans.modules.jackpot30.server.indexer.Index
498.78 +manifest.file=manifest.mf
498.79 +meta.inf.dir=${src.dir}/META-INF
498.80 +mkdist.disabled=false
498.81 +platform.active=default_platform
498.82 +project.org_netbeans_modules_jackpot30_api=../../api
498.83 +reference.org_netbeans_modules_jackpot30_api.module=${project.org_netbeans_modules_jackpot30_api}/../build/cluster/modules/org-netbeans-modules-jackpot30-api.jar
498.84 +run.classpath=\
498.85 + ${javac.classpath}:\
498.86 + ${build.classes.dir}
498.87 +# Space-separated list of JVM arguments used when running the project
498.88 +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
498.89 +# or test-sys-prop.name=value to set system properties for unit tests):
498.90 +run.jvmargs=
498.91 +run.test.classpath=\
498.92 + ${javac.test.classpath}:\
498.93 + ${build.test.classes.dir}
498.94 +source.encoding=UTF-8
498.95 +src.dir=src
498.96 +test.src.dir=test
498.97 +
498.98 +hudson.compiler.dir=../hudson/data/compiler
499.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
499.2 +++ b/sandbox/old-modules/server/indexer/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
499.3 @@ -0,0 +1,28 @@
499.4 +<?xml version="1.0" encoding="UTF-8"?>
499.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
499.6 + <type>org.netbeans.modules.java.j2seproject</type>
499.7 + <configuration>
499.8 + <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
499.9 + <name>indexer</name>
499.10 + <source-roots>
499.11 + <root id="src.dir"/>
499.12 + </source-roots>
499.13 + <test-roots>
499.14 + <root id="test.src.dir"/>
499.15 + </test-roots>
499.16 + </data>
499.17 + <libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
499.18 + <definitions>../lib/nblibraries.properties</definitions>
499.19 + </libraries>
499.20 + <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
499.21 + <reference>
499.22 + <foreign-project>org_netbeans_modules_jackpot30_api</foreign-project>
499.23 + <artifact-type>jar</artifact-type>
499.24 + <script>build.xml</script>
499.25 + <target>netbeans</target>
499.26 + <clean-target>clean</clean-target>
499.27 + <id>module</id>
499.28 + </reference>
499.29 + </references>
499.30 + </configuration>
499.31 +</project>
500.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
500.2 +++ b/sandbox/old-modules/server/indexer/src/org/netbeans/modules/jackpot30/server/indexer/Index.java Mon Mar 12 21:10:10 2012 +0100
500.3 @@ -0,0 +1,106 @@
500.4 +/*
500.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
500.6 + *
500.7 + * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
500.8 + *
500.9 + * The contents of this file are subject to the terms of either the GNU
500.10 + * General Public License Version 2 only ("GPL") or the Common
500.11 + * Development and Distribution License("CDDL") (collectively, the
500.12 + * "License"). You may not use this file except in compliance with the
500.13 + * License. You can obtain a copy of the License at
500.14 + * http://www.netbeans.org/cddl-gplv2.html
500.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
500.16 + * specific language governing permissions and limitations under the
500.17 + * License. When distributing the software, include this License Header
500.18 + * Notice in each file and include the License file at
500.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
500.20 + * particular file as subject to the "Classpath" exception as provided
500.21 + * by Sun in the GPL Version 2 section of the License file that
500.22 + * accompanied this code. If applicable, add the following below the
500.23 + * License Header, with the fields enclosed by brackets [] replaced by
500.24 + * your own identifying information:
500.25 + * "Portions Copyrighted [year] [name of copyright owner]"
500.26 + *
500.27 + * If you wish your version of this file to be governed by only the CDDL
500.28 + * or only the GPL Version 2, indicate your decision by adding
500.29 + * "[Contributor] elects to include this software in this distribution
500.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
500.31 + * single choice of license, a recipient has the option to distribute
500.32 + * your version of this file under either the CDDL, the GPL Version 2 or
500.33 + * to extend the choice of license to its licensees as provided above.
500.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
500.35 + * Version 2 license, then the option applies only if the new code is
500.36 + * made subject to such option by the copyright holder.
500.37 + *
500.38 + * Contributor(s):
500.39 + *
500.40 + * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
500.41 + */
500.42 +
500.43 +package org.netbeans.modules.jackpot30.server.indexer;
500.44 +
500.45 +import java.io.File;
500.46 +import java.io.IOException;
500.47 +import java.util.ArrayList;
500.48 +import java.util.Arrays;
500.49 +import java.util.List;
500.50 +import org.netbeans.modules.jackpot30.impl.indexing.Cache;
500.51 +import org.netbeans.modules.java.hints.jackpot.impl.Utilities;
500.52 +
500.53 +/**
500.54 + *
500.55 + * @author lahvac
500.56 + */
500.57 +public class Index {
500.58 +
500.59 + static final String PARAM_CONSTRUCT_DUPLICATES_INDEX = "-construct-duplicates-index";
500.60 + static final String PARAM_STORE_SOURCES = "-store-sources";
500.61 +
500.62 + /**
500.63 + * @param args the command line arguments
500.64 + */
500.65 + public static void main(String[] args) throws IOException {
500.66 + new Index().index(args);
500.67 + }
500.68 +
500.69 + void index(String[] args) throws IOException {
500.70 + List<String> argsList = new ArrayList<String>(Arrays.asList(args));
500.71 + boolean constructDuplicatesIndex = !argsList.isEmpty() && PARAM_CONSTRUCT_DUPLICATES_INDEX.equals(argsList.get(0));
500.72 +
500.73 + if (constructDuplicatesIndex) argsList.remove(0);
500.74 +
500.75 + boolean storeSources = !argsList.isEmpty() && PARAM_STORE_SOURCES.equals(argsList.get(0));
500.76 +
500.77 + if (storeSources) argsList.remove(0);
500.78 +
500.79 + String modified = null;
500.80 + String removed = null;
500.81 +
500.82 + if (argsList.size() != 2 && argsList.size() != 4) {
500.83 + printHelp();
500.84 + return ;
500.85 + }
500.86 +
500.87 + if (argsList.size() == 4) {
500.88 + modified = argsList.get(2);
500.89 + removed = argsList.get(3);
500.90 + }
500.91 +
500.92 + long startTime = System.currentTimeMillis();
500.93 +
500.94 + Cache.setStandaloneCacheRoot(new File(argsList.get(1)));
500.95 + invokeIndexer(new File(argsList.get(0)), constructDuplicatesIndex, storeSources, modified, removed);
500.96 +
500.97 + long endTime = System.currentTimeMillis();
500.98 +
500.99 + System.out.println("indexing took: " + Utilities.toHumanReadableTime(endTime - startTime));
500.100 + }
500.101 +
500.102 + protected void invokeIndexer(File root, boolean duplicatesIndex, boolean storeSources, String modified, String removed) throws IOException {
500.103 + StandaloneIndexer.index(root, duplicatesIndex, storeSources, modified, removed);
500.104 + }
500.105 +
500.106 + protected void printHelp() {
500.107 + System.err.println("Usage: java -jar " + Index.class.getProtectionDomain().getCodeSource().getLocation().getPath() + " [" + PARAM_CONSTRUCT_DUPLICATES_INDEX + "] [" + PARAM_STORE_SOURCES + "] <source-root> <cache> [<modified-files> <removed-files>]");
500.108 + }
500.109 +}
501.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
501.2 +++ b/sandbox/old-modules/server/indexer/src/org/netbeans/modules/jackpot30/server/indexer/StandaloneFinder.java Mon Mar 12 21:10:10 2012 +0100
501.3 @@ -0,0 +1,202 @@
501.4 +/*
501.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
501.6 + *
501.7 + * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
501.8 + *
501.9 + * The contents of this file are subject to the terms of either the GNU
501.10 + * General Public License Version 2 only ("GPL") or the Common
501.11 + * Development and Distribution License("CDDL") (collectively, the
501.12 + * "License"). You may not use this file except in compliance with the
501.13 + * License. You can obtain a copy of the License at
501.14 + * http://www.netbeans.org/cddl-gplv2.html
501.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
501.16 + * specific language governing permissions and limitations under the
501.17 + * License. When distributing the software, include this License Header
501.18 + * Notice in each file and include the License file at
501.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
501.20 + * particular file as subject to the "Classpath" exception as provided
501.21 + * by Sun in the GPL Version 2 section of the License file that
501.22 + * accompanied this code. If applicable, add the following below the
501.23 + * License Header, with the fields enclosed by brackets [] replaced by
501.24 + * your own identifying information:
501.25 + * "Portions Copyrighted [year] [name of copyright owner]"
501.26 + *
501.27 + * If you wish your version of this file to be governed by only the CDDL
501.28 + * or only the GPL Version 2, indicate your decision by adding
501.29 + * "[Contributor] elects to include this software in this distribution
501.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
501.31 + * single choice of license, a recipient has the option to distribute
501.32 + * your version of this file under either the CDDL, the GPL Version 2 or
501.33 + * to extend the choice of license to its licensees as provided above.
501.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
501.35 + * Version 2 license, then the option applies only if the new code is
501.36 + * made subject to such option by the copyright holder.
501.37 + *
501.38 + * Contributor(s):
501.39 + *
501.40 + * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
501.41 + */
501.42 +
501.43 +package org.netbeans.modules.jackpot30.server.indexer;
501.44 +
501.45 +import com.sun.source.tree.CompilationUnitTree;
501.46 +import com.sun.source.tree.Tree;
501.47 +import com.sun.source.util.TreePath;
501.48 +import com.sun.source.util.Trees;
501.49 +import com.sun.tools.javac.api.JavacTaskImpl;
501.50 +import java.io.File;
501.51 +import java.io.IOException;
501.52 +import java.net.URI;
501.53 +import java.util.Arrays;
501.54 +import java.util.BitSet;
501.55 +import java.util.Collection;
501.56 +import java.util.Collections;
501.57 +import java.util.HashMap;
501.58 +import java.util.LinkedList;
501.59 +import java.util.Map;
501.60 +import javax.tools.Diagnostic;
501.61 +import javax.tools.JavaCompiler;
501.62 +import javax.tools.JavaFileObject;
501.63 +import javax.tools.SimpleJavaFileObject;
501.64 +import javax.tools.ToolProvider;
501.65 +import org.apache.lucene.document.Document;
501.66 +import org.apache.lucene.index.IndexReader;
501.67 +import org.apache.lucene.index.Term;
501.68 +import org.apache.lucene.search.Collector;
501.69 +import org.apache.lucene.search.IndexSearcher;
501.70 +import org.apache.lucene.search.Query;
501.71 +import org.apache.lucene.search.Searcher;
501.72 +import org.apache.lucene.search.TermQuery;
501.73 +import org.apache.lucene.store.FSDirectory;
501.74 +import org.netbeans.modules.jackpot30.impl.duplicates.indexing.DuplicatesIndex;
501.75 +import org.netbeans.modules.jackpot30.impl.indexing.AbstractLuceneIndex.BitSetCollector;
501.76 +import org.netbeans.modules.jackpot30.impl.indexing.Cache;
501.77 +import org.netbeans.modules.jackpot30.impl.indexing.FileBasedIndex;
501.78 +import org.netbeans.modules.java.hints.jackpot.impl.Utilities;
501.79 +import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch;
501.80 +import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch.BulkPattern;
501.81 +import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
501.82 +import org.netbeans.modules.java.hints.jackpot.spi.HintDescription.AdditionalQueryConstraints;
501.83 +import org.netbeans.modules.java.hints.jackpot.spi.PatternConvertor;
501.84 +import org.netbeans.modules.java.hints.jackpot.spi.Trigger.PatternDescription;
501.85 +
501.86 +/**
501.87 + *
501.88 + * @author lahvac
501.89 + */
501.90 +public class StandaloneFinder {
501.91 +
501.92 + public static Collection<? extends String> findCandidates(File sourceRoot, String pattern) throws IOException {
501.93 + BulkPattern bulkPattern = preparePattern(pattern, null);
501.94 +
501.95 + return FileBasedIndex.get(sourceRoot.toURI().toURL()).findCandidates(bulkPattern);
501.96 + }
501.97 +
501.98 + public static int[] findCandidateOccurrenceSpans(File sourceRoot, String relativePath, String pattern) throws IOException {
501.99 + BulkPattern bulkPattern = preparePattern(pattern, null);
501.100 + CharSequence source = FileBasedIndex.get(sourceRoot.toURI().toURL()).getSourceCode(relativePath).toString().replaceAll("\r\n", "\n");
501.101 + JavacTaskImpl jti = prepareJavacTaskImpl();
501.102 + CompilationUnitTree cut = jti.parse(new JFOImpl(source)).iterator().next();
501.103 + Collection<TreePath> paths = new LinkedList<TreePath>();
501.104 +
501.105 + for (Collection<TreePath> c : BulkSearch.getDefault().match(null, new TreePath(cut), bulkPattern).values()) {
501.106 + paths.addAll(c);
501.107 + }
501.108 +
501.109 + Trees t = Trees.instance(jti);
501.110 + int[] result = new int[2 * paths.size()];
501.111 + int i = 0;
501.112 +
501.113 + for (TreePath tp : paths) {
501.114 + result[i++] = (int) t.getSourcePositions().getStartPosition(cut, tp.getLeaf());
501.115 + result[i++] = (int) t.getSourcePositions().getEndPosition(cut, tp.getLeaf());
501.116 + }
501.117 +
501.118 + return result;
501.119 + }
501.120 +
501.121 + public static Collection<Diagnostic<? extends JavaFileObject>> parseAndReportErrors(String pattern) {
501.122 + Collection<Diagnostic<? extends JavaFileObject>> errors = new LinkedList<Diagnostic<? extends JavaFileObject>>();
501.123 +
501.124 + preparePattern(pattern, errors);
501.125 +
501.126 + return errors;
501.127 + }
501.128 +
501.129 + public static Map<String, Collection<? extends String>> containsHash(File sourceRoot, Iterable<? extends String> hashes) throws IOException {
501.130 + File cacheRoot = Cache.findCache(DuplicatesIndex.NAME, DuplicatesIndex.VERSION).findCacheRoot(sourceRoot.toURI().toURL());
501.131 + File dir = new File(cacheRoot, "fulltext");
501.132 +
501.133 + if (dir.listFiles() != null && dir.listFiles().length > 0) {
501.134 + IndexReader reader = IndexReader.open(FSDirectory.open(dir), true);
501.135 + Map<String, Collection<? extends String>> result = new HashMap<String, Collection<? extends String>>();
501.136 +
501.137 + for (String hash : hashes) {
501.138 + Collection<String> found = new LinkedList<String>();
501.139 + Query query = new TermQuery(new Term("generalized", hash));
501.140 + Searcher s = new IndexSearcher(reader);
501.141 + BitSet matchingDocuments = new BitSet(reader.maxDoc());
501.142 + Collector c = new BitSetCollector(matchingDocuments);
501.143 +
501.144 + s.search(query, c);
501.145 +
501.146 + for (int docNum = matchingDocuments.nextSetBit(0); docNum >= 0; docNum = matchingDocuments.nextSetBit(docNum + 1)) {
501.147 + final Document doc = reader.document(docNum);
501.148 +
501.149 + found.add(doc.getField("path").stringValue());
501.150 + }
501.151 +
501.152 + result.put(hash, found);
501.153 + }
501.154 +
501.155 + return result;
501.156 + }
501.157 +
501.158 + return Collections.emptyMap();
501.159 + }
501.160 +
501.161 + private static BulkPattern preparePattern(String pattern, Collection<Diagnostic<? extends JavaFileObject>> errors) {
501.162 + return preparePattern(PatternConvertor.create(pattern), errors);
501.163 + }
501.164 +
501.165 + //XXX: copied from BatchSearch, may be possible to merge once CompilationInfo is accessible in server mode
501.166 + private static BulkPattern preparePattern(final Iterable<? extends HintDescription> patterns, Collection<Diagnostic<? extends JavaFileObject>> errors) {
501.167 + JavacTaskImpl javac = prepareJavacTaskImpl();
501.168 + Collection<String> code = new LinkedList<String>();
501.169 + Collection<Tree> trees = new LinkedList<Tree>();
501.170 + Collection<AdditionalQueryConstraints> additionalConstraints = new LinkedList<AdditionalQueryConstraints>();
501.171 +
501.172 + for (HintDescription pattern : patterns) {
501.173 + String textPattern = ((PatternDescription) pattern.getTrigger()).getPattern();
501.174 +
501.175 + code.add(textPattern);
501.176 + trees.add(Utilities.parseAndAttribute(javac, textPattern, errors));
501.177 + additionalConstraints.add(pattern.getAdditionalConstraints());
501.178 + }
501.179 +
501.180 + return BulkSearch.getDefault().create(code, trees, additionalConstraints);
501.181 + }
501.182 +
501.183 + private static JavacTaskImpl prepareJavacTaskImpl() {
501.184 + final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
501.185 + final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
501.186 +
501.187 + assert tool != null;
501.188 +
501.189 + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, Arrays.asList("-bootclasspath", bootPath, "-Xjcov"), null, Collections.<JavaFileObject>emptyList());
501.190 +
501.191 + return ct;
501.192 + }
501.193 +
501.194 + private static final class JFOImpl extends SimpleJavaFileObject {
501.195 + private final CharSequence code;
501.196 + public JFOImpl(CharSequence code) {
501.197 + super(URI.create(""), Kind.SOURCE);
501.198 + this.code = code;
501.199 + }
501.200 + @Override
501.201 + public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
501.202 + return code;
501.203 + }
501.204 + }
501.205 +}
502.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
502.2 +++ b/sandbox/old-modules/server/indexer/src/org/netbeans/modules/jackpot30/server/indexer/StandaloneIndexer.java Mon Mar 12 21:10:10 2012 +0100
502.3 @@ -0,0 +1,169 @@
502.4 +/*
502.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
502.6 + *
502.7 + * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
502.8 + *
502.9 + * The contents of this file are subject to the terms of either the GNU
502.10 + * General Public License Version 2 only ("GPL") or the Common
502.11 + * Development and Distribution License("CDDL") (collectively, the
502.12 + * "License"). You may not use this file except in compliance with the
502.13 + * License. You can obtain a copy of the License at
502.14 + * http://www.netbeans.org/cddl-gplv2.html
502.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
502.16 + * specific language governing permissions and limitations under the
502.17 + * License. When distributing the software, include this License Header
502.18 + * Notice in each file and include the License file at
502.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
502.20 + * particular file as subject to the "Classpath" exception as provided
502.21 + * by Sun in the GPL Version 2 section of the License file that
502.22 + * accompanied this code. If applicable, add the following below the
502.23 + * License Header, with the fields enclosed by brackets [] replaced by
502.24 + * your own identifying information:
502.25 + * "Portions Copyrighted [year] [name of copyright owner]"
502.26 + *
502.27 + * If you wish your version of this file to be governed by only the CDDL
502.28 + * or only the GPL Version 2, indicate your decision by adding
502.29 + * "[Contributor] elects to include this software in this distribution
502.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
502.31 + * single choice of license, a recipient has the option to distribute
502.32 + * your version of this file under either the CDDL, the GPL Version 2 or
502.33 + * to extend the choice of license to its licensees as provided above.
502.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
502.35 + * Version 2 license, then the option applies only if the new code is
502.36 + * made subject to such option by the copyright holder.
502.37 + *
502.38 + * Contributor(s):
502.39 + *
502.40 + * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
502.41 + */
502.42 +
502.43 +package org.netbeans.modules.jackpot30.server.indexer;
502.44 +
502.45 +import com.sun.source.tree.CompilationUnitTree;
502.46 +import com.sun.tools.javac.api.JavacTaskImpl;
502.47 +import java.io.BufferedReader;
502.48 +import java.io.File;
502.49 +import java.io.FileReader;
502.50 +import java.io.IOException;
502.51 +import java.util.Arrays;
502.52 +import java.util.Collection;
502.53 +import java.util.Collections;
502.54 +import java.util.LinkedList;
502.55 +import java.util.logging.Level;
502.56 +import java.util.logging.Logger;
502.57 +import javax.tools.Diagnostic;
502.58 +import javax.tools.DiagnosticListener;
502.59 +import javax.tools.JavaCompiler;
502.60 +import javax.tools.JavaFileObject;
502.61 +import javax.tools.StandardJavaFileManager;
502.62 +import javax.tools.StandardLocation;
502.63 +import javax.tools.ToolProvider;
502.64 +import org.netbeans.modules.jackpot30.impl.duplicates.indexing.DuplicatesIndex;
502.65 +import org.netbeans.modules.jackpot30.impl.indexing.FileBasedIndex;
502.66 +import org.netbeans.modules.jackpot30.impl.indexing.Index;
502.67 +import org.netbeans.modules.jackpot30.impl.indexing.Index.IndexWriter;
502.68 +import org.netbeans.modules.jackpot30.impl.indexing.IndexInfo;
502.69 +
502.70 +/**
502.71 + *
502.72 + * @author lahvac
502.73 + */
502.74 +public class StandaloneIndexer {
502.75 +
502.76 + public static void index(File root, boolean duplicatesIndex, boolean storeSources, String modified, String removed) throws IOException {
502.77 + Index index = FileBasedIndex.create(root.toURI().toURL(), storeSources);
502.78 + IndexInfo ii = index.getIndexInfo();
502.79 + boolean clearIndexing = ii.totalFiles < 0 || ii.majorVersion != FileBasedIndex.MAJOR_VERSION || ii.minorVersion != FileBasedIndex.MINOR_VERSION;
502.80 + IndexWriter w = index.openForWriting();
502.81 + DuplicatesIndex.IndexWriter dw = duplicatesIndex ? DuplicatesIndex.get(root.toURI().toURL()).openForWriting() : null;
502.82 +
502.83 + try {
502.84 + StandaloneIndexer i = new StandaloneIndexer();
502.85 +
502.86 + if (!clearIndexing && modified != null && removed != null) {
502.87 + i.doIndex(w, dw, root, modified, removed);
502.88 + } else {
502.89 + w.clear();
502.90 + i.doIndex(w, dw, root);
502.91 + }
502.92 + } finally {
502.93 + w.close();
502.94 + if (dw != null) {
502.95 + dw.close();
502.96 + }
502.97 + }
502.98 + }
502.99 +
502.100 + private void doIndex(IndexWriter w, DuplicatesIndex.IndexWriter dw, File fileOrDir) throws IOException {
502.101 + if (fileOrDir.isDirectory()) {
502.102 + for (File f : fileOrDir.listFiles()) {
502.103 + doIndex(w, dw, f);
502.104 + }
502.105 + } else {
502.106 + indexFile(w, dw, fileOrDir);
502.107 + }
502.108 + }
502.109 +
502.110 + private void doIndex(IndexWriter w, DuplicatesIndex.IndexWriter dw, File root, String modified, String removed) throws IOException {
502.111 + for (String r : read(removed)) {
502.112 + w.remove(r);
502.113 + if (dw != null) dw.remove(r);
502.114 + }
502.115 +
502.116 + for (String m : read(modified)) {
502.117 + indexFile(w, dw, new File(root, m));
502.118 + }
502.119 + }
502.120 +
502.121 + private void indexFile(IndexWriter w, DuplicatesIndex.IndexWriter dw, File source) throws IOException {
502.122 + if (!source.getName().endsWith(".java"))
502.123 + return ;
502.124 +
502.125 + final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
502.126 + final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
502.127 + assert tool != null;
502.128 +
502.129 + DiagnosticListener<JavaFileObject> devNull = new DiagnosticListener<JavaFileObject>() {
502.130 + public void report(Diagnostic<? extends JavaFileObject> diagnostic) {}
502.131 + };
502.132 + StandardJavaFileManager m = tool.getStandardFileManager(devNull, null, null);
502.133 +
502.134 + m.setLocation(StandardLocation.CLASS_PATH, Collections.<File>emptyList());
502.135 + m.setLocation(StandardLocation.SOURCE_PATH, Collections.<File>emptyList());
502.136 +
502.137 + Iterable<? extends JavaFileObject> fos = m.getJavaFileObjects(source);
502.138 + JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, null, devNull, Arrays.asList("-bootclasspath", bootPath), null, fos);
502.139 + CompilationUnitTree cut = ct.parse().iterator().next();
502.140 +
502.141 + w.record(source.toURI().toURL(), cut, null);
502.142 +
502.143 + if (dw != null) {
502.144 + ct.analyze(ct.enter(Collections.singletonList(cut)));
502.145 +
502.146 + dw.record(ct, source.toURI().toURL(), cut);
502.147 + }
502.148 + }
502.149 +
502.150 + private static Iterable<? extends String> read(String file) throws IOException {
502.151 + Collection<String> result = new LinkedList<String>();
502.152 + BufferedReader r = new BufferedReader(new FileReader(file));
502.153 +
502.154 + try {
502.155 + String line;
502.156 +
502.157 + while ((line = r.readLine()) != null) {
502.158 + if (!line.isEmpty()) {
502.159 + result.add(line);
502.160 + }
502.161 + }
502.162 + } finally {
502.163 + try {
502.164 + r.close();
502.165 + } catch (IOException ex) {
502.166 + Logger.getLogger(StandaloneIndexer.class.getName()).log(Level.SEVERE, null, ex);
502.167 + }
502.168 + }
502.169 +
502.170 + return result;
502.171 + }
502.172 +}
503.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
503.2 +++ b/sandbox/old-modules/server/indexer/test/org/netbeans/modules/jackpot30/server/indexer/IndexTest.java Mon Mar 12 21:10:10 2012 +0100
503.3 @@ -0,0 +1,96 @@
503.4 +/*
503.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
503.6 + *
503.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
503.8 + *
503.9 + * The contents of this file are subject to the terms of either the GNU
503.10 + * General Public License Version 2 only ("GPL") or the Common
503.11 + * Development and Distribution License("CDDL") (collectively, the
503.12 + * "License"). You may not use this file except in compliance with the
503.13 + * License. You can obtain a copy of the License at
503.14 + * http://www.netbeans.org/cddl-gplv2.html
503.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
503.16 + * specific language governing permissions and limitations under the
503.17 + * License. When distributing the software, include this License Header
503.18 + * Notice in each file and include the License file at
503.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
503.20 + * particular file as subject to the "Classpath" exception as provided
503.21 + * by Sun in the GPL Version 2 section of the License file that
503.22 + * accompanied this code. If applicable, add the following below the
503.23 + * License Header, with the fields enclosed by brackets [] replaced by
503.24 + * your own identifying information:
503.25 + * "Portions Copyrighted [year] [name of copyright owner]"
503.26 + *
503.27 + * If you wish your version of this file to be governed by only the CDDL
503.28 + * or only the GPL Version 2, indicate your decision by adding
503.29 + * "[Contributor] elects to include this software in this distribution
503.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
503.31 + * single choice of license, a recipient has the option to distribute
503.32 + * your version of this file under either the CDDL, the GPL Version 2 or
503.33 + * to extend the choice of license to its licensees as provided above.
503.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
503.35 + * Version 2 license, then the option applies only if the new code is
503.36 + * made subject to such option by the copyright holder.
503.37 + *
503.38 + * Contributor(s):
503.39 + *
503.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
503.41 + */
503.42 +
503.43 +package org.netbeans.modules.jackpot30.server.indexer;
503.44 +
503.45 +import java.io.File;
503.46 +import java.io.IOException;
503.47 +import junit.framework.TestCase;
503.48 +
503.49 +/**
503.50 + *
503.51 + * @author lahvac
503.52 + */
503.53 +public class IndexTest extends TestCase {
503.54 +
503.55 + public IndexTest(String name) {
503.56 + super(name);
503.57 + }
503.58 +
503.59 + public void testCmdLine() throws IOException {
503.60 + assertCmdLineOk("/foo", false, false, null, null, "/foo", "/cache");
503.61 + assertCmdLineOk("/foo", false, false, "/modified.list", "/removed.list", "/foo", "/cache", "/modified.list", "/removed.list");
503.62 + assertCmdLineOk("/foo", true, false, null, null, Index.PARAM_CONSTRUCT_DUPLICATES_INDEX, "/foo", "/cache");
503.63 + assertCmdLineOk("/foo", true, false, "/modified.list", "/removed.list", Index.PARAM_CONSTRUCT_DUPLICATES_INDEX, "/foo", "/cache", "/modified.list", "/removed.list");
503.64 + assertCmdLineOk("/foo", false, true, null, null, Index.PARAM_STORE_SOURCES, "/foo", "/cache");
503.65 + assertCmdLineOk("/foo", false, true, "/modified.list", "/removed.list", Index.PARAM_STORE_SOURCES, "/foo", "/cache", "/modified.list", "/removed.list");
503.66 + assertCmdLineOk("/foo", true, true, null, null, Index.PARAM_CONSTRUCT_DUPLICATES_INDEX, Index.PARAM_STORE_SOURCES, "/foo", "/cache");
503.67 + assertCmdLineOk("/foo", true, true, "/modified.list", "/removed.list", Index.PARAM_CONSTRUCT_DUPLICATES_INDEX, Index.PARAM_STORE_SOURCES, "/foo", "/cache", "/modified.list", "/removed.list");
503.68 + assertCmdLineFailed();
503.69 + assertCmdLineFailed("/foo");
503.70 + }
503.71 +
503.72 + private static void assertCmdLineOk(final String rootGolden, final boolean duplicatesIndexGolden, final boolean storeSourcesGolden, final String modifiedGolden, final String removedGolden, String... cmdLine) throws IOException {
503.73 + new Index() {
503.74 + @Override
503.75 + protected void invokeIndexer(File root, boolean duplicatesIndex, boolean storeSources, String modified, String removed) throws IOException {
503.76 + assertEquals(rootGolden, root.getPath());
503.77 + assertEquals(duplicatesIndexGolden, duplicatesIndex);
503.78 + assertEquals(storeSourcesGolden, storeSources);
503.79 + assertEquals(modifiedGolden, modified);
503.80 + assertEquals(removedGolden, removed);
503.81 + }
503.82 + @Override
503.83 + protected void printHelp() {
503.84 + fail();
503.85 + }
503.86 + }.index(cmdLine);
503.87 + }
503.88 +
503.89 + private static void assertCmdLineFailed(String... cmdLine) throws IOException {
503.90 + new Index() {
503.91 + @Override
503.92 + protected void invokeIndexer(File root, boolean duplicatesIndex, boolean storeSources, String modified, String removed) throws IOException {
503.93 + fail();
503.94 + }
503.95 + @Override
503.96 + protected void printHelp() {}
503.97 + }.index(cmdLine);
503.98 + }
503.99 +}
503.100 \ No newline at end of file
504.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
504.2 +++ b/sandbox/old-modules/server/indexer/test/org/netbeans/modules/jackpot30/server/indexer/LargeScaleTester.java Mon Mar 12 21:10:10 2012 +0100
504.3 @@ -0,0 +1,147 @@
504.4 +/*
504.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
504.6 + *
504.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
504.8 + *
504.9 + * The contents of this file are subject to the terms of either the GNU
504.10 + * General Public License Version 2 only ("GPL") or the Common
504.11 + * Development and Distribution License("CDDL") (collectively, the
504.12 + * "License"). You may not use this file except in compliance with the
504.13 + * License. You can obtain a copy of the License at
504.14 + * http://www.netbeans.org/cddl-gplv2.html
504.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
504.16 + * specific language governing permissions and limitations under the
504.17 + * License. When distributing the software, include this License Header
504.18 + * Notice in each file and include the License file at
504.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
504.20 + * particular file as subject to the "Classpath" exception as provided
504.21 + * by Sun in the GPL Version 2 section of the License file that
504.22 + * accompanied this code. If applicable, add the following below the
504.23 + * License Header, with the fields enclosed by brackets [] replaced by
504.24 + * your own identifying information:
504.25 + * "Portions Copyrighted [year] [name of copyright owner]"
504.26 + *
504.27 + * If you wish your version of this file to be governed by only the CDDL
504.28 + * or only the GPL Version 2, indicate your decision by adding
504.29 + * "[Contributor] elects to include this software in this distribution
504.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
504.31 + * single choice of license, a recipient has the option to distribute
504.32 + * your version of this file under either the CDDL, the GPL Version 2 or
504.33 + * to extend the choice of license to its licensees as provided above.
504.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
504.35 + * Version 2 license, then the option applies only if the new code is
504.36 + * made subject to such option by the copyright holder.
504.37 + *
504.38 + * Contributor(s):
504.39 + *
504.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
504.41 + */
504.42 +
504.43 +package org.netbeans.modules.jackpot30.server.indexer;
504.44 +
504.45 +import java.io.File;
504.46 +import java.io.IOException;
504.47 +import java.util.logging.Handler;
504.48 +import java.util.logging.Level;
504.49 +import java.util.logging.LogRecord;
504.50 +import java.util.logging.Logger;
504.51 +import java.util.logging.SimpleFormatter;
504.52 +import junit.framework.TestCase;
504.53 +import org.netbeans.modules.jackpot30.impl.indexing.Cache;
504.54 +import org.netbeans.modules.jackpot30.impl.indexing.FileBasedIndex;
504.55 +
504.56 +/**
504.57 + *
504.58 + * @author lahvac
504.59 + */
504.60 +public class LargeScaleTester extends TestCase {
504.61 +
504.62 + public LargeScaleTester(String name) {
504.63 + super(name);
504.64 + }
504.65 +
504.66 + private static final boolean createIndex = true;
504.67 +
504.68 + private File src;
504.69 +
504.70 + public void setUp() throws Exception {
504.71 + Logger.getLogger(FileBasedIndex.class.getName()).setLevel(Level.ALL);
504.72 + Logger.getLogger(FileBasedIndex.class.getName()).addHandler(new Handler() {
504.73 + @Override
504.74 + public void publish(LogRecord record) {
504.75 + System.err.println(new SimpleFormatter().formatMessage(record));
504.76 + }
504.77 + @Override
504.78 + public void flush() {
504.79 + System.err.flush();
504.80 + }
504.81 + @Override
504.82 + public void close() throws SecurityException {}
504.83 + });
504.84 +
504.85 + File source = new File(LargeScaleTester.class.getProtectionDomain().getCodeSource().getLocation().getPath());
504.86 + File workingDirectory = new File(new File(source.getParentFile(), "wd"), this.getName());
504.87 +
504.88 + if (createIndex)
504.89 + deleteRecursively(workingDirectory);
504.90 +
504.91 + File cache = new File(workingDirectory, "cache");
504.92 + String toIndex = System.getProperty("index-folder");
504.93 +
504.94 + if (toIndex == null || !(src = new File(toIndex)).isDirectory()) {
504.95 + throw new IllegalStateException("Directory to index not correctly specified - add 'test-sys-prop.index-folder=<directory>' to private.properties");
504.96 + }
504.97 +
504.98 + Cache.setStandaloneCacheRoot(cache);
504.99 +
504.100 + if (createIndex) {
504.101 + long start = System.currentTimeMillis();
504.102 + StandaloneIndexer.index(src, false, false, null, null);
504.103 + long end = System.currentTimeMillis();
504.104 + System.err.println("indexing took: " + (end - start));
504.105 + System.err.println("cache size total: " + totalSize(cache) + ", lucene=" + totalSize(new File(cache, "s1/jackpot30/fulltext")));
504.106 + }
504.107 + }
504.108 +
504.109 + private static void deleteRecursively(File d) throws IOException {
504.110 + if (!d.exists()) return;
504.111 +
504.112 + if (d.isDirectory()) {
504.113 + for (File c : d.listFiles()) {
504.114 + deleteRecursively(c);
504.115 + }
504.116 + }
504.117 +
504.118 + if (!d.delete()) throw new IOException();
504.119 + }
504.120 +
504.121 + private static long totalSize(File d) throws IOException {
504.122 + if (!d.exists()) return 0;
504.123 +
504.124 + if (d.isDirectory()) {
504.125 + long total = 0;
504.126 +
504.127 + for (File c : d.listFiles()) {
504.128 + total += totalSize(c);
504.129 + }
504.130 +
504.131 + return total;
504.132 + } else {
504.133 + return d.length();
504.134 + }
504.135 + }
504.136 +
504.137 + public void testFind() throws Exception {
504.138 + performTest("new $type() { $mods$ $resultType $methodName($args$) { $statements$; } }");
504.139 + performTest("$1.isDirectory()");
504.140 + }
504.141 +
504.142 + private void performTest(String code) throws Exception {
504.143 + System.err.println("searching for " + code);
504.144 + long start = System.currentTimeMillis();
504.145 + System.err.println("Found occurrences: " + StandaloneFinder.findCandidates(src, code).size());
504.146 + long end = System.currentTimeMillis();
504.147 +
504.148 + System.err.println("total search time: " + (end - start));
504.149 + }
504.150 +}
505.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
505.2 +++ b/sandbox/old-modules/server/indexer/test/org/netbeans/modules/jackpot30/server/indexer/StandaloneFinderTest.java Mon Mar 12 21:10:10 2012 +0100
505.3 @@ -0,0 +1,154 @@
505.4 +/*
505.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
505.6 + *
505.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
505.8 + *
505.9 + * The contents of this file are subject to the terms of either the GNU
505.10 + * General Public License Version 2 only ("GPL") or the Common
505.11 + * Development and Distribution License("CDDL") (collectively, the
505.12 + * "License"). You may not use this file except in compliance with the
505.13 + * License. You can obtain a copy of the License at
505.14 + * http://www.netbeans.org/cddl-gplv2.html
505.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
505.16 + * specific language governing permissions and limitations under the
505.17 + * License. When distributing the software, include this License Header
505.18 + * Notice in each file and include the License file at
505.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
505.20 + * particular file as subject to the "Classpath" exception as provided
505.21 + * by Sun in the GPL Version 2 section of the License file that
505.22 + * accompanied this code. If applicable, add the following below the
505.23 + * License Header, with the fields enclosed by brackets [] replaced by
505.24 + * your own identifying information:
505.25 + * "Portions Copyrighted [year] [name of copyright owner]"
505.26 + *
505.27 + * If you wish your version of this file to be governed by only the CDDL
505.28 + * or only the GPL Version 2, indicate your decision by adding
505.29 + * "[Contributor] elects to include this software in this distribution
505.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
505.31 + * single choice of license, a recipient has the option to distribute
505.32 + * your version of this file under either the CDDL, the GPL Version 2 or
505.33 + * to extend the choice of license to its licensees as provided above.
505.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
505.35 + * Version 2 license, then the option applies only if the new code is
505.36 + * made subject to such option by the copyright holder.
505.37 + *
505.38 + * Contributor(s):
505.39 + *
505.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
505.41 + */
505.42 +
505.43 +package org.netbeans.modules.jackpot30.server.indexer;
505.44 +
505.45 +import java.io.ByteArrayInputStream;
505.46 +import java.io.File;
505.47 +import java.io.FileOutputStream;
505.48 +import java.io.IOException;
505.49 +import java.io.InputStream;
505.50 +import java.util.ArrayList;
505.51 +import java.util.Arrays;
505.52 +import java.util.HashSet;
505.53 +import java.util.LinkedList;
505.54 +import java.util.List;
505.55 +import junit.framework.Assert;
505.56 +import junit.framework.TestCase;
505.57 +import org.netbeans.modules.jackpot30.impl.indexing.Cache;
505.58 +
505.59 +/**
505.60 + *
505.61 + * @author lahvac
505.62 + */
505.63 +public class StandaloneFinderTest extends TestCase {
505.64 +
505.65 + public StandaloneFinderTest(String name) {
505.66 + super(name);
505.67 + }
505.68 +
505.69 + private File src;
505.70 +
505.71 + public void setUp() throws Exception {
505.72 + File source = new File(StandaloneFinderTest.class.getProtectionDomain().getCodeSource().getLocation().getPath());
505.73 + File workingDirectory = new File(new File(source.getParentFile(), "wd"), this.getName());
505.74 +
505.75 + deleteRecursively(workingDirectory);
505.76 +
505.77 + File cache = new File(workingDirectory, "cache");
505.78 +
505.79 + src = new File(workingDirectory, "src");
505.80 +
505.81 + Cache.setStandaloneCacheRoot(cache);
505.82 +
505.83 + copyStringToFile(new File(src, "test/Test1.java"), "package test; public class Test {private void test() { new java.io.File(\"\").isDirectory(); } }");
505.84 + copyStringToFile(new File(src, "test/TestLambda.java"), "package test; public class Test1 { private void test() { Runnable r = new Runnable() { public void run() { System.err.println(); } }; } }");
505.85 +
505.86 + StandaloneIndexer.index(src, false, false, null, null);
505.87 + }
505.88 +
505.89 + public final static void copyStringToFile (File f, String content) throws Exception {
505.90 + f.getParentFile().mkdirs();
505.91 +
505.92 + FileOutputStream os = new FileOutputStream(f);
505.93 + InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
505.94 + int read;
505.95 + while ((read = is.read()) != (-1)) {
505.96 + os.write(read);
505.97 + }
505.98 + os.close ();
505.99 + is.close();
505.100 + }
505.101 +
505.102 + private static List<Integer> toIntegerList(int[] arr) {
505.103 + List<Integer> res = new ArrayList<Integer>(arr.length);
505.104 +
505.105 + for (int e : arr) {
505.106 + res.add(e);
505.107 + }
505.108 +
505.109 + return res;
505.110 + }
505.111 +
505.112 + private static void deleteRecursively(File d) throws IOException {
505.113 + if (!d.exists()) return;
505.114 +
505.115 + if (d.isDirectory()) {
505.116 + for (File c : d.listFiles()) {
505.117 + deleteRecursively(c);
505.118 + }
505.119 + }
505.120 +
505.121 + if (!d.delete()) throw new IOException();
505.122 + }
505.123 +
505.124 + public void testFindSpans() throws Exception {
505.125 + Assert.assertEquals(Arrays.asList(55, 89), toIntegerList(StandaloneFinder.findCandidateOccurrenceSpans(src, "test/Test1.java", "$1.isDirectory()")));
505.126 + }
505.127 +
505.128 + public void testMultiplePatterns() throws Exception {
505.129 + String patterns = "$1.isDirectory();; new java.io.File($1);;";
505.130 + Assert.assertEquals(Arrays.asList("test/Test1.java"), new LinkedList<String>(StandaloneFinder.findCandidates(src, patterns)));
505.131 + Assert.assertEquals(Arrays.asList(55, 75, 55, 89), toIntegerList(StandaloneFinder.findCandidateOccurrenceSpans(src, "test/Test1.java", patterns)));
505.132 + }
505.133 +
505.134 + public void testUpdate() throws Exception {
505.135 + File modified = new File(src.getParentFile(), "modified");
505.136 + File removed = new File(src.getParentFile(), "removed");
505.137 +
505.138 + copyStringToFile(removed, "test/Test1.java");
505.139 + copyStringToFile(modified, "test/Test2.java\ntest/Test3.java");
505.140 +
505.141 + new File(src, "test/Test1.java").delete();
505.142 +
505.143 + copyStringToFile(new File(src, "test/Test2.java"), "package test; public class Test {private void test() { new java.io.File(\"\").isDirectory(); } }");
505.144 + copyStringToFile(new File(src, "test/Test3.java"), "package test; public class Test {private void test() { new java.io.File(\"\").isDirectory(); } }");
505.145 +
505.146 + StandaloneIndexer.index(src, false, false, modified.getAbsolutePath(), removed.getAbsolutePath());
505.147 +
505.148 + String patterns = "$1.isDirectory();; new java.io.File($1);;";
505.149 + Assert.assertEquals(new HashSet<String>(Arrays.asList("test/Test2.java", "test/Test3.java")), new HashSet<String>(StandaloneFinder.findCandidates(src, patterns)));
505.150 + }
505.151 +
505.152 + public void testLambdaPattern() throws Exception {
505.153 + String patterns = "new $type() {\n $mods$ $resultType $methodName($args$) {\n $statements$;\n }\n }\n";
505.154 + Assert.assertEquals(Arrays.asList("test/TestLambda.java"), new LinkedList<String>(StandaloneFinder.findCandidates(src, patterns)));
505.155 + Assert.assertEquals(Arrays.asList(70, 132), toIntegerList(StandaloneFinder.findCandidateOccurrenceSpans(src, "test/TestLambda.java", patterns)));
505.156 + }
505.157 +}
506.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
506.2 +++ b/sandbox/old-modules/server/web.api/build.xml Mon Mar 12 21:10:10 2012 +0100
506.3 @@ -0,0 +1,75 @@
506.4 +<?xml version="1.0" encoding="UTF-8"?>
506.5 +<!-- You may freely edit this file. See commented blocks below for -->
506.6 +<!-- some examples of how to customize the build. -->
506.7 +<!-- (If you delete it and reopen the project it will be recreated.) -->
506.8 +<!-- By default, only the Clean and Build commands use this build script. -->
506.9 +<!-- Commands such as Run, Debug, and Test only use this build script if -->
506.10 +<!-- the Compile on Save feature is turned off for the project. -->
506.11 +<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
506.12 +<!-- in the project's Project Properties dialog box.-->
506.13 +<project name="web.api" default="default" basedir=".">
506.14 + <description>Builds, tests, and runs the project web.api.</description>
506.15 + <import file="../download.xml"/>
506.16 + <import file="nbproject/build-impl.xml"/>
506.17 + <!--
506.18 +
506.19 + There exist several targets which are by default empty and which can be
506.20 + used for execution of your tasks. These targets are usually executed
506.21 + before and after some main targets. They are:
506.22 +
506.23 + -pre-init: called before initialization of project properties
506.24 + -post-init: called after initialization of project properties
506.25 + -pre-compile: called before javac compilation
506.26 + -post-compile: called after javac compilation
506.27 + -pre-compile-single: called before javac compilation of single file
506.28 + -post-compile-single: called after javac compilation of single file
506.29 + -pre-compile-test: called before javac compilation of JUnit tests
506.30 + -post-compile-test: called after javac compilation of JUnit tests
506.31 + -pre-compile-test-single: called before javac compilation of single JUnit test
506.32 + -post-compile-test-single: called after javac compilation of single JUunit test
506.33 + -pre-jar: called before JAR building
506.34 + -post-jar: called after JAR building
506.35 + -post-clean: called after cleaning build products
506.36 +
506.37 + (Targets beginning with '-' are not intended to be called on their own.)
506.38 +
506.39 + Example of inserting an obfuscator after compilation could look like this:
506.40 +
506.41 + <target name="-post-compile">
506.42 + <obfuscate>
506.43 + <fileset dir="${build.classes.dir}"/>
506.44 + </obfuscate>
506.45 + </target>
506.46 +
506.47 + For list of available properties check the imported
506.48 + nbproject/build-impl.xml file.
506.49 +
506.50 +
506.51 + Another way to customize the build is by overriding existing main targets.
506.52 + The targets of interest are:
506.53 +
506.54 + -init-macrodef-javac: defines macro for javac compilation
506.55 + -init-macrodef-junit: defines macro for junit execution
506.56 + -init-macrodef-debug: defines macro for class debugging
506.57 + -init-macrodef-java: defines macro for class execution
506.58 + -do-jar-with-manifest: JAR building (if you are using a manifest)
506.59 + -do-jar-without-manifest: JAR building (if you are not using a manifest)
506.60 + run: execution of project
506.61 + -javadoc-build: Javadoc generation
506.62 + test-report: JUnit report generation
506.63 +
506.64 + An example of overriding the target for project execution could look like this:
506.65 +
506.66 + <target name="run" depends="web.api-impl.jar">
506.67 + <exec dir="bin" executable="launcher.exe">
506.68 + <arg file="${dist.jar}"/>
506.69 + </exec>
506.70 + </target>
506.71 +
506.72 + Notice that the overridden target depends on the jar target and not only on
506.73 + the compile target as the regular run target does. Again, for a list of available
506.74 + properties which you can use, check the target you are overriding in the
506.75 + nbproject/build-impl.xml file.
506.76 +
506.77 + -->
506.78 +</project>
507.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
507.2 +++ b/sandbox/old-modules/server/web.api/manifest.mf Mon Mar 12 21:10:10 2012 +0100
507.3 @@ -0,0 +1,3 @@
507.4 +Manifest-Version: 1.0
507.5 +X-COMMENT: Main-Class will be added automatically by build
507.6 +
508.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
508.2 +++ b/sandbox/old-modules/server/web.api/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
508.3 @@ -0,0 +1,966 @@
508.4 +<?xml version="1.0" encoding="UTF-8"?>
508.5 +<!--
508.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
508.7 +*** EDIT ../build.xml INSTEAD ***
508.8 +
508.9 +For the purpose of easier reading the script
508.10 +is divided into following sections:
508.11 +
508.12 + - initialization
508.13 + - compilation
508.14 + - jar
508.15 + - execution
508.16 + - debugging
508.17 + - javadoc
508.18 + - junit compilation
508.19 + - junit execution
508.20 + - junit debugging
508.21 + - applet
508.22 + - cleanup
508.23 +
508.24 + -->
508.25 +<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="web.api-impl">
508.26 + <fail message="Please build using Ant 1.7.1 or higher.">
508.27 + <condition>
508.28 + <not>
508.29 + <antversion atleast="1.7.1"/>
508.30 + </not>
508.31 + </condition>
508.32 + </fail>
508.33 + <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
508.34 + <!--
508.35 + ======================
508.36 + INITIALIZATION SECTION
508.37 + ======================
508.38 + -->
508.39 + <target name="-pre-init">
508.40 + <!-- Empty placeholder for easier customization. -->
508.41 + <!-- You can override this target in the ../build.xml file. -->
508.42 + </target>
508.43 + <target depends="-pre-init" name="-init-private">
508.44 + <property file="nbproject/private/config.properties"/>
508.45 + <property file="nbproject/private/configs/${config}.properties"/>
508.46 + <property file="nbproject/private/private.properties"/>
508.47 + </target>
508.48 + <target name="-pre-init-libraries">
508.49 + <property location="../lib/nblibraries.properties" name="libraries.path"/>
508.50 + <dirname file="${libraries.path}" property="libraries.dir.nativedirsep"/>
508.51 + <pathconvert dirsep="/" property="libraries.dir">
508.52 + <path path="${libraries.dir.nativedirsep}"/>
508.53 + </pathconvert>
508.54 + <basename file="${libraries.path}" property="libraries.basename" suffix=".properties"/>
508.55 + <available file="${libraries.dir}/${libraries.basename}-private.properties" property="private.properties.available"/>
508.56 + </target>
508.57 + <target depends="-pre-init-libraries" if="private.properties.available" name="-init-private-libraries">
508.58 + <loadproperties encoding="ISO-8859-1" srcfile="${libraries.dir}/${libraries.basename}-private.properties">
508.59 + <filterchain>
508.60 + <replacestring from="$${base}" to="${libraries.dir}"/>
508.61 + <escapeunicode/>
508.62 + </filterchain>
508.63 + </loadproperties>
508.64 + </target>
508.65 + <target depends="-pre-init,-init-private,-init-private-libraries" name="-init-libraries">
508.66 + <loadproperties encoding="ISO-8859-1" srcfile="${libraries.path}">
508.67 + <filterchain>
508.68 + <replacestring from="$${base}" to="${libraries.dir}"/>
508.69 + <escapeunicode/>
508.70 + </filterchain>
508.71 + </loadproperties>
508.72 + </target>
508.73 + <target depends="-pre-init,-init-private,-init-libraries" name="-init-user">
508.74 + <property file="${user.properties.file}"/>
508.75 + <!-- The two properties below are usually overridden -->
508.76 + <!-- by the active platform. Just a fallback. -->
508.77 + <property name="default.javac.source" value="1.4"/>
508.78 + <property name="default.javac.target" value="1.4"/>
508.79 + </target>
508.80 + <target depends="-pre-init,-init-private,-init-libraries,-init-user" name="-init-project">
508.81 + <property file="nbproject/configs/${config}.properties"/>
508.82 + <property file="nbproject/project.properties"/>
508.83 + </target>
508.84 + <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-init-macrodef-property" name="-do-init">
508.85 + <available file="${manifest.file}" property="manifest.available"/>
508.86 + <available file="${application.splash}" property="splashscreen.available"/>
508.87 + <condition property="main.class.available">
508.88 + <and>
508.89 + <isset property="main.class"/>
508.90 + <not>
508.91 + <equals arg1="${main.class}" arg2="" trim="true"/>
508.92 + </not>
508.93 + </and>
508.94 + </condition>
508.95 + <condition property="manifest.available+main.class">
508.96 + <and>
508.97 + <isset property="manifest.available"/>
508.98 + <isset property="main.class.available"/>
508.99 + </and>
508.100 + </condition>
508.101 + <condition property="do.mkdist">
508.102 + <and>
508.103 + <isset property="libs.CopyLibs.classpath"/>
508.104 + <not>
508.105 + <istrue value="${mkdist.disabled}"/>
508.106 + </not>
508.107 + </and>
508.108 + </condition>
508.109 + <condition property="manifest.available+main.class+mkdist.available">
508.110 + <and>
508.111 + <istrue value="${manifest.available+main.class}"/>
508.112 + <isset property="do.mkdist"/>
508.113 + </and>
508.114 + </condition>
508.115 + <condition property="manifest.available+main.class+mkdist.available+splashscreen.available">
508.116 + <and>
508.117 + <istrue value="${manifest.available+main.class+mkdist.available}"/>
508.118 + <istrue value="${splashscreen.available}"/>
508.119 + </and>
508.120 + </condition>
508.121 + <condition property="manifest.available+main.class+mkdist.available+splashscreen.available">
508.122 + <and>
508.123 + <istrue value="${manifest.available+main.class+mkdist.available}"/>
508.124 + <istrue value="${splashscreen.available}"/>
508.125 + </and>
508.126 + </condition>
508.127 + <condition property="manifest.available+mkdist.available">
508.128 + <and>
508.129 + <istrue value="${manifest.available}"/>
508.130 + <isset property="do.mkdist"/>
508.131 + </and>
508.132 + </condition>
508.133 + <condition property="manifest.available-mkdist.available">
508.134 + <or>
508.135 + <istrue value="${manifest.available}"/>
508.136 + <isset property="do.mkdist"/>
508.137 + </or>
508.138 + </condition>
508.139 + <condition property="manifest.available+main.class-mkdist.available">
508.140 + <or>
508.141 + <istrue value="${manifest.available+main.class}"/>
508.142 + <isset property="do.mkdist"/>
508.143 + </or>
508.144 + </condition>
508.145 + <condition property="have.tests">
508.146 + <or>
508.147 + <available file="${test.src.dir}"/>
508.148 + </or>
508.149 + </condition>
508.150 + <condition property="have.sources">
508.151 + <or>
508.152 + <available file="${src.dir}"/>
508.153 + </or>
508.154 + </condition>
508.155 + <condition property="netbeans.home+have.tests">
508.156 + <and>
508.157 + <isset property="netbeans.home"/>
508.158 + <isset property="have.tests"/>
508.159 + </and>
508.160 + </condition>
508.161 + <condition property="no.javadoc.preview">
508.162 + <and>
508.163 + <isset property="javadoc.preview"/>
508.164 + <isfalse value="${javadoc.preview}"/>
508.165 + </and>
508.166 + </condition>
508.167 + <property name="run.jvmargs" value=""/>
508.168 + <property name="javac.compilerargs" value=""/>
508.169 + <property name="work.dir" value="${basedir}"/>
508.170 + <condition property="no.deps">
508.171 + <and>
508.172 + <istrue value="${no.dependencies}"/>
508.173 + </and>
508.174 + </condition>
508.175 + <property name="javac.debug" value="true"/>
508.176 + <property name="javadoc.preview" value="true"/>
508.177 + <property name="application.args" value=""/>
508.178 + <property name="source.encoding" value="${file.encoding}"/>
508.179 + <property name="runtime.encoding" value="${source.encoding}"/>
508.180 + <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
508.181 + <and>
508.182 + <isset property="javadoc.encoding"/>
508.183 + <not>
508.184 + <equals arg1="${javadoc.encoding}" arg2=""/>
508.185 + </not>
508.186 + </and>
508.187 + </condition>
508.188 + <property name="javadoc.encoding.used" value="${source.encoding}"/>
508.189 + <property name="includes" value="**"/>
508.190 + <property name="excludes" value=""/>
508.191 + <property name="do.depend" value="false"/>
508.192 + <condition property="do.depend.true">
508.193 + <istrue value="${do.depend}"/>
508.194 + </condition>
508.195 + <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
508.196 + <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
508.197 + <length length="0" string="${endorsed.classpath}" when="greater"/>
508.198 + </condition>
508.199 + <property name="javac.fork" value="false"/>
508.200 + </target>
508.201 + <target name="-post-init">
508.202 + <!-- Empty placeholder for easier customization. -->
508.203 + <!-- You can override this target in the ../build.xml file. -->
508.204 + </target>
508.205 + <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init" name="-init-check">
508.206 + <fail unless="src.dir">Must set src.dir</fail>
508.207 + <fail unless="test.src.dir">Must set test.src.dir</fail>
508.208 + <fail unless="build.dir">Must set build.dir</fail>
508.209 + <fail unless="dist.dir">Must set dist.dir</fail>
508.210 + <fail unless="build.classes.dir">Must set build.classes.dir</fail>
508.211 + <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
508.212 + <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
508.213 + <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
508.214 + <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
508.215 + <fail unless="dist.jar">Must set dist.jar</fail>
508.216 + </target>
508.217 + <target name="-init-macrodef-property">
508.218 + <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
508.219 + <attribute name="name"/>
508.220 + <attribute name="value"/>
508.221 + <sequential>
508.222 + <property name="@{name}" value="${@{value}}"/>
508.223 + </sequential>
508.224 + </macrodef>
508.225 + </target>
508.226 + <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors">
508.227 + <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
508.228 + <attribute default="${src.dir}" name="srcdir"/>
508.229 + <attribute default="${build.classes.dir}" name="destdir"/>
508.230 + <attribute default="${javac.classpath}" name="classpath"/>
508.231 + <attribute default="${javac.processorpath}" name="processorpath"/>
508.232 + <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
508.233 + <attribute default="${includes}" name="includes"/>
508.234 + <attribute default="${excludes}" name="excludes"/>
508.235 + <attribute default="${javac.debug}" name="debug"/>
508.236 + <attribute default="${empty.dir}" name="sourcepath"/>
508.237 + <attribute default="${empty.dir}" name="gensrcdir"/>
508.238 + <element name="customize" optional="true"/>
508.239 + <sequential>
508.240 + <property location="${build.dir}/empty" name="empty.dir"/>
508.241 + <mkdir dir="${empty.dir}"/>
508.242 + <mkdir dir="@{apgeneratedsrcdir}"/>
508.243 + <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
508.244 + <src>
508.245 + <dirset dir="@{gensrcdir}" erroronmissingdir="false">
508.246 + <include name="*"/>
508.247 + </dirset>
508.248 + </src>
508.249 + <classpath>
508.250 + <path path="@{classpath}"/>
508.251 + </classpath>
508.252 + <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
508.253 + <compilerarg line="${javac.compilerargs}"/>
508.254 + <compilerarg value="-processorpath"/>
508.255 + <compilerarg path="@{processorpath}"/>
508.256 + <compilerarg line="${ap.processors.internal}"/>
508.257 + <compilerarg value="-s"/>
508.258 + <compilerarg path="@{apgeneratedsrcdir}"/>
508.259 + <compilerarg line="${ap.proc.none.internal}"/>
508.260 + <customize/>
508.261 + </javac>
508.262 + </sequential>
508.263 + </macrodef>
508.264 + </target>
508.265 + <target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal">
508.266 + <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
508.267 + <attribute default="${src.dir}" name="srcdir"/>
508.268 + <attribute default="${build.classes.dir}" name="destdir"/>
508.269 + <attribute default="${javac.classpath}" name="classpath"/>
508.270 + <attribute default="${javac.processorpath}" name="processorpath"/>
508.271 + <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
508.272 + <attribute default="${includes}" name="includes"/>
508.273 + <attribute default="${excludes}" name="excludes"/>
508.274 + <attribute default="${javac.debug}" name="debug"/>
508.275 + <attribute default="${empty.dir}" name="sourcepath"/>
508.276 + <attribute default="${empty.dir}" name="gensrcdir"/>
508.277 + <element name="customize" optional="true"/>
508.278 + <sequential>
508.279 + <property location="${build.dir}/empty" name="empty.dir"/>
508.280 + <mkdir dir="${empty.dir}"/>
508.281 + <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
508.282 + <src>
508.283 + <dirset dir="@{gensrcdir}" erroronmissingdir="false">
508.284 + <include name="*"/>
508.285 + </dirset>
508.286 + </src>
508.287 + <classpath>
508.288 + <path path="@{classpath}"/>
508.289 + </classpath>
508.290 + <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
508.291 + <compilerarg line="${javac.compilerargs}"/>
508.292 + <customize/>
508.293 + </javac>
508.294 + </sequential>
508.295 + </macrodef>
508.296 + </target>
508.297 + <target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac">
508.298 + <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
508.299 + <attribute default="${src.dir}" name="srcdir"/>
508.300 + <attribute default="${build.classes.dir}" name="destdir"/>
508.301 + <attribute default="${javac.classpath}" name="classpath"/>
508.302 + <sequential>
508.303 + <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
508.304 + <classpath>
508.305 + <path path="@{classpath}"/>
508.306 + </classpath>
508.307 + </depend>
508.308 + </sequential>
508.309 + </macrodef>
508.310 + <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
508.311 + <attribute default="${build.classes.dir}" name="destdir"/>
508.312 + <sequential>
508.313 + <fail unless="javac.includes">Must set javac.includes</fail>
508.314 + <pathconvert pathsep="," property="javac.includes.binary">
508.315 + <path>
508.316 + <filelist dir="@{destdir}" files="${javac.includes}"/>
508.317 + </path>
508.318 + <globmapper from="*.java" to="*.class"/>
508.319 + </pathconvert>
508.320 + <delete>
508.321 + <files includes="${javac.includes.binary}"/>
508.322 + </delete>
508.323 + </sequential>
508.324 + </macrodef>
508.325 + </target>
508.326 + <target name="-init-macrodef-junit">
508.327 + <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
508.328 + <attribute default="${includes}" name="includes"/>
508.329 + <attribute default="${excludes}" name="excludes"/>
508.330 + <attribute default="**" name="testincludes"/>
508.331 + <sequential>
508.332 + <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}">
508.333 + <batchtest todir="${build.test.results.dir}">
508.334 + <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
508.335 + <filename name="@{testincludes}"/>
508.336 + </fileset>
508.337 + </batchtest>
508.338 + <classpath>
508.339 + <path path="${run.test.classpath}"/>
508.340 + </classpath>
508.341 + <syspropertyset>
508.342 + <propertyref prefix="test-sys-prop."/>
508.343 + <mapper from="test-sys-prop.*" to="*" type="glob"/>
508.344 + </syspropertyset>
508.345 + <formatter type="brief" usefile="false"/>
508.346 + <formatter type="xml"/>
508.347 + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
508.348 + <jvmarg line="${run.jvmargs}"/>
508.349 + </junit>
508.350 + </sequential>
508.351 + </macrodef>
508.352 + </target>
508.353 + <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
508.354 + <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
508.355 + <attribute default="${main.class}" name="name"/>
508.356 + <attribute default="${debug.classpath}" name="classpath"/>
508.357 + <attribute default="" name="stopclassname"/>
508.358 + <sequential>
508.359 + <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
508.360 + <classpath>
508.361 + <path path="@{classpath}"/>
508.362 + </classpath>
508.363 + </nbjpdastart>
508.364 + </sequential>
508.365 + </macrodef>
508.366 + <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
508.367 + <attribute default="${build.classes.dir}" name="dir"/>
508.368 + <sequential>
508.369 + <nbjpdareload>
508.370 + <fileset dir="@{dir}" includes="${fix.classes}">
508.371 + <include name="${fix.includes}*.class"/>
508.372 + </fileset>
508.373 + </nbjpdareload>
508.374 + </sequential>
508.375 + </macrodef>
508.376 + </target>
508.377 + <target name="-init-debug-args">
508.378 + <property name="version-output" value="java version "${ant.java.version}"/>
508.379 + <condition property="have-jdk-older-than-1.4">
508.380 + <or>
508.381 + <contains string="${version-output}" substring="java version "1.0"/>
508.382 + <contains string="${version-output}" substring="java version "1.1"/>
508.383 + <contains string="${version-output}" substring="java version "1.2"/>
508.384 + <contains string="${version-output}" substring="java version "1.3"/>
508.385 + </or>
508.386 + </condition>
508.387 + <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
508.388 + <istrue value="${have-jdk-older-than-1.4}"/>
508.389 + </condition>
508.390 + <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
508.391 + <os family="windows"/>
508.392 + </condition>
508.393 + <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
508.394 + <isset property="debug.transport"/>
508.395 + </condition>
508.396 + </target>
508.397 + <target depends="-init-debug-args" name="-init-macrodef-debug">
508.398 + <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
508.399 + <attribute default="${main.class}" name="classname"/>
508.400 + <attribute default="${debug.classpath}" name="classpath"/>
508.401 + <element name="customize" optional="true"/>
508.402 + <sequential>
508.403 + <java classname="@{classname}" dir="${work.dir}" fork="true">
508.404 + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
508.405 + <jvmarg line="${debug-args-line}"/>
508.406 + <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
508.407 + <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
508.408 + <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
508.409 + <jvmarg line="${run.jvmargs}"/>
508.410 + <classpath>
508.411 + <path path="@{classpath}"/>
508.412 + </classpath>
508.413 + <syspropertyset>
508.414 + <propertyref prefix="run-sys-prop."/>
508.415 + <mapper from="run-sys-prop.*" to="*" type="glob"/>
508.416 + </syspropertyset>
508.417 + <customize/>
508.418 + </java>
508.419 + </sequential>
508.420 + </macrodef>
508.421 + </target>
508.422 + <target name="-init-macrodef-java">
508.423 + <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
508.424 + <attribute default="${main.class}" name="classname"/>
508.425 + <attribute default="${run.classpath}" name="classpath"/>
508.426 + <element name="customize" optional="true"/>
508.427 + <sequential>
508.428 + <java classname="@{classname}" dir="${work.dir}" fork="true">
508.429 + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
508.430 + <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
508.431 + <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
508.432 + <jvmarg line="${run.jvmargs}"/>
508.433 + <classpath>
508.434 + <path path="@{classpath}"/>
508.435 + </classpath>
508.436 + <syspropertyset>
508.437 + <propertyref prefix="run-sys-prop."/>
508.438 + <mapper from="run-sys-prop.*" to="*" type="glob"/>
508.439 + </syspropertyset>
508.440 + <customize/>
508.441 + </java>
508.442 + </sequential>
508.443 + </macrodef>
508.444 + </target>
508.445 + <target name="-init-presetdef-jar">
508.446 + <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
508.447 + <jar compress="${jar.compress}" jarfile="${dist.jar}">
508.448 + <j2seproject1:fileset dir="${build.classes.dir}"/>
508.449 + </jar>
508.450 + </presetdef>
508.451 + </target>
508.452 + <target name="-init-ap-cmdline-properties">
508.453 + <property name="annotation.processing.enabled" value="true"/>
508.454 + <property name="annotation.processing.processors.list" value=""/>
508.455 + <property name="annotation.processing.run.all.processors" value="true"/>
508.456 + <property name="javac.processorpath" value="${javac.classpath}"/>
508.457 + <property name="javac.test.processorpath" value="${javac.test.classpath}"/>
508.458 + <condition property="ap.supported.internal" value="true">
508.459 + <not>
508.460 + <matches pattern="1\.[0-5](\..*)?" string="${javac.source}"/>
508.461 + </not>
508.462 + </condition>
508.463 + </target>
508.464 + <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-ap-cmdline-supported">
508.465 + <condition else="" property="ap.processors.internal" value="-processor ${annotation.processing.processors.list}">
508.466 + <isfalse value="${annotation.processing.run.all.processors}"/>
508.467 + </condition>
508.468 + <condition else="" property="ap.proc.none.internal" value="-proc:none">
508.469 + <isfalse value="${annotation.processing.enabled}"/>
508.470 + </condition>
508.471 + </target>
508.472 + <target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
508.473 + <property name="ap.cmd.line.internal" value=""/>
508.474 + </target>
508.475 + <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
508.476 + <!--
508.477 + ===================
508.478 + COMPILATION SECTION
508.479 + ===================
508.480 + -->
508.481 + <target name="-deps-jar-init" unless="built-jar.properties">
508.482 + <property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>
508.483 + <delete file="${built-jar.properties}" quiet="true"/>
508.484 + </target>
508.485 + <target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
508.486 + <echo level="warn" message="Cycle detected: web.api was already built"/>
508.487 + </target>
508.488 + <target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
508.489 + <mkdir dir="${build.dir}"/>
508.490 + <touch file="${built-jar.properties}" verbose="false"/>
508.491 + <property file="${built-jar.properties}" prefix="already.built.jar."/>
508.492 + <antcall target="-warn-already-built-jar"/>
508.493 + <propertyfile file="${built-jar.properties}">
508.494 + <entry key="${basedir}" value=""/>
508.495 + </propertyfile>
508.496 + <antcall target="-maybe-call-dep">
508.497 + <param name="call.built.properties" value="${built-jar.properties}"/>
508.498 + <param location="${project.indexer}" name="call.subproject"/>
508.499 + <param location="${project.indexer}/build.xml" name="call.script"/>
508.500 + <param name="call.target" value="jar"/>
508.501 + <param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
508.502 + </antcall>
508.503 + <antcall target="-maybe-call-dep">
508.504 + <param name="call.built.properties" value="${built-jar.properties}"/>
508.505 + <param location="${project.org_netbeans_modules_jackpot30_api}" name="call.subproject"/>
508.506 + <param location="${project.org_netbeans_modules_jackpot30_api}/build.xml" name="call.script"/>
508.507 + <param name="call.target" value="netbeans"/>
508.508 + <param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
508.509 + </antcall>
508.510 + </target>
508.511 + <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
508.512 + <target depends="init" name="-check-automatic-build">
508.513 + <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
508.514 + </target>
508.515 + <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
508.516 + <antcall target="clean"/>
508.517 + </target>
508.518 + <target depends="init,deps-jar" name="-pre-pre-compile">
508.519 + <mkdir dir="${build.classes.dir}"/>
508.520 + </target>
508.521 + <target name="-pre-compile">
508.522 + <!-- Empty placeholder for easier customization. -->
508.523 + <!-- You can override this target in the ../build.xml file. -->
508.524 + </target>
508.525 + <target if="do.depend.true" name="-compile-depend">
508.526 + <pathconvert property="build.generated.subdirs">
508.527 + <dirset dir="${build.generated.sources.dir}" erroronmissingdir="false">
508.528 + <include name="*"/>
508.529 + </dirset>
508.530 + </pathconvert>
508.531 + <j2seproject3:depend srcdir="${src.dir}:${build.generated.subdirs}"/>
508.532 + </target>
508.533 + <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
508.534 + <j2seproject3:javac gensrcdir="${build.generated.sources.dir}"/>
508.535 + <copy todir="${build.classes.dir}">
508.536 + <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
508.537 + </copy>
508.538 + </target>
508.539 + <target name="-post-compile">
508.540 + <!-- Empty placeholder for easier customization. -->
508.541 + <!-- You can override this target in the ../build.xml file. -->
508.542 + </target>
508.543 + <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
508.544 + <target name="-pre-compile-single">
508.545 + <!-- Empty placeholder for easier customization. -->
508.546 + <!-- You can override this target in the ../build.xml file. -->
508.547 + </target>
508.548 + <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
508.549 + <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
508.550 + <j2seproject3:force-recompile/>
508.551 + <j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.dir}"/>
508.552 + </target>
508.553 + <target name="-post-compile-single">
508.554 + <!-- Empty placeholder for easier customization. -->
508.555 + <!-- You can override this target in the ../build.xml file. -->
508.556 + </target>
508.557 + <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
508.558 + <!--
508.559 + ====================
508.560 + JAR BUILDING SECTION
508.561 + ====================
508.562 + -->
508.563 + <target depends="init" name="-pre-pre-jar">
508.564 + <dirname file="${dist.jar}" property="dist.jar.dir"/>
508.565 + <mkdir dir="${dist.jar.dir}"/>
508.566 + </target>
508.567 + <target name="-pre-jar">
508.568 + <!-- Empty placeholder for easier customization. -->
508.569 + <!-- You can override this target in the ../build.xml file. -->
508.570 + </target>
508.571 + <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available-mkdist.available">
508.572 + <j2seproject1:jar/>
508.573 + </target>
508.574 + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class-mkdist.available">
508.575 + <j2seproject1:jar manifest="${manifest.file}"/>
508.576 + </target>
508.577 + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
508.578 + <j2seproject1:jar manifest="${manifest.file}">
508.579 + <j2seproject1:manifest>
508.580 + <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
508.581 + </j2seproject1:manifest>
508.582 + </j2seproject1:jar>
508.583 + <echo>To run this application from the command line without Ant, try:</echo>
508.584 + <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
508.585 + <property location="${dist.jar}" name="dist.jar.resolved"/>
508.586 + <pathconvert property="run.classpath.with.dist.jar">
508.587 + <path path="${run.classpath}"/>
508.588 + <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
508.589 + </pathconvert>
508.590 + <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
508.591 + </target>
508.592 + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available+splashscreen.available" name="-do-jar-with-libraries-and-splashscreen">
508.593 + <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
508.594 + <pathconvert property="run.classpath.without.build.classes.dir">
508.595 + <path path="${run.classpath}"/>
508.596 + <map from="${build.classes.dir.resolved}" to=""/>
508.597 + </pathconvert>
508.598 + <pathconvert pathsep=" " property="jar.classpath">
508.599 + <path path="${run.classpath.without.build.classes.dir}"/>
508.600 + <chainedmapper>
508.601 + <flattenmapper/>
508.602 + <globmapper from="*" to="lib/*"/>
508.603 + </chainedmapper>
508.604 + </pathconvert>
508.605 + <basename file="${application.splash}" property="splashscreen.basename"/>
508.606 + <mkdir dir="${build.classes.dir}/META-INF"/>
508.607 + <copy failonerror="false" file="${application.splash}" todir="${build.classes.dir}/META-INF"/>
508.608 + <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
508.609 + <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
508.610 + <fileset dir="${build.classes.dir}"/>
508.611 + <manifest>
508.612 + <attribute name="Main-Class" value="${main.class}"/>
508.613 + <attribute name="Class-Path" value="${jar.classpath}"/>
508.614 + <attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/>
508.615 + </manifest>
508.616 + </copylibs>
508.617 + <echo>To run this application from the command line without Ant, try:</echo>
508.618 + <property location="${dist.jar}" name="dist.jar.resolved"/>
508.619 + <echo>java -jar "${dist.jar.resolved}"</echo>
508.620 + </target>
508.621 + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries" unless="splashscreen.available">
508.622 + <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
508.623 + <pathconvert property="run.classpath.without.build.classes.dir">
508.624 + <path path="${run.classpath}"/>
508.625 + <map from="${build.classes.dir.resolved}" to=""/>
508.626 + </pathconvert>
508.627 + <pathconvert pathsep=" " property="jar.classpath">
508.628 + <path path="${run.classpath.without.build.classes.dir}"/>
508.629 + <chainedmapper>
508.630 + <flattenmapper/>
508.631 + <globmapper from="*" to="lib/*"/>
508.632 + </chainedmapper>
508.633 + </pathconvert>
508.634 + <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
508.635 + <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
508.636 + <fileset dir="${build.classes.dir}"/>
508.637 + <manifest>
508.638 + <attribute name="Main-Class" value="${main.class}"/>
508.639 + <attribute name="Class-Path" value="${jar.classpath}"/>
508.640 + </manifest>
508.641 + </copylibs>
508.642 + <echo>To run this application from the command line without Ant, try:</echo>
508.643 + <property location="${dist.jar}" name="dist.jar.resolved"/>
508.644 + <echo>java -jar "${dist.jar.resolved}"</echo>
508.645 + </target>
508.646 + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+mkdist.available" name="-do-jar-with-libraries-without-mainclass" unless="main.class.available">
508.647 + <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
508.648 + <pathconvert property="run.classpath.without.build.classes.dir">
508.649 + <path path="${run.classpath}"/>
508.650 + <map from="${build.classes.dir.resolved}" to=""/>
508.651 + </pathconvert>
508.652 + <pathconvert pathsep=" " property="jar.classpath">
508.653 + <path path="${run.classpath.without.build.classes.dir}"/>
508.654 + <chainedmapper>
508.655 + <flattenmapper/>
508.656 + <globmapper from="*" to="lib/*"/>
508.657 + </chainedmapper>
508.658 + </pathconvert>
508.659 + <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
508.660 + <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
508.661 + <fileset dir="${build.classes.dir}"/>
508.662 + <manifest>
508.663 + <attribute name="Class-Path" value="${jar.classpath}"/>
508.664 + </manifest>
508.665 + </copylibs>
508.666 + </target>
508.667 + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.mkdist" name="-do-jar-with-libraries-without-manifest" unless="manifest.available">
508.668 + <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
508.669 + <pathconvert property="run.classpath.without.build.classes.dir">
508.670 + <path path="${run.classpath}"/>
508.671 + <map from="${build.classes.dir.resolved}" to=""/>
508.672 + </pathconvert>
508.673 + <pathconvert pathsep=" " property="jar.classpath">
508.674 + <path path="${run.classpath.without.build.classes.dir}"/>
508.675 + <chainedmapper>
508.676 + <flattenmapper/>
508.677 + <globmapper from="*" to="lib/*"/>
508.678 + </chainedmapper>
508.679 + </pathconvert>
508.680 + <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
508.681 + <copylibs compress="${jar.compress}" jarfile="${dist.jar}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
508.682 + <fileset dir="${build.classes.dir}"/>
508.683 + <manifest>
508.684 + <attribute name="Class-Path" value="${jar.classpath}"/>
508.685 + </manifest>
508.686 + </copylibs>
508.687 + </target>
508.688 + <target name="-post-jar">
508.689 + <!-- Empty placeholder for easier customization. -->
508.690 + <!-- You can override this target in the ../build.xml file. -->
508.691 + </target>
508.692 + <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries-and-splashscreen,-do-jar-with-libraries,-do-jar-with-libraries-without-mainclass,-do-jar-with-libraries-without-manifest,-post-jar" description="Build JAR." name="jar"/>
508.693 + <!--
508.694 + =================
508.695 + EXECUTION SECTION
508.696 + =================
508.697 + -->
508.698 + <target depends="init,compile" description="Run a main class." name="run">
508.699 + <j2seproject1:java>
508.700 + <customize>
508.701 + <arg line="${application.args}"/>
508.702 + </customize>
508.703 + </j2seproject1:java>
508.704 + </target>
508.705 + <target name="-do-not-recompile">
508.706 + <property name="javac.includes.binary" value=""/>
508.707 + </target>
508.708 + <target depends="init,compile-single" name="run-single">
508.709 + <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
508.710 + <j2seproject1:java classname="${run.class}"/>
508.711 + </target>
508.712 + <target depends="init,compile-test-single" name="run-test-with-main">
508.713 + <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
508.714 + <j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
508.715 + </target>
508.716 + <!--
508.717 + =================
508.718 + DEBUGGING SECTION
508.719 + =================
508.720 + -->
508.721 + <target depends="init" if="netbeans.home" name="-debug-start-debugger">
508.722 + <j2seproject1:nbjpdastart name="${debug.class}"/>
508.723 + </target>
508.724 + <target depends="init" if="netbeans.home" name="-debug-start-debugger-main-test">
508.725 + <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${debug.class}"/>
508.726 + </target>
508.727 + <target depends="init,compile" name="-debug-start-debuggee">
508.728 + <j2seproject3:debug>
508.729 + <customize>
508.730 + <arg line="${application.args}"/>
508.731 + </customize>
508.732 + </j2seproject3:debug>
508.733 + </target>
508.734 + <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
508.735 + <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
508.736 + <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
508.737 + </target>
508.738 + <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
508.739 + <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
508.740 + <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
508.741 + <j2seproject3:debug classname="${debug.class}"/>
508.742 + </target>
508.743 + <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
508.744 + <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">
508.745 + <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
508.746 + <j2seproject3:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>
508.747 + </target>
508.748 + <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
508.749 + <target depends="init" name="-pre-debug-fix">
508.750 + <fail unless="fix.includes">Must set fix.includes</fail>
508.751 + <property name="javac.includes" value="${fix.includes}.java"/>
508.752 + </target>
508.753 + <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
508.754 + <j2seproject1:nbjpdareload/>
508.755 + </target>
508.756 + <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
508.757 + <!--
508.758 + ===============
508.759 + JAVADOC SECTION
508.760 + ===============
508.761 + -->
508.762 + <target depends="init" if="have.sources" name="-javadoc-build">
508.763 + <mkdir dir="${dist.javadoc.dir}"/>
508.764 + <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
508.765 + <classpath>
508.766 + <path path="${javac.classpath}"/>
508.767 + </classpath>
508.768 + <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
508.769 + <filename name="**/*.java"/>
508.770 + </fileset>
508.771 + <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
508.772 + <include name="**/*.java"/>
508.773 + </fileset>
508.774 + </javadoc>
508.775 + </target>
508.776 + <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
508.777 + <nbbrowse file="${dist.javadoc.dir}/index.html"/>
508.778 + </target>
508.779 + <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
508.780 + <!--
508.781 + =========================
508.782 + JUNIT COMPILATION SECTION
508.783 + =========================
508.784 + -->
508.785 + <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
508.786 + <mkdir dir="${build.test.classes.dir}"/>
508.787 + </target>
508.788 + <target name="-pre-compile-test">
508.789 + <!-- Empty placeholder for easier customization. -->
508.790 + <!-- You can override this target in the ../build.xml file. -->
508.791 + </target>
508.792 + <target if="do.depend.true" name="-compile-test-depend">
508.793 + <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
508.794 + </target>
508.795 + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
508.796 + <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.src.dir}"/>
508.797 + <copy todir="${build.test.classes.dir}">
508.798 + <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
508.799 + </copy>
508.800 + </target>
508.801 + <target name="-post-compile-test">
508.802 + <!-- Empty placeholder for easier customization. -->
508.803 + <!-- You can override this target in the ../build.xml file. -->
508.804 + </target>
508.805 + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
508.806 + <target name="-pre-compile-test-single">
508.807 + <!-- Empty placeholder for easier customization. -->
508.808 + <!-- You can override this target in the ../build.xml file. -->
508.809 + </target>
508.810 + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
508.811 + <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
508.812 + <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
508.813 + <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
508.814 + <copy todir="${build.test.classes.dir}">
508.815 + <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
508.816 + </copy>
508.817 + </target>
508.818 + <target name="-post-compile-test-single">
508.819 + <!-- Empty placeholder for easier customization. -->
508.820 + <!-- You can override this target in the ../build.xml file. -->
508.821 + </target>
508.822 + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
508.823 + <!--
508.824 + =======================
508.825 + JUNIT EXECUTION SECTION
508.826 + =======================
508.827 + -->
508.828 + <target depends="init" if="have.tests" name="-pre-test-run">
508.829 + <mkdir dir="${build.test.results.dir}"/>
508.830 + </target>
508.831 + <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
508.832 + <j2seproject3:junit testincludes="**/*Test.java"/>
508.833 + </target>
508.834 + <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
508.835 + <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
508.836 + </target>
508.837 + <target depends="init" if="have.tests" name="test-report"/>
508.838 + <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
508.839 + <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
508.840 + <target depends="init" if="have.tests" name="-pre-test-run-single">
508.841 + <mkdir dir="${build.test.results.dir}"/>
508.842 + </target>
508.843 + <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
508.844 + <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
508.845 + <j2seproject3:junit excludes="" includes="${test.includes}"/>
508.846 + </target>
508.847 + <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
508.848 + <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
508.849 + </target>
508.850 + <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
508.851 + <!--
508.852 + =======================
508.853 + JUNIT DEBUGGING SECTION
508.854 + =======================
508.855 + -->
508.856 + <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
508.857 + <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
508.858 + <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
508.859 + <delete file="${test.report.file}"/>
508.860 + <mkdir dir="${build.test.results.dir}"/>
508.861 + <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
508.862 + <customize>
508.863 + <syspropertyset>
508.864 + <propertyref prefix="test-sys-prop."/>
508.865 + <mapper from="test-sys-prop.*" to="*" type="glob"/>
508.866 + </syspropertyset>
508.867 + <arg value="${test.class}"/>
508.868 + <arg value="showoutput=true"/>
508.869 + <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
508.870 + <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
508.871 + </customize>
508.872 + </j2seproject3:debug>
508.873 + </target>
508.874 + <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
508.875 + <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
508.876 + </target>
508.877 + <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
508.878 + <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
508.879 + <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
508.880 + </target>
508.881 + <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
508.882 + <!--
508.883 + =========================
508.884 + APPLET EXECUTION SECTION
508.885 + =========================
508.886 + -->
508.887 + <target depends="init,compile-single" name="run-applet">
508.888 + <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
508.889 + <j2seproject1:java classname="sun.applet.AppletViewer">
508.890 + <customize>
508.891 + <arg value="${applet.url}"/>
508.892 + </customize>
508.893 + </j2seproject1:java>
508.894 + </target>
508.895 + <!--
508.896 + =========================
508.897 + APPLET DEBUGGING SECTION
508.898 + =========================
508.899 + -->
508.900 + <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
508.901 + <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
508.902 + <j2seproject3:debug classname="sun.applet.AppletViewer">
508.903 + <customize>
508.904 + <arg value="${applet.url}"/>
508.905 + </customize>
508.906 + </j2seproject3:debug>
508.907 + </target>
508.908 + <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
508.909 + <!--
508.910 + ===============
508.911 + CLEANUP SECTION
508.912 + ===============
508.913 + -->
508.914 + <target name="-deps-clean-init" unless="built-clean.properties">
508.915 + <property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>
508.916 + <delete file="${built-clean.properties}" quiet="true"/>
508.917 + </target>
508.918 + <target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
508.919 + <echo level="warn" message="Cycle detected: web.api was already built"/>
508.920 + </target>
508.921 + <target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
508.922 + <mkdir dir="${build.dir}"/>
508.923 + <touch file="${built-clean.properties}" verbose="false"/>
508.924 + <property file="${built-clean.properties}" prefix="already.built.clean."/>
508.925 + <antcall target="-warn-already-built-clean"/>
508.926 + <propertyfile file="${built-clean.properties}">
508.927 + <entry key="${basedir}" value=""/>
508.928 + </propertyfile>
508.929 + <antcall target="-maybe-call-dep">
508.930 + <param name="call.built.properties" value="${built-clean.properties}"/>
508.931 + <param location="${project.indexer}" name="call.subproject"/>
508.932 + <param location="${project.indexer}/build.xml" name="call.script"/>
508.933 + <param name="call.target" value="clean"/>
508.934 + <param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
508.935 + </antcall>
508.936 + <antcall target="-maybe-call-dep">
508.937 + <param name="call.built.properties" value="${built-clean.properties}"/>
508.938 + <param location="${project.org_netbeans_modules_jackpot30_api}" name="call.subproject"/>
508.939 + <param location="${project.org_netbeans_modules_jackpot30_api}/build.xml" name="call.script"/>
508.940 + <param name="call.target" value="clean"/>
508.941 + <param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
508.942 + </antcall>
508.943 + </target>
508.944 + <target depends="init" name="-do-clean">
508.945 + <delete dir="${build.dir}"/>
508.946 + <delete dir="${dist.dir}" followsymlinks="false" includeemptydirs="true"/>
508.947 + </target>
508.948 + <target name="-post-clean">
508.949 + <!-- Empty placeholder for easier customization. -->
508.950 + <!-- You can override this target in the ../build.xml file. -->
508.951 + </target>
508.952 + <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
508.953 + <target name="-check-call-dep">
508.954 + <property file="${call.built.properties}" prefix="already.built."/>
508.955 + <condition property="should.call.dep">
508.956 + <not>
508.957 + <isset property="already.built.${call.subproject}"/>
508.958 + </not>
508.959 + </condition>
508.960 + </target>
508.961 + <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
508.962 + <ant antfile="${call.script}" inheritall="false" target="${call.target}">
508.963 + <propertyset>
508.964 + <propertyref prefix="transfer."/>
508.965 + <mapper from="transfer.*" to="*" type="glob"/>
508.966 + </propertyset>
508.967 + </ant>
508.968 + </target>
508.969 +</project>
509.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
509.2 +++ b/sandbox/old-modules/server/web.api/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
509.3 @@ -0,0 +1,8 @@
509.4 +build.xml.data.CRC32=2d84667c
509.5 +build.xml.script.CRC32=0d0c4a18
509.6 +build.xml.stylesheet.CRC32=958a1d3e@1.27.0.45
509.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
509.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
509.9 +nbproject/build-impl.xml.data.CRC32=2d84667c
509.10 +nbproject/build-impl.xml.script.CRC32=8250004f
509.11 +nbproject/build-impl.xml.stylesheet.CRC32=ff4aa3ed@1.35.0.45
510.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
510.2 +++ b/sandbox/old-modules/server/web.api/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
510.3 @@ -0,0 +1,99 @@
510.4 +annotation.processing.enabled=true
510.5 +annotation.processing.enabled.in.editor=false
510.6 +annotation.processing.run.all.processors=true
510.7 +application.title=web.api
510.8 +application.vendor=lahvac
510.9 +build.classes.dir=${build.dir}/classes
510.10 +build.classes.excludes=**/*.java,**/*.form
510.11 +# This directory is removed when the project is cleaned:
510.12 +build.dir=build
510.13 +build.generated.dir=${build.dir}/generated
510.14 +build.generated.sources.dir=${build.dir}/generated-sources
510.15 +# Only compile against the classpath explicitly listed here:
510.16 +build.sysclasspath=ignore
510.17 +build.test.classes.dir=${build.dir}/test/classes
510.18 +build.test.results.dir=${build.dir}/test/results
510.19 +# Uncomment to specify the preferred debugger connection transport:
510.20 +#debug.transport=dt_socket
510.21 +debug.classpath=\
510.22 + ${run.classpath}
510.23 +debug.test.classpath=\
510.24 + ${run.test.classpath}
510.25 +# This directory is removed when the project is cleaned:
510.26 +dist.dir=dist
510.27 +dist.jar=${dist.dir}/web.api.jar
510.28 +dist.javadoc.dir=${dist.dir}/javadoc
510.29 +endorsed.classpath=\
510.30 + ${libs.javac.classpath}
510.31 +excludes=
510.32 +file.reference.org-netbeans-modules-java-source.jar=../lib/org-netbeans-modules-java-source.jar
510.33 +file.reference.org-netbeans-spi-editor-hints.jar=../lib/org-netbeans-spi-editor-hints.jar
510.34 +file.reference.org-openide-filesystems.jar=../lib/org-openide-filesystems.jar
510.35 +file.reference.org-openide-util-lookup.jar=../lib/org-openide-util-lookup.jar
510.36 +file.reference.org-openide-util.jar=../lib/org-openide-util.jar
510.37 +file.reference.util-commons.jar=../../remoting/ide/api/external/util-commons.jar
510.38 +file.reference.util-pojson.jar=../../remoting/ide/api/external/util-pojson.jar
510.39 +includes=**
510.40 +jar.compress=false
510.41 +javac.classpath=\
510.42 + ${reference.org_netbeans_modules_jackpot30_api.module}:\
510.43 + ${libs.jersey.classpath}:\
510.44 + ${libs.lucene.classpath}:\
510.45 + ${libs.javac.classpath}:\
510.46 + ${reference.indexer.jar}:\
510.47 + ${file.reference.org-netbeans-modules-java-source.jar}:\
510.48 + ${file.reference.org-openide-filesystems.jar}:\
510.49 + ${file.reference.util-commons.jar}:\
510.50 + ${file.reference.util-pojson.jar}:\
510.51 + ${libs.freemarker.classpath}:\
510.52 + ${file.reference.org-openide-util.jar}:\
510.53 + ${file.reference.org-openide-util-lookup.jar}:\
510.54 + ${file.reference.org-netbeans-spi-editor-hints.jar}:\
510.55 + ${reference.org_netbeans_modules_jackpot30_remoting_api.module}
510.56 +# Space-separated list of extra javac options
510.57 +javac.compilerargs=
510.58 +javac.deprecation=false
510.59 +javac.processorpath=\
510.60 + ${javac.classpath}
510.61 +javac.source=1.5
510.62 +javac.target=1.5
510.63 +javac.test.classpath=\
510.64 + ${javac.classpath}:\
510.65 + ${build.classes.dir}:\
510.66 + ${libs.junit_4.classpath}
510.67 +javadoc.additionalparam=
510.68 +javadoc.author=false
510.69 +javadoc.encoding=${source.encoding}
510.70 +javadoc.noindex=false
510.71 +javadoc.nonavbar=false
510.72 +javadoc.notree=false
510.73 +javadoc.private=false
510.74 +javadoc.splitindex=true
510.75 +javadoc.use=true
510.76 +javadoc.version=false
510.77 +javadoc.windowtitle=
510.78 +jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api"
510.79 +main.class=org.netbeans.modules.jackpot30.server.webapi.Main
510.80 +manifest.file=manifest.mf
510.81 +meta.inf.dir=${src.dir}/META-INF
510.82 +mkdist.disabled=false
510.83 +platform.active=default_platform
510.84 +project.indexer=../indexer
510.85 +project.org_netbeans_modules_jackpot30_api=../../api
510.86 +project.org_netbeans_modules_jackpot30_remoting_api=../../remoting/ide/api
510.87 +reference.indexer.jar=${project.indexer}/dist/indexer.jar
510.88 +reference.org_netbeans_modules_jackpot30_api.module=${project.org_netbeans_modules_jackpot30_api}/../build/cluster/modules/org-netbeans-modules-jackpot30-api.jar
510.89 +reference.org_netbeans_modules_jackpot30_remoting_api.module=${project.org_netbeans_modules_jackpot30_remoting_api}/../build/cluster/modules/org-netbeans-modules-jackpot30-remoting-api.jar
510.90 +run.classpath=\
510.91 + ${javac.classpath}:\
510.92 + ${build.classes.dir}
510.93 +# Space-separated list of JVM arguments used when running the project
510.94 +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
510.95 +# or test-sys-prop.name=value to set system properties for unit tests):
510.96 +run.jvmargs=-Xbootclasspath/p:${libs.javac.classpath}
510.97 +run.test.classpath=\
510.98 + ${javac.test.classpath}:\
510.99 + ${build.test.classes.dir}
510.100 +source.encoding=UTF-8
510.101 +src.dir=src
510.102 +test.src.dir=test
511.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
511.2 +++ b/sandbox/old-modules/server/web.api/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
511.3 @@ -0,0 +1,44 @@
511.4 +<?xml version="1.0" encoding="UTF-8"?>
511.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
511.6 + <type>org.netbeans.modules.java.j2seproject</type>
511.7 + <configuration>
511.8 + <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
511.9 + <name>web.api</name>
511.10 + <source-roots>
511.11 + <root id="src.dir"/>
511.12 + </source-roots>
511.13 + <test-roots>
511.14 + <root id="test.src.dir"/>
511.15 + </test-roots>
511.16 + </data>
511.17 + <libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
511.18 + <definitions>../lib/nblibraries.properties</definitions>
511.19 + </libraries>
511.20 + <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
511.21 + <reference>
511.22 + <foreign-project>indexer</foreign-project>
511.23 + <artifact-type>jar</artifact-type>
511.24 + <script>build.xml</script>
511.25 + <target>jar</target>
511.26 + <clean-target>clean</clean-target>
511.27 + <id>jar</id>
511.28 + </reference>
511.29 + <reference>
511.30 + <foreign-project>org_netbeans_modules_jackpot30_api</foreign-project>
511.31 + <artifact-type>jar</artifact-type>
511.32 + <script>build.xml</script>
511.33 + <target>netbeans</target>
511.34 + <clean-target>clean</clean-target>
511.35 + <id>module</id>
511.36 + </reference>
511.37 + <reference>
511.38 + <foreign-project>org_netbeans_modules_jackpot30_remoting_api</foreign-project>
511.39 + <artifact-type>jar</artifact-type>
511.40 + <script>build.xml</script>
511.41 + <target>netbeans</target>
511.42 + <clean-target>clean</clean-target>
511.43 + <id>module</id>
511.44 + </reference>
511.45 + </references>
511.46 + </configuration>
511.47 +</project>
512.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
512.2 +++ b/sandbox/old-modules/server/web.api/src/org/netbeans/modules/jackpot30/server/webapi/API.java Mon Mar 12 21:10:10 2012 +0100
512.3 @@ -0,0 +1,233 @@
512.4 +/*
512.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
512.6 + *
512.7 + * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
512.8 + *
512.9 + * The contents of this file are subject to the terms of either the GNU
512.10 + * General Public License Version 2 only ("GPL") or the Common
512.11 + * Development and Distribution License("CDDL") (collectively, the
512.12 + * "License"). You may not use this file except in compliance with the
512.13 + * License. You can obtain a copy of the License at
512.14 + * http://www.netbeans.org/cddl-gplv2.html
512.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
512.16 + * specific language governing permissions and limitations under the
512.17 + * License. When distributing the software, include this License Header
512.18 + * Notice in each file and include the License file at
512.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
512.20 + * particular file as subject to the "Classpath" exception as provided
512.21 + * by Sun in the GPL Version 2 section of the License file that
512.22 + * accompanied this code. If applicable, add the following below the
512.23 + * License Header, with the fields enclosed by brackets [] replaced by
512.24 + * your own identifying information:
512.25 + * "Portions Copyrighted [year] [name of copyright owner]"
512.26 + *
512.27 + * If you wish your version of this file to be governed by only the CDDL
512.28 + * or only the GPL Version 2, indicate your decision by adding
512.29 + * "[Contributor] elects to include this software in this distribution
512.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
512.31 + * single choice of license, a recipient has the option to distribute
512.32 + * your version of this file under either the CDDL, the GPL Version 2 or
512.33 + * to extend the choice of license to its licensees as provided above.
512.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
512.35 + * Version 2 license, then the option applies only if the new code is
512.36 + * made subject to such option by the copyright holder.
512.37 + *
512.38 + * Contributor(s):
512.39 + *
512.40 + * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
512.41 + */
512.42 +
512.43 +package org.netbeans.modules.jackpot30.server.webapi;
512.44 +
512.45 +import java.io.IOException;
512.46 +import java.net.URL;
512.47 +import java.util.Arrays;
512.48 +import java.util.Collection;
512.49 +import java.util.HashMap;
512.50 +import java.util.LinkedList;
512.51 +import java.util.List;
512.52 +import java.util.Map;
512.53 +import java.util.Map.Entry;
512.54 +import javax.tools.Diagnostic;
512.55 +import javax.tools.JavaFileObject;
512.56 +import javax.ws.rs.DefaultValue;
512.57 +import javax.ws.rs.GET;
512.58 +import javax.ws.rs.Path;
512.59 +import javax.ws.rs.Produces;
512.60 +import javax.ws.rs.QueryParam;
512.61 +import org.codeviation.pojson.Pojson;
512.62 +import org.netbeans.modules.jackpot30.impl.examples.Example;
512.63 +import org.netbeans.modules.jackpot30.impl.examples.Example.Option;
512.64 +import org.netbeans.modules.jackpot30.impl.examples.LoadExamples;
512.65 +import org.netbeans.modules.jackpot30.impl.indexing.Cache;
512.66 +import org.netbeans.modules.jackpot30.impl.indexing.FileBasedIndex;
512.67 +import org.netbeans.modules.jackpot30.impl.indexing.Index;
512.68 +import org.netbeans.modules.jackpot30.server.indexer.StandaloneFinder;
512.69 +
512.70 +/**
512.71 + *
512.72 + * @author lahvac
512.73 + */
512.74 +@Path("/")
512.75 +public class API {
512.76 +
512.77 + @GET
512.78 + @Path("/find")
512.79 + @Produces("text/plain")
512.80 + public String find(@QueryParam("path") String segment, @QueryParam("pattern") String pattern) throws IOException {
512.81 + StringBuilder sb = new StringBuilder();
512.82 +
512.83 + for (String candidate : StandaloneFinder.findCandidates(Cache.sourceRootForKey(segment), pattern)) {
512.84 + sb.append(candidate);
512.85 + sb.append("\n");
512.86 + }
512.87 +
512.88 + return sb.toString();
512.89 + }
512.90 +
512.91 + @GET
512.92 + @Path("/findSpans")
512.93 + @Produces("text/plain")
512.94 + public String findSpans(@QueryParam("path") String segment, @QueryParam("relativePath") String relativePath, @QueryParam("pattern") String pattern) throws IOException {
512.95 + StringBuilder sb = new StringBuilder();
512.96 +
512.97 + for (int o : StandaloneFinder.findCandidateOccurrenceSpans(Cache.sourceRootForKey(segment), relativePath, pattern)) {
512.98 + sb.append(o);
512.99 + sb.append(":");
512.100 + }
512.101 +
512.102 + if (sb.length() > 0) {
512.103 + sb.delete(sb.length() - 1, sb.length());
512.104 + }
512.105 +
512.106 + return sb.toString();
512.107 + }
512.108 +
512.109 + @GET
512.110 + @Path("/list")
512.111 + @Produces("text/plain")
512.112 + public String list() throws IOException {
512.113 + StringBuilder sb = new StringBuilder();
512.114 +
512.115 + for (String root : Cache.knownSourceRoots()) {
512.116 + URL sourceRoot = Cache.sourceRootForKey(root).toURI().toURL();
512.117 + Index index = FileBasedIndex.get(sourceRoot);
512.118 + String displayName;
512.119 +
512.120 + if (index != null && index.getIndexInfo().displayName != null) {
512.121 + displayName = index.getIndexInfo().displayName;
512.122 + } else {
512.123 + String path = sourceRoot.getPath().replaceFirst("/$", "");
512.124 +
512.125 + displayName = path.substring(path.lastIndexOf('/') + 1);
512.126 + }
512.127 +
512.128 + sb.append(root);
512.129 + sb.append(":");
512.130 + sb.append(displayName);
512.131 + sb.append("\n");
512.132 + }
512.133 +
512.134 + return sb.toString();
512.135 + }
512.136 +
512.137 + @GET
512.138 + @Path("/cat")
512.139 + @Produces("text/plain")
512.140 + public String cat(@QueryParam("path") String segment, @QueryParam("relative") String relative) throws IOException {
512.141 + URL sourceRoot = Cache.sourceRootForKey(segment).toURI().toURL();
512.142 + Index index = FileBasedIndex.get(sourceRoot);
512.143 +
512.144 + if (index == null) {
512.145 + throw new IOException("No index");
512.146 + }
512.147 +
512.148 + CharSequence source = index.getSourceCode(relative);
512.149 +
512.150 + if (source == null) {
512.151 + throw new IOException("Source code not found");
512.152 + }
512.153 +
512.154 + return source.toString().replaceAll("\r\n", "\n");
512.155 + }
512.156 +
512.157 + @GET
512.158 + @Path("/info")
512.159 + @Produces("text/plain")
512.160 + public String info(@QueryParam("path") String segment) throws IOException {
512.161 + URL sourceRoot = Cache.sourceRootForKey(segment).toURI().toURL();
512.162 + Index index = FileBasedIndex.get(sourceRoot);
512.163 +
512.164 + if (index == null) {
512.165 + throw new IOException("No index");
512.166 + }
512.167 +
512.168 + return Pojson.save(index.getIndexInfo());
512.169 + }
512.170 +
512.171 + @GET
512.172 + @Path("/examples")
512.173 + @Produces("text/plain")
512.174 + public String examples() throws IOException {
512.175 + List<Map<String, String>> examples = new LinkedList<Map<String, String>>();
512.176 +
512.177 + for (Example ex : LoadExamples.loadExamples()) {
512.178 + if (ex.getOptions().contains(Option.VERIFY) || ex.getOptions().contains(Option.FIX)) continue;
512.179 + Map<String, String> desc = new HashMap<String, String>();
512.180 +
512.181 + desc.put("displayName", ex.getDisplayName());
512.182 + desc.put("pattern", ex.getCode());
512.183 +
512.184 + examples.add(desc);
512.185 + }
512.186 +
512.187 + return Pojson.save(examples);
512.188 + }
512.189 +
512.190 + @GET
512.191 + @Path("/errors")
512.192 + @Produces("text/plain")
512.193 + public String errors(@QueryParam("pattern") String pattern) throws IOException {
512.194 + StringBuilder sb = new StringBuilder();
512.195 +
512.196 + for (Diagnostic<? extends JavaFileObject> d : StandaloneFinder.parseAndReportErrors(pattern)) {
512.197 + sb.append(d.getMessage(null));
512.198 + sb.append("\n");
512.199 + }
512.200 +
512.201 + return sb.toString();
512.202 + }
512.203 +
512.204 + @GET
512.205 + @Path("/findDuplicates")
512.206 + @Produces("text/plain")
512.207 + public String findDuplicates(@QueryParam("path") String segment, @QueryParam("hashes") String hashes) throws IOException {
512.208 + Map<String, Map<String, Collection<? extends String>>> hash2Segment2Contains = new HashMap<String, Map<String, Collection<? extends String>>>();
512.209 + Collection<String> segments = new LinkedList<String>();
512.210 +
512.211 + if (segment != null) segments.add(segment);
512.212 + else {
512.213 + for (String key : Cache.knownSourceRoots()) {
512.214 + segments.add(key);
512.215 + }
512.216 + }
512.217 +
512.218 + Iterable<? extends String> hashesList = Arrays.asList(Pojson.load(String[].class, hashes));
512.219 +
512.220 + for (String key : segments) {
512.221 + Map<String, Collection<? extends String>> found = StandaloneFinder.containsHash(Cache.sourceRootForKey(key), hashesList);
512.222 +
512.223 + for (Entry<String, Collection<? extends String>> e : found.entrySet()) {
512.224 + Map<String, Collection<? extends String>> perRoot = hash2Segment2Contains.get(e.getKey());
512.225 +
512.226 + if (perRoot == null) {
512.227 + hash2Segment2Contains.put(e.getKey(), perRoot = new HashMap<String, Collection<? extends String>>());
512.228 + }
512.229 +
512.230 + perRoot.put(key, e.getValue());
512.231 + }
512.232 + }
512.233 +
512.234 + return Pojson.save(hash2Segment2Contains);
512.235 + }
512.236 +}
513.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
513.2 +++ b/sandbox/old-modules/server/web.api/src/org/netbeans/modules/jackpot30/server/webapi/Main.java Mon Mar 12 21:10:10 2012 +0100
513.3 @@ -0,0 +1,93 @@
513.4 +/*
513.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
513.6 + *
513.7 + * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
513.8 + *
513.9 + * The contents of this file are subject to the terms of either the GNU
513.10 + * General Public License Version 2 only ("GPL") or the Common
513.11 + * Development and Distribution License("CDDL") (collectively, the
513.12 + * "License"). You may not use this file except in compliance with the
513.13 + * License. You can obtain a copy of the License at
513.14 + * http://www.netbeans.org/cddl-gplv2.html
513.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
513.16 + * specific language governing permissions and limitations under the
513.17 + * License. When distributing the software, include this License Header
513.18 + * Notice in each file and include the License file at
513.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
513.20 + * particular file as subject to the "Classpath" exception as provided
513.21 + * by Sun in the GPL Version 2 section of the License file that
513.22 + * accompanied this code. If applicable, add the following below the
513.23 + * License Header, with the fields enclosed by brackets [] replaced by
513.24 + * your own identifying information:
513.25 + * "Portions Copyrighted [year] [name of copyright owner]"
513.26 + *
513.27 + * If you wish your version of this file to be governed by only the CDDL
513.28 + * or only the GPL Version 2, indicate your decision by adding
513.29 + * "[Contributor] elects to include this software in this distribution
513.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
513.31 + * single choice of license, a recipient has the option to distribute
513.32 + * your version of this file under either the CDDL, the GPL Version 2 or
513.33 + * to extend the choice of license to its licensees as provided above.
513.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
513.35 + * Version 2 license, then the option applies only if the new code is
513.36 + * made subject to such option by the copyright holder.
513.37 + *
513.38 + * Contributor(s):
513.39 + *
513.40 + * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
513.41 + */
513.42 +
513.43 +package org.netbeans.modules.jackpot30.server.webapi;
513.44 +
513.45 +import com.sun.grizzly.http.embed.GrizzlyWebServer;
513.46 +import com.sun.grizzly.http.servlet.ServletAdapter;
513.47 +import com.sun.grizzly.tcp.http11.GrizzlyAdapter;
513.48 +import com.sun.grizzly.tcp.http11.GrizzlyRequest;
513.49 +import com.sun.grizzly.tcp.http11.GrizzlyResponse;
513.50 +import com.sun.jersey.spi.container.servlet.ServletContainer;
513.51 +import java.io.File;
513.52 +import java.io.IOException;
513.53 +import org.netbeans.modules.jackpot30.impl.indexing.Cache;
513.54 +
513.55 +/**
513.56 + *
513.57 + * @author lahvac
513.58 + */
513.59 +public class Main {
513.60 +
513.61 + /**
513.62 + * @param args the command line arguments
513.63 + */
513.64 + public static void main(String[] args) throws IOException {
513.65 + if (args.length != 1 && args.length != 2) {
513.66 + System.err.println("Usage: java -jar " + Main.class.getProtectionDomain().getCodeSource().getLocation().getPath() + " <cache> [<static-content>]");
513.67 + return ;
513.68 + }
513.69 +
513.70 + Cache.setStandaloneCacheRoot(new File(args[0]));
513.71 +
513.72 + GrizzlyWebServer gws;
513.73 +
513.74 + if (args.length == 2) {
513.75 + gws = new GrizzlyWebServer(9998, args[1]);
513.76 + } else {
513.77 + gws = new GrizzlyWebServer(9998);
513.78 + }
513.79 +
513.80 + // Jersey web resources
513.81 + ServletAdapter jerseyAdapter = new ServletAdapter();
513.82 + jerseyAdapter.addInitParameter("com.sun.jersey.config.property.packages", "org.netbeans.modules.jackpot30.server.webapi");
513.83 + jerseyAdapter.setContextPath("/index");
513.84 + jerseyAdapter.setServletInstance(new ServletContainer());
513.85 +
513.86 + // register all above defined adapters
513.87 + gws.addGrizzlyAdapter(jerseyAdapter);
513.88 + gws.addGrizzlyAdapter(new GrizzlyAdapter(){
513.89 + public void service(GrizzlyRequest request, GrizzlyResponse response){}
513.90 + });
513.91 +
513.92 + // let Grizzly run
513.93 + gws.start();
513.94 + }
513.95 +
513.96 +}
514.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
514.2 +++ b/sandbox/old-modules/server/web.api/src/org/netbeans/modules/jackpot30/server/webapi/UI.java Mon Mar 12 21:10:10 2012 +0100
514.3 @@ -0,0 +1,274 @@
514.4 +/*
514.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
514.6 + *
514.7 + * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
514.8 + *
514.9 + * The contents of this file are subject to the terms of either the GNU
514.10 + * General Public License Version 2 only ("GPL") or the Common
514.11 + * Development and Distribution License("CDDL") (collectively, the
514.12 + * "License"). You may not use this file except in compliance with the
514.13 + * License. You can obtain a copy of the License at
514.14 + * http://www.netbeans.org/cddl-gplv2.html
514.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
514.16 + * specific language governing permissions and limitations under the
514.17 + * License. When distributing the software, include this License Header
514.18 + * Notice in each file and include the License file at
514.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
514.20 + * particular file as subject to the "Classpath" exception as provided
514.21 + * by Sun in the GPL Version 2 section of the License file that
514.22 + * accompanied this code. If applicable, add the following below the
514.23 + * License Header, with the fields enclosed by brackets [] replaced by
514.24 + * your own identifying information:
514.25 + * "Portions Copyrighted [year] [name of copyright owner]"
514.26 + *
514.27 + * If you wish your version of this file to be governed by only the CDDL
514.28 + * or only the GPL Version 2, indicate your decision by adding
514.29 + * "[Contributor] elects to include this software in this distribution
514.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
514.31 + * single choice of license, a recipient has the option to distribute
514.32 + * your version of this file under either the CDDL, the GPL Version 2 or
514.33 + * to extend the choice of license to its licensees as provided above.
514.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
514.35 + * Version 2 license, then the option applies only if the new code is
514.36 + * made subject to such option by the copyright holder.
514.37 + *
514.38 + * Contributor(s):
514.39 + *
514.40 + * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
514.41 + */
514.42 +
514.43 +package org.netbeans.modules.jackpot30.server.webapi;
514.44 +
514.45 +import freemarker.cache.TemplateLoader;
514.46 +import freemarker.template.Configuration;
514.47 +import freemarker.template.Template;
514.48 +import freemarker.template.TemplateException;
514.49 +import java.io.IOException;
514.50 +import java.io.InputStream;
514.51 +import java.io.InputStreamReader;
514.52 +import java.io.Reader;
514.53 +import java.io.StringWriter;
514.54 +import java.net.URI;
514.55 +import java.net.URISyntaxException;
514.56 +import java.util.ArrayList;
514.57 +import java.util.Collections;
514.58 +import java.util.HashMap;
514.59 +import java.util.LinkedList;
514.60 +import java.util.List;
514.61 +import java.util.Map;
514.62 +import javax.ws.rs.GET;
514.63 +import javax.ws.rs.Path;
514.64 +import javax.ws.rs.Produces;
514.65 +import javax.ws.rs.QueryParam;
514.66 +import org.codeviation.pojson.Pojson;
514.67 +import org.netbeans.modules.jackpot30.remoting.api.WebUtilities;
514.68 +import static org.netbeans.modules.jackpot30.remoting.api.WebUtilities.escapeForQuery;
514.69 +
514.70 +/**
514.71 + *
514.72 + * @author lahvac
514.73 + */
514.74 +@Path("/ui")
514.75 +public class UI {
514.76 +
514.77 + @GET
514.78 + @Path("/search")
514.79 + @Produces("text/html")
514.80 + public String search(@QueryParam("path") String path, @QueryParam("pattern") String pattern) throws URISyntaxException, IOException, TemplateException {
514.81 + Map<String, Object> configurationData = new HashMap<String, Object>();
514.82 +
514.83 + configurationData.put("paths", list());
514.84 + configurationData.put("selectedPath", path);
514.85 + configurationData.put("pattern", pattern);
514.86 + configurationData.put("patternEscaped", escapeForQuery(pattern));
514.87 + configurationData.put("examples", loadExamples());
514.88 +
514.89 + if (pattern != null && path != null) {
514.90 + URI u = new URI("http://localhost:9998/index/find?path=" + escapeForQuery(path) + "&pattern=" + escapeForQuery(pattern));
514.91 + List<Map<String, Object>> results = new LinkedList<Map<String, Object>>();
514.92 + long queryTime = System.currentTimeMillis();
514.93 + List<String> candidates = new ArrayList<String>(WebUtilities.requestStringArrayResponse(u));
514.94 +
514.95 + queryTime = System.currentTimeMillis() - queryTime;
514.96 +
514.97 + Collections.sort(candidates);
514.98 +
514.99 + for (String c : candidates) {
514.100 + Map<String, Object> found = new HashMap<String, Object>(3);
514.101 +
514.102 + found.put("relativePath", c);
514.103 +
514.104 + results.add(found);
514.105 + }
514.106 +
514.107 + configurationData.put("results", results);
514.108 +
514.109 + Map<String, Object> statistics = new HashMap<String, Object>();
514.110 +
514.111 + statistics.put("files", candidates.size());
514.112 + statistics.put("queryTime", queryTime);
514.113 +
514.114 + configurationData.put("statistics", statistics);
514.115 + }
514.116 +
514.117 + return processTemplate("/org/netbeans/modules/jackpot30/server/webapi/ui-search.html", configurationData);
514.118 + }
514.119 +
514.120 + @GET
514.121 + @Path("/show")
514.122 + @Produces("text/html")
514.123 + public String show(@QueryParam("path") String path, @QueryParam("relative") String relativePath, @QueryParam("pattern") String pattern) throws URISyntaxException, IOException, TemplateException {
514.124 + Map<String, Object> configurationData = new HashMap<String, Object>();
514.125 + List<Map<String, String>> occurrences = new LinkedList<Map<String, String>>();
514.126 +
514.127 + configurationData.put("occurrences", occurrences);
514.128 +
514.129 + URI codeURL = new URI("http://localhost:9998/index/cat?path=" + escapeForQuery(path) + "&relative=" + escapeForQuery(relativePath));
514.130 + String code = WebUtilities.requestStringResponse(codeURL);
514.131 + URI spansURL = new URI("http://localhost:9998/index/findSpans?path=" + escapeForQuery(path) + "&relativePath=" + escapeForQuery(relativePath) + "&pattern=" + escapeForQuery(pattern));
514.132 + int currentCodePos = 0;
514.133 + for (int[] span : parseSpans(WebUtilities.requestStringResponse(spansURL))) { //XXX: sorted!
514.134 + Map<String, String> occ = new HashMap<String, String>();
514.135 + occ.put("prefix", WebUtilities.escapeForHTMLElement(code.substring(currentCodePos, span[0])));
514.136 + occ.put("occurrence", WebUtilities.escapeForHTMLElement(code.substring(span[0], span[1])));
514.137 + occurrences.add(occ);
514.138 + currentCodePos = span[1];
514.139 + }
514.140 +
514.141 + configurationData.put("suffix", WebUtilities.escapeForHTMLElement(code.substring(currentCodePos, code.length())));
514.142 +
514.143 + return processTemplate("/org/netbeans/modules/jackpot30/server/webapi/ui-cat.html", configurationData);
514.144 + }
514.145 +
514.146 + @GET
514.147 + @Path("/snippet")
514.148 + @Produces("text/html")
514.149 + public String snippet(@QueryParam("path") String path, @QueryParam("relative") String relativePath, @QueryParam("pattern") String pattern) throws URISyntaxException, IOException, TemplateException {
514.150 + List<Map<String, String>> snippets = new LinkedList<Map<String, String>>();
514.151 +
514.152 + URI codeURL = new URI("http://localhost:9998/index/cat?path=" + escapeForQuery(path) + "&relative=" + escapeForQuery(relativePath));
514.153 + String code = WebUtilities.requestStringResponse(codeURL);
514.154 + URI spansURL = new URI("http://localhost:9998/index/findSpans?path=" + escapeForQuery(path) + "&relativePath=" + escapeForQuery(relativePath) + "&pattern=" + escapeForQuery(pattern));
514.155 +
514.156 + for (int[] span : parseSpans(WebUtilities.requestStringResponse(spansURL))) {
514.157 + snippets.add(prepareSnippet(code, span));
514.158 + }
514.159 +
514.160 + return processTemplate("/org/netbeans/modules/jackpot30/server/webapi/ui-snippet.html", Collections.<String, Object>singletonMap("snippets", snippets));
514.161 + }
514.162 +
514.163 + private static List<Map<String, String>> list() throws URISyntaxException {
514.164 + List<Map<String, String>> result = new LinkedList<Map<String, String>>();
514.165 +
514.166 + for (String enc : WebUtilities.requestStringArrayResponse(new URI("http://localhost:9998/index/list"))) {
514.167 + Map<String, String> rootDesc = new HashMap<String, String>();
514.168 + String[] col = enc.split(":", 2);
514.169 +
514.170 + rootDesc.put("segment", col[0]);
514.171 + rootDesc.put("displayName", col[1]);
514.172 + result.add(rootDesc);
514.173 + }
514.174 +
514.175 + return result;
514.176 + }
514.177 +
514.178 + private static Iterable<int[]> parseSpans(String from) {
514.179 + if (from.isEmpty()) {
514.180 + return Collections.emptyList();
514.181 + }
514.182 + String[] split = from.split(":");
514.183 + List<int[]> result = new LinkedList<int[]>();
514.184 +
514.185 + for (int i = 0; i < split.length; i += 2) {
514.186 + result.add(new int[] {
514.187 + Integer.parseInt(split[i + 0].trim()),
514.188 + Integer.parseInt(split[i + 1].trim())
514.189 + });
514.190 + }
514.191 +
514.192 + return result;
514.193 + }
514.194 +
514.195 + private static final int DESIRED_CONTEXT = 2;
514.196 +
514.197 + private static Map<String, String> prepareSnippet(String code, int[] span) {
514.198 + int grandStart = span[0];
514.199 + int firstLineStart = grandStart = lineStart(code, grandStart);
514.200 +
514.201 + while (grandStart > 0 && contextLength(code.substring(grandStart, firstLineStart)) < DESIRED_CONTEXT)
514.202 + grandStart = lineStart(code, grandStart - 1);
514.203 +
514.204 + int grandEnd = span[1];
514.205 + int firstLineEnd = grandEnd = lineEnd(code, grandEnd);
514.206 +
514.207 + while (grandEnd < code.length() - 1 && contextLength(code.substring(firstLineEnd, grandEnd)) < DESIRED_CONTEXT)
514.208 + grandEnd = lineEnd(code, grandEnd + 1);
514.209 +
514.210 + Map<String, String> result = new HashMap<String, String>();
514.211 +
514.212 + result.put("prefix", WebUtilities.escapeForHTMLElement(code.substring(grandStart, span[0])));
514.213 + result.put("occurrence", WebUtilities.escapeForHTMLElement(code.substring(span[0], span[1])));
514.214 + result.put("suffix", WebUtilities.escapeForHTMLElement(code.substring(span[1], grandEnd)));
514.215 +
514.216 + return result;
514.217 + }
514.218 +
514.219 + private static int lineStart(String code, int o) {
514.220 + while (o > 0 && code.charAt(o) != '\n') {
514.221 + o--;
514.222 + }
514.223 +
514.224 + return o;
514.225 + }
514.226 +
514.227 + private static int lineEnd(String code, int o) {
514.228 + while (o < code.length() - 1 && code.charAt(o) != '\n') {
514.229 + o++;
514.230 + }
514.231 +
514.232 + return o;
514.233 + }
514.234 +
514.235 + private static int contextLength(String in) {
514.236 + return in.replaceAll("\n[ \t]*\n", "\n").trim().split("\n").length;
514.237 + }
514.238 +
514.239 + @SuppressWarnings("unchecked")
514.240 + private List<Map<String, String>> loadExamples() throws IOException, URISyntaxException {
514.241 + return Pojson.load(LinkedList.class, new URI("http://localhost:9998/index/examples"));
514.242 + }
514.243 +
514.244 + private static String processTemplate(String template, Map<String, Object> configurationData) throws TemplateException, IOException {
514.245 + Configuration conf = new Configuration();
514.246 +
514.247 + conf.setTemplateLoader(new TemplateLoaderImpl());
514.248 +
514.249 + Template templ = conf.getTemplate(template);
514.250 + StringWriter out = new StringWriter();
514.251 +
514.252 + templ.process(configurationData, out);
514.253 +
514.254 + return out.toString();
514.255 + }
514.256 +
514.257 + private static final class TemplateLoaderImpl implements TemplateLoader {
514.258 +
514.259 + public Object findTemplateSource(String name) throws IOException {
514.260 + return TemplateLoaderImpl.class.getResourceAsStream("/" + name);
514.261 + }
514.262 +
514.263 + public long getLastModified(Object templateSource) {
514.264 + return 0L;
514.265 + }
514.266 +
514.267 + public Reader getReader(Object templateSource, String encoding) throws IOException {
514.268 + InputStream in = (InputStream) templateSource;
514.269 +
514.270 + return new InputStreamReader(in);
514.271 + }
514.272 +
514.273 + public void closeTemplateSource(Object templateSource) throws IOException {
514.274 + }
514.275 + }
514.276 +
514.277 +}
515.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
515.2 +++ b/sandbox/old-modules/server/web.api/src/org/netbeans/modules/jackpot30/server/webapi/ui-cat.html Mon Mar 12 21:10:10 2012 +0100
515.3 @@ -0,0 +1,10 @@
515.4 +<html>
515.5 +<head>
515.6 + <style type="text/css">
515.7 + .occurrence {BACKGROUND: #DDDD00;}
515.8 + </style>
515.9 +</head>
515.10 +<body>
515.11 +<pre><#list occurrences as occurrence>${occurrence.prefix}<span class="occurrence">${occurrence.occurrence}</span></#list>${suffix}</pre>
515.12 +</body>
515.13 +</html>
516.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
516.2 +++ b/sandbox/old-modules/server/web.api/src/org/netbeans/modules/jackpot30/server/webapi/ui-search.html Mon Mar 12 21:10:10 2012 +0100
516.3 @@ -0,0 +1,70 @@
516.4 +<html>
516.5 +<head>
516.6 + <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
516.7 +<#if results??>
516.8 + <script type="text/javascript">
516.9 + $(document).ready(function() {
516.10 + $('#list').find('dd').hide().end().find('dt').click(function() {
516.11 + current_dd=$(this).next();
516.12 + //XXX: will do the AJAX call for both show and hide!
516.13 + $.get("snippet?path=${selectedPath}&relative=" + current_dd.attr("id") + "&pattern=${patternEscaped}",function(data) {
516.14 + current_dd.html(data).slideToggle();
516.15 + })
516.16 + });
516.17 + });
516.18 + </script>
516.19 +</#if>
516.20 + <style type="text/css">
516.21 + .occurrence {BACKGROUND: #DDDD00;}
516.22 + </style>
516.23 +</head>
516.24 +<body>
516.25 +<form method="get">
516.26 +
516.27 +<label for="path">Project:</label>
516.28 +<select size="1" name="path">");
516.29 + <#list paths as path>
516.30 + <option <#if selectedPath?? && path.segment == selectedPath>selected</#if> value="${path.segment}">
516.31 + ${path.displayName}
516.32 + </option>
516.33 + </#list>
516.34 +</select>
516.35 +<br>
516.36 +<label for="pattern">Pattern:</label><br>
516.37 +<textarea rows="10" cols="40" name="pattern">
516.38 +<#if pattern??>
516.39 +${pattern}
516.40 +</#if>
516.41 +</textarea><br>
516.42 +<input type="submit" name="Find Candidates"/>
516.43 +</form>
516.44 +
516.45 +<div class="examples">
516.46 +<#if examples??>
516.47 + Examples:
516.48 + <dl id="examples-list">
516.49 + <#list examples as example>
516.50 + <dt>${example.displayName}</dt>
516.51 + <dd><pre>${example.pattern}</pre>
516.52 + </dd>
516.53 + </#list>
516.54 + </dl>
516.55 +</#if>
516.56 +</div>
516.57 +
516.58 +<#if results??>
516.59 + Found candidates for pattern: ${pattern}
516.60 + <dl id="list">
516.61 + <#list results as result>
516.62 + <dt>${result.relativePath}<a href="/index/ui/show?path=${selectedPath}&relative=${result.relativePath}&pattern=${patternEscaped}">show</a></dt>
516.63 + <dd id="${result.relativePath}">
516.64 + </dd>
516.65 + </#list>
516.66 + </dl>
516.67 +</#if>
516.68 +
516.69 +<#if statistics??>
516.70 + Query time: ${statistics.queryTime}ms, matching files: ${statistics.files}.
516.71 +</#if>
516.72 +</body>
516.73 +</html>
517.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
517.2 +++ b/sandbox/old-modules/server/web.api/src/org/netbeans/modules/jackpot30/server/webapi/ui-snippet.html Mon Mar 12 21:10:10 2012 +0100
517.3 @@ -0,0 +1,7 @@
517.4 +<#if snippets??>
517.5 + <#list snippets as snippet>
517.6 + <pre>${snippet.prefix}<span class="occurrence">${snippet.occurrence}</span>${snippet.suffix}</pre><br>
517.7 + </#list>
517.8 +<#else>
517.9 + No occurrences.
517.10 +</#if>
518.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
518.2 +++ b/sandbox/old-modules/server/web.api/test/org/netbeans/modules/jackpot30/server/webapi/APITest.java Mon Mar 12 21:10:10 2012 +0100
518.3 @@ -0,0 +1,107 @@
518.4 +/*
518.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
518.6 + *
518.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
518.8 + *
518.9 + * The contents of this file are subject to the terms of either the GNU
518.10 + * General Public License Version 2 only ("GPL") or the Common
518.11 + * Development and Distribution License("CDDL") (collectively, the
518.12 + * "License"). You may not use this file except in compliance with the
518.13 + * License. You can obtain a copy of the License at
518.14 + * http://www.netbeans.org/cddl-gplv2.html
518.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
518.16 + * specific language governing permissions and limitations under the
518.17 + * License. When distributing the software, include this License Header
518.18 + * Notice in each file and include the License file at
518.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
518.20 + * particular file as subject to the "Classpath" exception as provided
518.21 + * by Sun in the GPL Version 2 section of the License file that
518.22 + * accompanied this code. If applicable, add the following below the
518.23 + * License Header, with the fields enclosed by brackets [] replaced by
518.24 + * your own identifying information:
518.25 + * "Portions Copyrighted [year] [name of copyright owner]"
518.26 + *
518.27 + * If you wish your version of this file to be governed by only the CDDL
518.28 + * or only the GPL Version 2, indicate your decision by adding
518.29 + * "[Contributor] elects to include this software in this distribution
518.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
518.31 + * single choice of license, a recipient has the option to distribute
518.32 + * your version of this file under either the CDDL, the GPL Version 2 or
518.33 + * to extend the choice of license to its licensees as provided above.
518.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
518.35 + * Version 2 license, then the option applies only if the new code is
518.36 + * made subject to such option by the copyright holder.
518.37 + *
518.38 + * Contributor(s):
518.39 + *
518.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
518.41 + */
518.42 +
518.43 +package org.netbeans.modules.jackpot30.server.webapi;
518.44 +
518.45 +import java.io.ByteArrayInputStream;
518.46 +import java.io.File;
518.47 +import java.io.FileOutputStream;
518.48 +import java.io.InputStream;
518.49 +import org.junit.Assert;
518.50 +import org.junit.Before;
518.51 +import org.junit.Test;
518.52 +import org.netbeans.modules.jackpot30.impl.indexing.Cache;
518.53 +import org.netbeans.modules.jackpot30.server.indexer.StandaloneIndexer;
518.54 +
518.55 +/**
518.56 + *
518.57 + * @author lahvac
518.58 + */
518.59 +public class APITest {
518.60 +
518.61 + public APITest() {
518.62 + }
518.63 +
518.64 + private File src;
518.65 +
518.66 + @Before
518.67 + public void setUp() throws Exception {
518.68 + File source = new File(APITest.class.getProtectionDomain().getCodeSource().getLocation().getPath());
518.69 + File workingDirectory = new File(source.getParentFile(), "wd");
518.70 + File cache = new File(workingDirectory, "cache");
518.71 +
518.72 + src = new File(workingDirectory, "src");
518.73 +
518.74 + Cache.setStandaloneCacheRoot(cache);
518.75 +
518.76 + copyStringToFile(new File(src, "test/Test1.java"), "package test; public class Test {private void test() { new java.io.File(\"\").isDirectory(); } }");
518.77 +
518.78 + StandaloneIndexer.index(src, false, false, null, null);
518.79 + }
518.80 +
518.81 + public final static void copyStringToFile (File f, String content) throws Exception {
518.82 + f.getParentFile().mkdirs();
518.83 +
518.84 + FileOutputStream os = new FileOutputStream(f);
518.85 + InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
518.86 + int read;
518.87 + while ((read = is.read()) != (-1)) {
518.88 + os.write(read);
518.89 + }
518.90 + os.close ();
518.91 + is.close();
518.92 + }
518.93 +
518.94 + @Test
518.95 + public void testFind() throws Exception {
518.96 + String cacheKey = null;
518.97 +
518.98 + for (String key : Cache.knownSourceRoots()) {
518.99 + if (src.getAbsolutePath().equals(Cache.sourceRootForKey(key).getAbsolutePath())) {
518.100 + cacheKey = key;
518.101 + break;
518.102 + }
518.103 + }
518.104 +
518.105 + Assert.assertNotNull(cacheKey);
518.106 +
518.107 + Assert.assertEquals("test/Test1.java\n", new API().find(cacheKey, "$1.isDirectory()"));
518.108 + }
518.109 +
518.110 +}
518.111 \ No newline at end of file
519.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
519.2 +++ b/sandbox/old-modules/transformer/build.xml Mon Mar 12 21:10:10 2012 +0100
519.3 @@ -0,0 +1,9 @@
519.4 +<?xml version="1.0" encoding="UTF-8"?>
519.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
519.6 +<!-- for some information on what you could do (e.g. targets to override). -->
519.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
519.8 +<project name="org.netbeans.modules.jackpot30.transformers" default="netbeans" basedir=".">
519.9 + <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.transformers.</description>
519.10 + <import file="nbproject/build-impl.xml"/>
519.11 + <import file="${suite.dir}/findbugs-import.xml"/>
519.12 +</project>
520.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
520.2 +++ b/sandbox/old-modules/transformer/manifest.mf Mon Mar 12 21:10:10 2012 +0100
520.3 @@ -0,0 +1,7 @@
520.4 +Manifest-Version: 1.0
520.5 +AutoUpdate-Show-In-Client: false
520.6 +OpenIDE-Module: org.netbeans.modules.jackpot30.transformers
520.7 +OpenIDE-Module-Layer: org/netbeans/modules/jackpot30/transformers/resources/layer.xml
520.8 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/transformers/resources/Bundle.properties
520.9 +OpenIDE-Module-Specification-Version: 1.16
520.10 +
521.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
521.2 +++ b/sandbox/old-modules/transformer/nbproject/build-impl.xml Mon Mar 12 21:10:10 2012 +0100
521.3 @@ -0,0 +1,45 @@
521.4 +<?xml version="1.0" encoding="UTF-8"?>
521.5 +<!--
521.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
521.7 +*** EDIT ../build.xml INSTEAD ***
521.8 +-->
521.9 +<project name="org.netbeans.modules.jackpot30.transformers-impl" basedir="..">
521.10 + <fail message="Please build using Ant 1.7.1 or higher.">
521.11 + <condition>
521.12 + <not>
521.13 + <antversion atleast="1.7.1"/>
521.14 + </not>
521.15 + </condition>
521.16 + </fail>
521.17 + <property file="nbproject/private/suite-private.properties"/>
521.18 + <property file="nbproject/suite.properties"/>
521.19 + <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
521.20 + <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
521.21 + <property file="${suite.dir}/nbproject/platform.properties"/>
521.22 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
521.23 + <attribute name="name"/>
521.24 + <attribute name="value"/>
521.25 + <sequential>
521.26 + <property name="@{name}" value="${@{value}}"/>
521.27 + </sequential>
521.28 + </macrodef>
521.29 + <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
521.30 + <attribute name="property"/>
521.31 + <attribute name="value"/>
521.32 + <sequential>
521.33 + <property name="@{property}" value="@{value}"/>
521.34 + </sequential>
521.35 + </macrodef>
521.36 + <property file="${user.properties.file}"/>
521.37 + <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
521.38 + <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
521.39 + <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
521.40 + <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
521.41 + <condition>
521.42 + <not>
521.43 + <contains string="${cluster.path.evaluated}" substring="platform"/>
521.44 + </not>
521.45 + </condition>
521.46 + </fail>
521.47 + <import file="${harness.dir}/build.xml"/>
521.48 +</project>
522.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
522.2 +++ b/sandbox/old-modules/transformer/nbproject/genfiles.properties Mon Mar 12 21:10:10 2012 +0100
522.3 @@ -0,0 +1,8 @@
522.4 +build.xml.data.CRC32=ec1a83f8
522.5 +build.xml.script.CRC32=14b2fe09
522.6 +build.xml.stylesheet.CRC32=79c3b980@1.28.0.7
522.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
522.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
522.9 +nbproject/build-impl.xml.data.CRC32=9e6fb388
522.10 +nbproject/build-impl.xml.script.CRC32=07a96417
522.11 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.47
523.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
523.2 +++ b/sandbox/old-modules/transformer/nbproject/project.properties Mon Mar 12 21:10:10 2012 +0100
523.3 @@ -0,0 +1,2 @@
523.4 +javac.source=1.5
523.5 +javac.compilerargs=-Xlint -Xlint:-serial
524.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
524.2 +++ b/sandbox/old-modules/transformer/nbproject/project.xml Mon Mar 12 21:10:10 2012 +0100
524.3 @@ -0,0 +1,157 @@
524.4 +<?xml version="1.0" encoding="UTF-8"?>
524.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
524.6 + <type>org.netbeans.modules.apisupport.project</type>
524.7 + <configuration>
524.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
524.9 + <code-name-base>org.netbeans.modules.jackpot30.transformers</code-name-base>
524.10 + <suite-component/>
524.11 + <module-dependencies>
524.12 + <dependency>
524.13 + <code-name-base>org.netbeans.api.java.classpath</code-name-base>
524.14 + <build-prerequisite/>
524.15 + <compile-dependency/>
524.16 + <run-dependency>
524.17 + <release-version>1</release-version>
524.18 + <specification-version>1.19</specification-version>
524.19 + </run-dependency>
524.20 + </dependency>
524.21 + <dependency>
524.22 + <code-name-base>org.netbeans.libs.javacapi</code-name-base>
524.23 + <build-prerequisite/>
524.24 + <compile-dependency/>
524.25 + <run-dependency>
524.26 + <specification-version>0.8.0.1</specification-version>
524.27 + </run-dependency>
524.28 + </dependency>
524.29 + <dependency>
524.30 + <code-name-base>org.netbeans.modules.jackpot30.api</code-name-base>
524.31 + <build-prerequisite/>
524.32 + <compile-dependency/>
524.33 + <run-dependency>
524.34 + <specification-version>1.0</specification-version>
524.35 + </run-dependency>
524.36 + </dependency>
524.37 + <dependency>
524.38 + <code-name-base>org.netbeans.modules.java.hints</code-name-base>
524.39 + <build-prerequisite/>
524.40 + <compile-dependency/>
524.41 + <run-dependency>
524.42 + <release-version>1</release-version>
524.43 + <implementation-version/>
524.44 + </run-dependency>
524.45 + </dependency>
524.46 + <dependency>
524.47 + <code-name-base>org.netbeans.modules.java.source</code-name-base>
524.48 + <build-prerequisite/>
524.49 + <compile-dependency/>
524.50 + <run-dependency>
524.51 + <specification-version>0.43.0.7.7.1</specification-version>
524.52 + </run-dependency>
524.53 + </dependency>
524.54 + <dependency>
524.55 + <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
524.56 + <build-prerequisite/>
524.57 + <compile-dependency/>
524.58 + <run-dependency>
524.59 + <release-version>0-1</release-version>
524.60 + <specification-version>1.7.0.7.2</specification-version>
524.61 + </run-dependency>
524.62 + </dependency>
524.63 + <dependency>
524.64 + <code-name-base>org.openide.filesystems</code-name-base>
524.65 + <build-prerequisite/>
524.66 + <compile-dependency/>
524.67 + <run-dependency>
524.68 + <specification-version>7.21.0.1.1</specification-version>
524.69 + </run-dependency>
524.70 + </dependency>
524.71 + <dependency>
524.72 + <code-name-base>org.openide.modules</code-name-base>
524.73 + <build-prerequisite/>
524.74 + <compile-dependency/>
524.75 + <run-dependency>
524.76 + <specification-version>7.10</specification-version>
524.77 + </run-dependency>
524.78 + </dependency>
524.79 + <dependency>
524.80 + <code-name-base>org.openide.util</code-name-base>
524.81 + <build-prerequisite/>
524.82 + <compile-dependency/>
524.83 + <run-dependency>
524.84 + <specification-version>7.22.0.1</specification-version>
524.85 + </run-dependency>
524.86 + </dependency>
524.87 + <dependency>
524.88 + <code-name-base>org.openide.util.lookup</code-name-base>
524.89 + <build-prerequisite/>
524.90 + <compile-dependency/>
524.91 + <run-dependency>
524.92 + <specification-version>8.0.0.1</specification-version>
524.93 + </run-dependency>
524.94 + </dependency>
524.95 + </module-dependencies>
524.96 + <test-dependencies>
524.97 + <test-type>
524.98 + <name>unit</name>
524.99 + <test-dependency>
524.100 + <code-name-base>org.netbeans.bootstrap</code-name-base>
524.101 + </test-dependency>
524.102 + <test-dependency>
524.103 + <code-name-base>org.netbeans.core.startup</code-name-base>
524.104 + </test-dependency>
524.105 + <test-dependency>
524.106 + <code-name-base>org.netbeans.libs.junit4</code-name-base>
524.107 + <compile-dependency/>
524.108 + </test-dependency>
524.109 + <test-dependency>
524.110 + <code-name-base>org.netbeans.modules.classfile</code-name-base>
524.111 + </test-dependency>
524.112 + <test-dependency>
524.113 + <code-name-base>org.netbeans.modules.defaults</code-name-base>
524.114 + </test-dependency>
524.115 + <test-dependency>
524.116 + <code-name-base>org.netbeans.modules.editor</code-name-base>
524.117 + </test-dependency>
524.118 + <test-dependency>
524.119 + <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
524.120 + </test-dependency>
524.121 + <test-dependency>
524.122 + <code-name-base>org.netbeans.modules.editor.settings</code-name-base>
524.123 + </test-dependency>
524.124 + <test-dependency>
524.125 + <code-name-base>org.netbeans.modules.editor.settings.storage</code-name-base>
524.126 + </test-dependency>
524.127 + <test-dependency>
524.128 + <code-name-base>org.netbeans.modules.editor.util</code-name-base>
524.129 + </test-dependency>
524.130 + <test-dependency>
524.131 + <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
524.132 + <recursive/>
524.133 + <compile-dependency/>
524.134 + </test-dependency>
524.135 + <test-dependency>
524.136 + <code-name-base>org.netbeans.modules.java.lexer</code-name-base>
524.137 + </test-dependency>
524.138 + <test-dependency>
524.139 + <code-name-base>org.netbeans.modules.masterfs</code-name-base>
524.140 + </test-dependency>
524.141 + <test-dependency>
524.142 + <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
524.143 + <recursive/>
524.144 + <compile-dependency/>
524.145 + </test-dependency>
524.146 + <test-dependency>
524.147 + <code-name-base>org.netbeans.modules.progress.ui</code-name-base>
524.148 + </test-dependency>
524.149 + <test-dependency>
524.150 + <code-name-base>org.netbeans.modules.projectui</code-name-base>
524.151 + </test-dependency>
524.152 + <test-dependency>
524.153 + <code-name-base>org.openidex.util</code-name-base>
524.154 + </test-dependency>
524.155 + </test-type>
524.156 + </test-dependencies>
524.157 + <public-packages/>
524.158 + </data>
524.159 + </configuration>
524.160 +</project>
525.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
525.2 +++ b/sandbox/old-modules/transformer/nbproject/suite.properties Mon Mar 12 21:10:10 2012 +0100
525.3 @@ -0,0 +1,1 @@
525.4 +suite.dir=${basedir}/..
526.1 Binary file sandbox/old-modules/transformer/release/libs/annotations.jar has changed
527.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
527.2 +++ b/sandbox/old-modules/transformer/src/org/netbeans/modules/jackpot30/transformers/Annotations.java Mon Mar 12 21:10:10 2012 +0100
527.3 @@ -0,0 +1,70 @@
527.4 +/*
527.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
527.6 + *
527.7 + * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
527.8 + *
527.9 + * The contents of this file are subject to the terms of either the GNU
527.10 + * General Public License Version 2 only ("GPL") or the Common
527.11 + * Development and Distribution License("CDDL") (collectively, the
527.12 + * "License"). You may not use this file except in compliance with the
527.13 + * License. You can obtain a copy of the License at
527.14 + * http://www.netbeans.org/cddl-gplv2.html
527.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
527.16 + * specific language governing permissions and limitations under the
527.17 + * License. When distributing the software, include this License Header
527.18 + * Notice in each file and include the License file at
527.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
527.20 + * particular file as subject to the "Classpath" exception as provided
527.21 + * by Sun in the GPL Version 2 section of the License file that
527.22 + * accompanied this code. If applicable, add the following below the
527.23 + * License Header, with the fields enclosed by brackets [] replaced by
527.24 + * your own identifying information:
527.25 + * "Portions Copyrighted [year] [name of copyright owner]"
527.26 + *
527.27 + * If you wish your version of this file to be governed by only the CDDL
527.28 + * or only the GPL Version 2, indicate your decision by adding
527.29 + * "[Contributor] elects to include this software in this distribution
527.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
527.31 + * single choice of license, a recipient has the option to distribute
527.32 + * your version of this file under either the CDDL, the GPL Version 2 or
527.33 + * to extend the choice of license to its licensees as provided above.
527.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
527.35 + * Version 2 license, then the option applies only if the new code is
527.36 + * made subject to such option by the copyright holder.
527.37 + *
527.38 + * Contributor(s):
527.39 + *
527.40 + * Portions Copyrighted 2008-2009 Sun Microsystems, Inc.
527.41 + */
527.42 +
527.43 +package org.netbeans.modules.jackpot30.transformers;
527.44 +
527.45 +/**
527.46 + *
527.47 + * @author Jan Lahoda
527.48 + */
527.49 +public enum Annotations {
527.50 +
527.51 + TRANSFORMATION_SET("TransformationSet"),
527.52 + TRANSFORMATION,
527.53 + FIX,
527.54 + PATTERN,
527.55 + CONSTRAINT;
527.56 +
527.57 + private static final String PACKAGE_NAME = "net.java.lang.annotations.";
527.58 +
527.59 + private final String specialName;
527.60 +
527.61 + private Annotations() {
527.62 + this(null);
527.63 + }
527.64 +
527.65 + private Annotations(String specialName) {
527.66 + this.specialName = specialName;
527.67 + }
527.68 +
527.69 + public String toFQN() {
527.70 + return PACKAGE_NAME + (specialName != null ? specialName : name().charAt(0) + name().substring(1).toLowerCase());
527.71 + }
527.72 +
527.73 +}
528.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
528.2 +++ b/sandbox/old-modules/transformer/src/org/netbeans/modules/jackpot30/transformers/TransformationHintProviderImpl.java Mon Mar 12 21:10:10 2012 +0100
528.3 @@ -0,0 +1,508 @@
528.4 +/*
528.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
528.6 + *
528.7 + * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
528.8 + *
528.9 + * The contents of this file are subject to the terms of either the GNU
528.10 + * General Public License Version 2 only ("GPL") or the Common
528.11 + * Development and Distribution License("CDDL") (collectively, the
528.12 + * "License"). You may not use this file except in compliance with the
528.13 + * License. You can obtain a copy of the License at
528.14 + * http://www.netbeans.org/cddl-gplv2.html
528.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
528.16 + * specific language governing permissions and limitations under the
528.17 + * License. When distributing the software, include this License Header
528.18 + * Notice in each file and include the License file at
528.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
528.20 + * particular file as subject to the "Classpath" exception as provided
528.21 + * by Sun in the GPL Version 2 section of the License file that
528.22 + * accompanied this code. If applicable, add the following below the
528.23 + * License Header, with the fields enclosed by brackets [] replaced bysanno
528.24 + * your own identifying information:
528.25 + * "Portions Copyrighted [year] [name of copyright owner]"
528.26 + *
528.27 + * If you wish your version of this file to be governed by only the CDDL
528.28 + * or only the GPL Version 2, indicate your decision by adding
528.29 + * "[Contributor] elects to include this software in this distribution
528.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
528.31 + * single choice of license, a recipient has the option to distribute
528.32 + * your version of this file under either the CDDL, the GPL Version 2 or
528.33 + * to extend the choice of license to its licensees as provided above.
528.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
528.35 + * Version 2 license, then the option applies only if the new code is
528.36 + * made subject to such option by the copyright holder.
528.37 + *
528.38 + * Contributor(s):
528.39 + *
528.40 + * Portions Copyrighted 2008-2009 Sun Microsystems, Inc.
528.41 + */
528.42 +
528.43 +package org.netbeans.modules.jackpot30.transformers;
528.44 +
528.45 +import org.netbeans.modules.java.hints.jackpot.spi.Trigger.PatternDescription;
528.46 +import org.netbeans.modules.java.hints.spi.AbstractHint.HintSeverity;
528.47 +import org.netbeans.modules.java.hints.jackpot.spi.support.ErrorDescriptionFactory;
528.48 +import org.netbeans.modules.java.hints.jackpot.spi.ElementBasedHintProvider;
528.49 +import org.netbeans.modules.java.hints.jackpot.spi.HintContext;
528.50 +import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
528.51 +import org.netbeans.modules.java.hints.jackpot.spi.HintDescription.Worker;
528.52 +import org.netbeans.modules.java.hints.jackpot.spi.HintDescriptionFactory;
528.53 +import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata;
528.54 +import org.netbeans.modules.java.hints.jackpot.spi.JavaFix;
528.55 +import com.sun.source.tree.Tree;
528.56 +import com.sun.source.util.SourcePositions;
528.57 +import com.sun.source.util.TreePath;
528.58 +import java.io.File;
528.59 +import java.io.IOException;
528.60 +import java.net.URL;
528.61 +import java.util.Collection;
528.62 +import java.util.Collections;
528.63 +import java.util.EnumSet;
528.64 +import java.util.HashMap;
528.65 +import java.util.HashSet;
528.66 +import java.util.LinkedList;
528.67 +import java.util.List;
528.68 +import java.util.Map;
528.69 +import java.util.Map.Entry;
528.70 +import java.util.Set;
528.71 +import java.util.concurrent.atomic.AtomicBoolean;
528.72 +import java.util.regex.Matcher;
528.73 +import javax.lang.model.element.AnnotationMirror;
528.74 +import javax.lang.model.element.AnnotationValue;
528.75 +import javax.lang.model.element.Element;
528.76 +import javax.lang.model.element.ElementKind;
528.77 +import javax.lang.model.element.ExecutableElement;
528.78 +import javax.lang.model.element.Modifier;
528.79 +import javax.lang.model.element.PackageElement;
528.80 +import javax.lang.model.element.TypeElement;
528.81 +import javax.lang.model.type.DeclaredType;
528.82 +import javax.lang.model.type.TypeMirror;
528.83 +import javax.lang.model.util.ElementFilter;
528.84 +import org.netbeans.api.java.classpath.ClassPath;
528.85 +import org.netbeans.api.java.source.ClasspathInfo;
528.86 +import org.netbeans.api.java.source.ClasspathInfo.PathKind;
528.87 +import org.netbeans.api.java.source.CompilationController;
528.88 +import org.netbeans.api.java.source.CompilationInfo;
528.89 +import org.netbeans.api.java.source.ElementHandle;
528.90 +import org.netbeans.api.java.source.JavaSource;
528.91 +import org.netbeans.api.java.source.Task;
528.92 +import org.netbeans.api.java.source.TypeMirrorHandle;
528.93 +import org.netbeans.api.java.source.support.CancellableTreePathScanner;
528.94 +import org.netbeans.spi.editor.hints.ErrorDescription;
528.95 +import org.netbeans.spi.editor.hints.Fix;
528.96 +import org.netbeans.spi.java.classpath.support.ClassPathSupport;
528.97 +import org.openide.filesystems.FileUtil;
528.98 +import org.openide.modules.InstalledFileLocator;
528.99 +import org.openide.util.Exceptions;
528.100 +
528.101 +import org.openide.util.lookup.ServiceProvider;
528.102 +import static org.netbeans.modules.jackpot30.transformers.Annotations.*;
528.103 +
528.104 +/**
528.105 + *
528.106 + * @author Jan Lahoda
528.107 + */
528.108 +@ServiceProvider(service=ElementBasedHintProvider.class)
528.109 +public class TransformationHintProviderImpl implements ElementBasedHintProvider {
528.110 +
528.111 + private JavaSource prepareJavaSource(CompilationInfo info) {
528.112 + ClasspathInfo currentCP = info.getClasspathInfo();
528.113 + ClassPath overlayCompileCP = prepareOverlayCompileCP();
528.114 + ClassPath extendedCompileCP = ClassPathSupport.createProxyClassPath(overlayCompileCP, currentCP.getClassPath(PathKind.COMPILE));
528.115 + ClassPath overlayBootCP = prepareOverlayBootCP();
528.116 + ClassPath extendedBootCP = ClassPathSupport.createProxyClassPath(overlayBootCP, currentCP.getClassPath(PathKind.BOOT));
528.117 + ClasspathInfo extendedCPInfo = ClasspathInfo.create(extendedBootCP, extendedCompileCP, currentCP.getClassPath(PathKind.SOURCE));
528.118 +
528.119 + return JavaSource.create(extendedCPInfo);
528.120 + }
528.121 +
528.122 + public Collection<? extends HintDescription> computeHints(final CompilationInfo info) {
528.123 + final List<HintDescription> hints = new LinkedList<HintDescription>();
528.124 +
528.125 + if (ANNOTATIONS_JAR != null && (JDK_OVERLAY_JAR != null || NB_OVERLAY_JAR != null)) {
528.126 + try {
528.127 + prepareJavaSource(info).runUserActionTask(new Task<CompilationController>() {
528.128 + public void run(final CompilationController overlayInfo) throws Exception {
528.129 + List<HintDescription> w = doComputeHints(info, overlayInfo);
528.130 +
528.131 + if (w != null) {
528.132 + hints.addAll(w);
528.133 + }
528.134 + }
528.135 + }, true);
528.136 + } catch (IOException ex) {
528.137 + Exceptions.printStackTrace(ex);
528.138 + }
528.139 + } else {
528.140 + List<HintDescription> w = doComputeHints(info, null);
528.141 +
528.142 + if (w != null) {
528.143 + hints.addAll(w);
528.144 + }
528.145 + }
528.146 +
528.147 + return hints;
528.148 + }
528.149 +
528.150 + private static final Set<ElementKind> KINDS_FOR_ELEMENT_HANDLE = EnumSet.of(
528.151 + ElementKind.PACKAGE, ElementKind.CLASS, ElementKind.INTERFACE, ElementKind.ENUM,
528.152 + ElementKind.ANNOTATION_TYPE, ElementKind.METHOD, ElementKind.CONSTRUCTOR,
528.153 + ElementKind.INSTANCE_INIT, ElementKind.STATIC_INIT, ElementKind.FIELD,
528.154 + ElementKind.ENUM_CONSTANT);
528.155 +
528.156 + private List<HintDescription> doComputeHints(CompilationInfo info,
528.157 + CompilationInfo overlayInfo) {
528.158 +
528.159 + FindAnnotation ann = new FindAnnotation(info, overlayInfo, /*XXX*/new AtomicBoolean());
528.160 +
528.161 + ann.scan(info.getCompilationUnit(), null);
528.162 +
528.163 + return ann.hints;
528.164 + }
528.165 +
528.166 + private final class FindAnnotation extends CancellableTreePathScanner<Void, Void> {
528.167 +
528.168 + private final CompilationInfo info;
528.169 + private final CompilationInfo overlayInfo;
528.170 + private final List<HintDescription> hints = new LinkedList<HintDescription>();
528.171 +
528.172 + public FindAnnotation(CompilationInfo info, CompilationInfo overlayInfo, AtomicBoolean cancel) {
528.173 + super(cancel);
528.174 + this.info = info;
528.175 + this.overlayInfo = overlayInfo;
528.176 + }
528.177 +
528.178 + private final Set<Element> handledElements = new HashSet<Element>();
528.179 +
528.180 + private void handleElementImpl(Element el) {
528.181 + if (!handledElements.add(el)) return ;
528.182 +
528.183 + List<HintDescription> currentHints = processAnnotations(el, el.getEnclosingElement(), info, info);
528.184 +
528.185 + if (overlayInfo != null && currentHints.isEmpty() && KINDS_FOR_ELEMENT_HANDLE.contains(el.getKind())) {
528.186 + Element overlay = ElementHandle.create(el).resolve(overlayInfo);
528.187 +
528.188 + if (overlay != null) {
528.189 + currentHints = processAnnotations(overlay, overlay.getEnclosingElement(), info, overlayInfo);
528.190 + }
528.191 + }
528.192 +
528.193 + this.hints.addAll(currentHints);
528.194 + }
528.195 +
528.196 + private void handleElement(Element el) {
528.197 + PackageElement p = info.getElements().getPackageOf(el);
528.198 +
528.199 + while (p != el) {
528.200 + handleElementImpl(el);
528.201 + el = el.getEnclosingElement();
528.202 + }
528.203 +
528.204 + handleElementImpl(p);
528.205 + }
528.206 +
528.207 + @Override
528.208 + public Void scan(Tree tree, Void p) {
528.209 + if (tree == null) return null;
528.210 +
528.211 + TreePath tp = new TreePath(getCurrentPath(), tree);
528.212 + Element el = info.getTrees().getElement(tp);
528.213 +
528.214 + if (el != null) {
528.215 + handleElement(el);
528.216 + }
528.217 +
528.218 + return super.scan(tree, p);
528.219 + }
528.220 + }
528.221 +
528.222 + private static final class WorkerImpl implements Worker {
528.223 +
528.224 + private final String displayName;
528.225 + private final List<FixDescription> fixDescriptions;
528.226 +
528.227 + public WorkerImpl(String displayName, List<FixDescription> fixDescriptions) {
528.228 + this.displayName = displayName;
528.229 + this.fixDescriptions = fixDescriptions;
528.230 + }
528.231 +
528.232 + public Collection<? extends ErrorDescription> createErrors(HintContext ctx) {
528.233 + //XXX: antipatterns not supported by the current infrastructure
528.234 +// TreePath tp = treePath;
528.235 +//
528.236 +// while (tp != null) {
528.237 +// if (!pd.getPattern().checkAntipatterns(tp)) {
528.238 +// return null;
528.239 +// }
528.240 +//
528.241 +// tp = tp.getParentPath();
528.242 +// }
528.243 +
528.244 + List<Fix> fixes = new LinkedList<Fix>();
528.245 +
528.246 + for (FixDescription d : fixDescriptions) {
528.247 + String dn = d.getDisplayName();
528.248 +
528.249 + if (dn.length() == 0) {
528.250 + dn = defaultFixDisplayName(ctx.getInfo(), ctx.getVariables(), d);
528.251 + }
528.252 +
528.253 + fixes.add(JavaFix.rewriteFix(ctx.getInfo(), dn, ctx.getPath(), d.getPattern(), ctx.getVariables(), ctx.getMultiVariables(), ctx.getVariableNames(), Collections.<String, TypeMirror>emptyMap()/*XXX: pd.pattern.getConstraints()*/));
528.254 + }
528.255 +
528.256 + return Collections.singletonList(ErrorDescriptionFactory.forName(ctx, ctx.getPath(), displayName, fixes.toArray(new Fix[0])));
528.257 + }
528.258 + }
528.259 +
528.260 + private static <T> T findValue(AnnotationMirror m, String name, Class<T> clazz) {
528.261 + for (Entry<? extends ExecutableElement, ? extends AnnotationValue> e : m.getElementValues().entrySet()) {
528.262 + if (name.equals(e.getKey().getSimpleName().toString())) {
528.263 + return clazz.cast(e.getValue().getValue());
528.264 + }
528.265 + }
528.266 +
528.267 + TypeElement te = (TypeElement) m.getAnnotationType().asElement();
528.268 +
528.269 + for (ExecutableElement ee : ElementFilter.methodsIn(te.getEnclosedElements())) {
528.270 + if (name.equals(ee.getSimpleName().toString())) {
528.271 + if (ee.getDefaultValue() == null) {
528.272 + return null;
528.273 + }
528.274 + return clazz.cast(ee.getDefaultValue().getValue());
528.275 + }
528.276 + }
528.277 +
528.278 + return null;
528.279 + }
528.280 +
528.281 + private static HintDescription create(CompilationInfo info, Element el, AnnotationMirror transformation, String id, CompilationInfo fake) {
528.282 + Collection rawPatterns = findValue(transformation, "pattern", Collection.class);
528.283 +
528.284 + if (rawPatterns == null || rawPatterns.isEmpty()) {
528.285 + return null;
528.286 + }
528.287 +
528.288 + Iterable<AnnotationMirror> patterns = Utilities.checkedIterableByFilter(rawPatterns, AnnotationMirror.class, true);
528.289 +
528.290 + String patternString = findValue(patterns.iterator().next(), "value", String.class);
528.291 +
528.292 + if (patternString == null) {
528.293 + return null;
528.294 + }
528.295 +
528.296 + Collection rawConstraints = findValue(transformation, "constraint", Collection.class);
528.297 +
528.298 + if (rawConstraints == null) {
528.299 + return null;
528.300 + }
528.301 +
528.302 + Iterable<AnnotationMirror> constraints = Utilities.checkedIterableByFilter(rawConstraints, AnnotationMirror.class, true);
528.303 + Map<String, String> variableTypes = new HashMap<String, String>();
528.304 +
528.305 + for (AnnotationMirror m : constraints) {
528.306 + String var = findValue(m, "variable", String.class);
528.307 + TypeMirror tm = findValue(m, "type", TypeMirror.class);
528.308 +
528.309 + if (var == null || tm == null) {
528.310 + return null;
528.311 + }
528.312 +
528.313 + variableTypes.put(var, tm.toString()); //XXX: toString()
528.314 + }
528.315 +
528.316 + if (!el.getModifiers().contains(Modifier.STATIC) && !variableTypes.containsKey("$this")) {
528.317 + TypeMirror parent = el.getEnclosingElement().asType();
528.318 +
528.319 + variableTypes.put("$this", TypeMirrorHandle.create(fake.getTypes().erasure(parent)).resolve(info).toString()); //XXX: toString()
528.320 + }
528.321 +
528.322 + List<String> aps = new LinkedList<String>();
528.323 +
528.324 + for (AnnotationMirror ap : Utilities.checkedIterableByFilter(findValue(transformation, "antipattern", Collection.class), AnnotationMirror.class, true)) {
528.325 + aps.add(findValue(ap, "value", String.class));
528.326 + }
528.327 +
528.328 + List<FixDescription> fixes = new LinkedList<FixDescription>();
528.329 + Collection rawFixes = findValue(transformation, "fix", Collection.class);
528.330 +
528.331 + if (rawFixes == null) {
528.332 + return null;
528.333 + }
528.334 +
528.335 + for (AnnotationMirror f : Utilities.checkedIterableByFilter(rawFixes, AnnotationMirror.class, true)) {
528.336 + String dn = findValue(f, "displayName", String.class);
528.337 + String to = findValue(f, "value", String.class);
528.338 +
528.339 + if (dn == null || to == null) {
528.340 + return null;
528.341 + }
528.342 +
528.343 + fixes.add(new FixDescription(dn, to));
528.344 + }
528.345 +
528.346 + String displayName = findValue(transformation, "displayName", String.class);
528.347 +
528.348 + if (displayName == null) {
528.349 + return null;//XXX
528.350 + }
528.351 +
528.352 + HintMetadata hm = HintMetadata.Builder.create(id).setDescription(displayName, displayName).setCategory(CATEGORY).build();
528.353 +
528.354 + return HintDescriptionFactory.create()
528.355 + .setMetadata(hm)
528.356 + .setTrigger(PatternDescription.create(patternString, variableTypes))
528.357 + .setWorker(new WorkerImpl(displayName, fixes))
528.358 + .produce();
528.359 + }
528.360 +
528.361 + private static final String CATEGORY = "Transformations";
528.362 +
528.363 + private static final class FixDescription {
528.364 + private final String displayName;
528.365 + private final String pattern;
528.366 +
528.367 + public FixDescription(String displayName, String pattern) {
528.368 + this.displayName = displayName;
528.369 + this.pattern = pattern;
528.370 + }
528.371 +
528.372 + public String getDisplayName() {
528.373 + return displayName;
528.374 + }
528.375 +
528.376 + public String getPattern() {
528.377 + return pattern;
528.378 + }
528.379 +
528.380 + }
528.381 +
528.382 + private static final File ANNOTATIONS_JAR;
528.383 + private static final File NB_OVERLAY_JAR;
528.384 + private static final File JDK_OVERLAY_JAR;
528.385 +
528.386 + static {
528.387 + ANNOTATIONS_JAR = InstalledFileLocator.getDefault().locate("libs/annotations.jar", null, false);
528.388 + NB_OVERLAY_JAR = InstalledFileLocator.getDefault().locate("overlay/org-netbeans-nboverlay.jar", null, false);
528.389 + JDK_OVERLAY_JAR = InstalledFileLocator.getDefault().locate("overlay/jdk.jar", null, false);
528.390 + }
528.391 +
528.392 + private ClassPath prepareOverlayCompileCP() throws IllegalArgumentException {
528.393 + if (NB_OVERLAY_JAR ==null) {
528.394 + return ClassPathSupport.createClassPath(new URL[0]);
528.395 + }
528.396 +
528.397 + return ClassPathSupport.createClassPath(FileUtil.urlForArchiveOrDir(NB_OVERLAY_JAR));
528.398 + }
528.399 +
528.400 + private ClassPath prepareOverlayBootCP() throws IllegalArgumentException {
528.401 + if (ANNOTATIONS_JAR == null) {
528.402 + return ClassPathSupport.createClassPath(new URL[0]);
528.403 + }
528.404 +
528.405 + if (JDK_OVERLAY_JAR == null) {
528.406 + return ClassPathSupport.createClassPath(FileUtil.urlForArchiveOrDir(ANNOTATIONS_JAR));
528.407 + }
528.408 +
528.409 + return ClassPathSupport.createClassPath(FileUtil.urlForArchiveOrDir(ANNOTATIONS_JAR), FileUtil.urlForArchiveOrDir(JDK_OVERLAY_JAR));
528.410 + }
528.411 +
528.412 + private List<HintDescription> processAnnotations(Element e, Element enclosing, CompilationInfo info, CompilationInfo fake) {
528.413 + boolean foundTransformations = false;
528.414 + List<HintDescription> result = new LinkedList<HintDescription>();
528.415 + String id;
528.416 + switch (e.getKind()) {
528.417 + case ANNOTATION_TYPE:
528.418 + case CLASS:
528.419 + case ENUM:
528.420 + case INTERFACE:
528.421 + id = fake.getElements().getBinaryName((TypeElement) e).toString();
528.422 + break;
528.423 + case FIELD:
528.424 + case ENUM_CONSTANT:
528.425 + id = fake.getElements().getBinaryName((TypeElement) enclosing).toString() + e.getSimpleName().toString();
528.426 + break;
528.427 + case CONSTRUCTOR:
528.428 + case METHOD:
528.429 + //XXX: parameters!
528.430 + id = fake.getElements().getBinaryName((TypeElement) enclosing).toString() + e.getSimpleName().toString();
528.431 + break;
528.432 + default:
528.433 + id = "no-id";
528.434 + break;
528.435 + }
528.436 +
528.437 + int index = 0;
528.438 +
528.439 + for (AnnotationMirror am : e.getAnnotationMirrors()) {
528.440 + String fqn = ((TypeElement) am.getAnnotationType().asElement()).getQualifiedName().toString();
528.441 + List<AnnotationMirror> transformations = new LinkedList<AnnotationMirror>();
528.442 + if (TRANSFORMATION.toFQN().equals(fqn)) {
528.443 + transformations.add(am);
528.444 + foundTransformations = true;
528.445 + }
528.446 + if (TRANSFORMATION_SET.toFQN().equals(fqn)) {
528.447 + for (AnnotationMirror m : Utilities.checkedIterableByFilter(findValue(am, "value", Collection.class), AnnotationMirror.class, true)) {
528.448 + transformations.add(m);
528.449 + }
528.450 + foundTransformations = true;
528.451 + }
528.452 +
528.453 + for (AnnotationMirror t : transformations) {
528.454 + HintDescription pd = create(info, e, t, id + "-" + (index++), fake);
528.455 +
528.456 + if (pd != null) {
528.457 + result.add(pd);
528.458 + }
528.459 + }
528.460 + }
528.461 +
528.462 + if (!foundTransformations && e.getKind() == ElementKind.METHOD) {
528.463 + TypeElement owner = (TypeElement) e.getEnclosingElement();
528.464 +
528.465 + for (TypeMirror tm : fake.getTypes().directSupertypes(owner.asType())) {
528.466 + DeclaredType dt = (DeclaredType) tm;
528.467 + TypeElement parent = (TypeElement) dt.asElement();
528.468 +
528.469 + for (ExecutableElement ee : ElementFilter.methodsIn(parent.getEnclosedElements())) {
528.470 + if (!fake.getElements().overrides((ExecutableElement) e, ee, (TypeElement) enclosing)) {
528.471 + continue;
528.472 + }
528.473 + List<HintDescription> r = processAnnotations(ee, enclosing, info, fake);
528.474 +
528.475 + result.addAll(r);
528.476 + }
528.477 +
528.478 + }
528.479 + }
528.480 +
528.481 + return result;
528.482 + }
528.483 +
528.484 + private static String defaultFixDisplayName(CompilationInfo info, Map<String, TreePath> variables, FixDescription d) {
528.485 + Map<String, String> stringsForVariables = new HashMap<String, String>();
528.486 +
528.487 + for (Entry<String, TreePath> e : variables.entrySet()) {
528.488 + Tree t = e.getValue().getLeaf();
528.489 + SourcePositions sp = info.getTrees().getSourcePositions();
528.490 + int startPos = (int) sp.getStartPosition(info.getCompilationUnit(), t);
528.491 + int endPos = (int) sp.getEndPosition(info.getCompilationUnit(), t);
528.492 +
528.493 + stringsForVariables.put(e.getKey(), info.getText().substring(startPos, endPos));
528.494 + }
528.495 +
528.496 + if (!stringsForVariables.containsKey("$this")) {
528.497 + stringsForVariables.put("$this", "this");
528.498 + }
528.499 +
528.500 + String replaceTarget = d.getPattern();
528.501 +
528.502 + for (Entry<String, String> e : stringsForVariables.entrySet()) {
528.503 + String quotedVariable = java.util.regex.Pattern.quote(e.getKey());
528.504 + String quotedTarget = Matcher.quoteReplacement(e.getValue());
528.505 + replaceTarget = replaceTarget.replaceAll(quotedVariable, quotedTarget);
528.506 + }
528.507 +
528.508 + return "Rewrite to " + replaceTarget;
528.509 + }
528.510 +
528.511 +}
529.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
529.2 +++ b/sandbox/old-modules/transformer/src/org/netbeans/modules/jackpot30/transformers/Utilities.java Mon Mar 12 21:10:10 2012 +0100
529.3 @@ -0,0 +1,138 @@
529.4 +/*
529.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
529.6 + *
529.7 + * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
529.8 + *
529.9 + * The contents of this file are subject to the terms of either the GNU
529.10 + * General Public License Version 2 only ("GPL") or the Common
529.11 + * Development and Distribution License("CDDL") (collectively, the
529.12 + * "License"). You may not use this file except in compliance with the
529.13 + * License. You can obtain a copy of the License at
529.14 + * http://www.netbeans.org/cddl-gplv2.html
529.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
529.16 + * specific language governing permissions and limitations under the
529.17 + * License. When distributing the software, include this License Header
529.18 + * Notice in each file and include the License file at
529.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
529.20 + * particular file as subject to the "Classpath" exception as provided
529.21 + * by Sun in the GPL Version 2 section of the License file that
529.22 + * accompanied this code. If applicable, add the following below the
529.23 + * License Header, with the fields enclosed by brackets [] replaced by
529.24 + * your own identifying information:
529.25 + * "Portions Copyrighted [year] [name of copyright owner]"
529.26 + *
529.27 + * If you wish your version of this file to be governed by only the CDDL
529.28 + * or only the GPL Version 2, indicate your decision by adding
529.29 + * "[Contributor] elects to include this software in this distribution
529.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
529.31 + * single choice of license, a recipient has the option to distribute
529.32 + * your version of this file under either the CDDL, the GPL Version 2 or
529.33 + * to extend the choice of license to its licensees as provided above.
529.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
529.35 + * Version 2 license, then the option applies only if the new code is
529.36 + * made subject to such option by the copyright holder.
529.37 + *
529.38 + * Contributor(s):
529.39 + *
529.40 + * Portions Copyrighted 2008-2009 Sun Microsystems, Inc.
529.41 + */
529.42 +
529.43 +package org.netbeans.modules.jackpot30.transformers;
529.44 +
529.45 +import com.sun.source.tree.AnnotationTree;
529.46 +import com.sun.source.tree.AssignmentTree;
529.47 +import com.sun.source.tree.ExpressionTree;
529.48 +import com.sun.source.tree.IdentifierTree;
529.49 +import com.sun.source.tree.LiteralTree;
529.50 +import com.sun.source.tree.MemberSelectTree;
529.51 +import com.sun.source.tree.NewArrayTree;
529.52 +import com.sun.source.tree.Tree;
529.53 +import com.sun.source.tree.Tree.Kind;
529.54 +import java.util.Arrays;
529.55 +import java.util.Iterator;
529.56 +import java.util.LinkedList;
529.57 +import java.util.List;
529.58 +import javax.lang.model.element.TypeElement;
529.59 +import javax.lang.model.type.TypeMirror;
529.60 +import org.netbeans.api.java.source.TreeMaker;
529.61 +import org.netbeans.api.java.source.WorkingCopy;
529.62 +import org.openide.util.NbCollections;
529.63 +
529.64 +/**
529.65 + *
529.66 + * @author Jan Lahoda
529.67 + */
529.68 +public class Utilities {
529.69 +
529.70 + private Utilities() {}
529.71 +
529.72 + public static <E> Iterable<E> checkedIterableByFilter(final Iterable raw, final Class<E> type, final boolean strict) {
529.73 + return new Iterable<E>() {
529.74 + public Iterator<E> iterator() {
529.75 + return NbCollections.checkedIteratorByFilter(raw.iterator(), type, strict);
529.76 + }
529.77 + };
529.78 + }
529.79 +
529.80 +// public static AnnotationTree constructConstraint(WorkingCopy wc, String name, TypeMirror tm) {
529.81 +// TreeMaker make = wc.getTreeMaker();
529.82 +// ExpressionTree variable = prepareAssignment(make, "variable", make.Literal(name));
529.83 +// ExpressionTree type = prepareAssignment(make, "type", make.MemberSelect((ExpressionTree) make.Type(wc.getTypes().erasure(tm)), "class"));
529.84 +// TypeElement constraint = wc.getElements().getTypeElement(Annotations.CONSTRAINT.toFQN());
529.85 +//
529.86 +// return make.Annotation(make.QualIdent(constraint), Arrays.asList(variable, type));
529.87 +// }
529.88 +
529.89 + public static ExpressionTree prepareAssignment(TreeMaker make, String name, ExpressionTree value) {
529.90 + return make.Assignment(make.Identifier(name), value);
529.91 + }
529.92 +
529.93 + public static ExpressionTree findValue(AnnotationTree m, String name) {
529.94 + for (ExpressionTree et : m.getArguments()) {
529.95 + if (et.getKind() == Kind.ASSIGNMENT) {
529.96 + AssignmentTree at = (AssignmentTree) et;
529.97 + String varName = ((IdentifierTree) at.getVariable()).getName().toString();
529.98 +
529.99 + if (varName.equals(name)) {
529.100 + return at.getExpression();
529.101 + }
529.102 + }
529.103 +
529.104 + if (et instanceof LiteralTree/*XXX*/ && "value".equals(name)) {
529.105 + return et;
529.106 + }
529.107 + }
529.108 +
529.109 + return null;
529.110 + }
529.111 +
529.112 + public static List<AnnotationTree> findArrayValue(AnnotationTree at, String name) {
529.113 + ExpressionTree fixesArray = findValue(at, name);
529.114 + List<AnnotationTree> fixes = new LinkedList<AnnotationTree>();
529.115 +
529.116 + if (fixesArray != null && fixesArray.getKind() == Kind.NEW_ARRAY) {
529.117 + NewArrayTree trees = (NewArrayTree) fixesArray;
529.118 +
529.119 + for (ExpressionTree fix : trees.getInitializers()) {
529.120 + if (fix.getKind() == Kind.ANNOTATION) {
529.121 + fixes.add((AnnotationTree) fix);
529.122 + }
529.123 + }
529.124 + }
529.125 +
529.126 + if (fixesArray != null && fixesArray.getKind() == Kind.ANNOTATION) {
529.127 + fixes.add((AnnotationTree) fixesArray);
529.128 + }
529.129 +
529.130 + return fixes;
529.131 + }
529.132 +
529.133 + public static boolean isPureMemberSelect(Tree mst, boolean allowVariables) {
529.134 + switch (mst.getKind()) {
529.135 + case IDENTIFIER: return allowVariables || ((IdentifierTree) mst).getName().charAt(0) != '$';
529.136 + case MEMBER_SELECT: return isPureMemberSelect(((MemberSelectTree) mst).getExpression(), allowVariables);
529.137 + default: return false;
529.138 + }
529.139 + }
529.140 +
529.141 +}
530.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
530.2 +++ b/sandbox/old-modules/transformer/src/org/netbeans/modules/jackpot30/transformers/resources/Bundle.properties Mon Mar 12 21:10:10 2012 +0100
530.3 @@ -0,0 +1,38 @@
530.4 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
530.5 +#
530.6 +# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
530.7 +#
530.8 +# The contents of this file are subject to the terms of either the GNU
530.9 +# General Public License Version 2 only ("GPL") or the Common
530.10 +# Development and Distribution License("CDDL") (collectively, the
530.11 +# "License"). You may not use this file except in compliance with the
530.12 +# License. You can obtain a copy of the License at
530.13 +# http://www.netbeans.org/cddl-gplv2.html
530.14 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
530.15 +# specific language governing permissions and limitations under the
530.16 +# License. When distributing the software, include this License Header
530.17 +# Notice in each file and include the License file at
530.18 +# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
530.19 +# particular file as subject to the "Classpath" exception as provided
530.20 +# by Sun in the GPL Version 2 section of the License file that
530.21 +# accompanied this code. If applicable, add the following below the
530.22 +# License Header, with the fields enclosed by brackets [] replaced by
530.23 +# your own identifying information:
530.24 +# "Portions Copyrighted [year] [name of copyright owner]"
530.25 +#
530.26 +# If you wish your version of this file to be governed by only the CDDL
530.27 +# or only the GPL Version 2, indicate your decision by adding
530.28 +# "[Contributor] elects to include this software in this distribution
530.29 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
530.30 +# single choice of license, a recipient has the option to distribute
530.31 +# your version of this file under either the CDDL, the GPL Version 2 or
530.32 +# to extend the choice of license to its licensees as provided above.
530.33 +# However, if you add GPL Version 2 code and therefore, elected the GPL
530.34 +# Version 2 license, then the option applies only if the new code is
530.35 +# made subject to such option by the copyright holder.
530.36 +#
530.37 +# Contributor(s):
530.38 +#
530.39 +# Portions Copyrighted 2009 Sun Microsystems, Inc.
530.40 +
530.41 +OpenIDE-Module-Name=Jackpot 3.0 Transformations
531.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
531.2 +++ b/sandbox/old-modules/transformer/src/org/netbeans/modules/jackpot30/transformers/resources/layer.xml Mon Mar 12 21:10:10 2012 +0100
531.3 @@ -0,0 +1,4 @@
531.4 +<?xml version="1.0" encoding="UTF-8"?>
531.5 +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
531.6 +<filesystem>
531.7 +</filesystem>
532.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
532.2 +++ b/sandbox/old-modules/transformer/test/unit/src/org/netbeans/modules/jackpot30/transformers/TransformationHintProviderImplTest.java Mon Mar 12 21:10:10 2012 +0100
532.3 @@ -0,0 +1,555 @@
532.4 +/*
532.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
532.6 + *
532.7 + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
532.8 + *
532.9 + * The contents of this file are subject to the terms of either the GNU
532.10 + * General Public License Version 2 only ("GPL") or the Common
532.11 + * Development and Distribution License("CDDL") (collectively, the
532.12 + * "License"). You may not use this file except in compliance with the
532.13 + * License. You can obtain a copy of the License at
532.14 + * http://www.netbeans.org/cddl-gplv2.html
532.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
532.16 + * specific language governing permissions and limitations under the
532.17 + * License. When distributing the software, include this License Header
532.18 + * Notice in each file and include the License file at
532.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
532.20 + * particular file as subject to the "Classpath" exception as provided
532.21 + * by Sun in the GPL Version 2 section of the License file that
532.22 + * accompanied this code. If applicable, add the following below the
532.23 + * License Header, with the fields enclosed by brackets [] replaced by
532.24 + * your own identifying information:
532.25 + * "Portions Copyrighted [year] [name of copyright owner]"
532.26 + *
532.27 + * If you wish your version of this file to be governed by only the CDDL
532.28 + * or only the GPL Version 2, indicate your decision by adding
532.29 + * "[Contributor] elects to include this software in this distribution
532.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
532.31 + * single choice of license, a recipient has the option to distribute
532.32 + * your version of this file under either the CDDL, the GPL Version 2 or
532.33 + * to extend the choice of license to its licensees as provided above.
532.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
532.35 + * Version 2 license, then the option applies only if the new code is
532.36 + * made subject to such option by the copyright holder.
532.37 + *
532.38 + * Contributor(s):
532.39 + *
532.40 + * Portions Copyrighted 2008 Sun Microsystems, Inc.
532.41 + */
532.42 +
532.43 +package org.netbeans.modules.jackpot30.transformers;
532.44 +
532.45 +import com.sun.source.tree.Tree.Kind;
532.46 +import java.io.File;
532.47 +import java.io.IOException;
532.48 +import java.util.ArrayList;
532.49 +import java.util.Arrays;
532.50 +import java.util.Collections;
532.51 +import java.util.HashMap;
532.52 +import java.util.LinkedList;
532.53 +import java.util.List;
532.54 +import java.util.Map;
532.55 +import java.util.concurrent.atomic.AtomicBoolean;
532.56 +import javax.swing.text.Document;
532.57 +import org.netbeans.api.java.lexer.JavaTokenId;
532.58 +import org.netbeans.api.java.source.CompilationInfo;
532.59 +import org.netbeans.api.java.source.JavaSource;
532.60 +import org.netbeans.api.java.source.JavaSource.Phase;
532.61 +import org.netbeans.api.java.source.SourceUtilsTestUtil;
532.62 +import org.netbeans.api.java.source.TestUtilities;
532.63 +import org.netbeans.api.lexer.Language;
532.64 +import org.netbeans.junit.NbTestCase;
532.65 +import org.netbeans.modules.java.hints.jackpot.impl.RulesManager;
532.66 +import org.netbeans.modules.java.hints.jackpot.impl.hints.HintsInvoker;
532.67 +import org.netbeans.modules.java.hints.jackpot.spi.ClassPathBasedHintProvider;
532.68 +import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
532.69 +import org.netbeans.modules.java.hints.jackpot.spi.Trigger.PatternDescription;
532.70 +import org.netbeans.modules.java.source.TreeLoader;
532.71 +import org.netbeans.spi.editor.hints.ErrorDescription;
532.72 +import org.netbeans.spi.editor.hints.Fix;
532.73 +import org.openide.LifecycleManager;
532.74 +import org.openide.cookies.EditorCookie;
532.75 +import org.openide.filesystems.FileObject;
532.76 +import org.openide.filesystems.FileUtil;
532.77 +import org.openide.loaders.DataObject;
532.78 +import org.openide.modules.InstalledFileLocator;
532.79 +
532.80 +/**
532.81 + *
532.82 + * @author Jan Lahoda
532.83 + */
532.84 +public class TransformationHintProviderImplTest extends NbTestCase {
532.85 +
532.86 + public TransformationHintProviderImplTest(String name) {
532.87 + super(name);
532.88 + }
532.89 +
532.90 + public void testSimpleAnalysis() throws Exception {
532.91 + performAnalysisTest("package test;\n" +
532.92 + "import net.java.lang.annotations.Constraint;\n" +
532.93 + "import net.java.lang.annotations.Fix;\n" +
532.94 + "import net.java.lang.annotations.Pattern;\n" +
532.95 + "import net.java.lang.annotations.Transformation;\n" +
532.96 + "public class Test {\n" +
532.97 + " @Transformation(\n" +
532.98 + " displayName=\"O\",\n" +
532.99 + " pattern=@Pattern(\"$0.getCookie($1)\"),\n" +
532.100 + " constraint={\n" +
532.101 + " @Constraint(variable=\"$0\", type=Test.class),\n" +
532.102 + " @Constraint(variable=\"$1\", type=Class.class)\n" +
532.103 + " },\n" +
532.104 + " fix=@Fix(\"$0.lookup($1)\")\n" +
532.105 + " )\n" +
532.106 + " public void getCookie(Class c) {}\n" +
532.107 + " private void test() {\n" +
532.108 + " getCookie(null);\n" +
532.109 + " }\n" +
532.110 + "}\n",
532.111 + "17:9-17:18:verifier:O");
532.112 + }
532.113 +
532.114 + public void testCanGoUp() throws Exception {
532.115 + performAnalysisTest("package test;\n" +
532.116 + "import net.java.lang.annotations.Constraint;\n" +
532.117 + "import net.java.lang.annotations.Fix;\n" +
532.118 + "import net.java.lang.annotations.Pattern;\n" +
532.119 + "import net.java.lang.annotations.Transformation;\n" +
532.120 + "public abstract class Test {\n" +
532.121 + " @Transformation(\n" +
532.122 + " displayName=\"O\",\n" +
532.123 + " pattern=@Pattern(\"$0.getCookie().toString()\"),\n" +
532.124 + " constraint={\n" +
532.125 + " @Constraint(variable=\"$0\", type=Test.class)\n" +
532.126 + " },\n" +
532.127 + " fix=@Fix(\"$0.lookup($1)\")\n" +
532.128 + " )\n" +
532.129 + " public abstract String getCookie();\n" +
532.130 + " private void test() {\n" +
532.131 + " getCookie().toString();\n" +
532.132 + " }\n" +
532.133 + "}\n",
532.134 + "16:21-16:29:verifier:O");
532.135 + }
532.136 +
532.137 + public void testForConstructor() throws Exception {
532.138 + performAnalysisTest("package test;\n" +
532.139 + "import net.java.lang.annotations.Constraint;\n" +
532.140 + "import net.java.lang.annotations.Fix;\n" +
532.141 + "import net.java.lang.annotations.Pattern;\n" +
532.142 + "import net.java.lang.annotations.Transformation;\n" +
532.143 + "public class Test {\n" +
532.144 + " @Transformation(\n" +
532.145 + " displayName=\"O\",\n" +
532.146 + " pattern=@Pattern(\"new test.Test()\"),\n" +
532.147 + " fix={}\n" +
532.148 + " )\n" +
532.149 + " public Test() {}\n" +
532.150 + " private void test() {\n" +
532.151 + " new Test();\n" +
532.152 + " }\n" +
532.153 + "}\n",
532.154 + "13:9-13:19:verifier:O");
532.155 + }
532.156 +
532.157 + public void testMoreWarnings() throws Exception {
532.158 + performAnalysisTest("package test;\n" +
532.159 + "import net.java.lang.annotations.Constraint;\n" +
532.160 + "import net.java.lang.annotations.Fix;\n" +
532.161 + "import net.java.lang.annotations.Pattern;\n" +
532.162 + "import net.java.lang.annotations.Transformation;\n" +
532.163 + "public class Test {\n" +
532.164 + " @Transformation(\n" +
532.165 + " displayName=\"O\",\n" +
532.166 + " pattern=@Pattern(\"new test.Test()\"),\n" +
532.167 + " fix={}\n" +
532.168 + " )\n" +
532.169 + " public Test() {}\n" +
532.170 + " private void test() {\n" +
532.171 + " new Test();\n" +
532.172 + " new Test();\n" +
532.173 + " }\n" +
532.174 + "}\n",
532.175 + "13:9-13:19:verifier:O",
532.176 + "14:9-14:19:verifier:O");
532.177 + }
532.178 +
532.179 + public void testCorrectImports() throws Exception {
532.180 + performFixTest("test/Test.java",
532.181 + "package test;\n" +
532.182 + "import net.java.lang.annotations.Constraint;\n" +
532.183 + "import net.java.lang.annotations.Fix;\n" +
532.184 + "import net.java.lang.annotations.Pattern;\n" +
532.185 + "import net.java.lang.annotations.Transformation;\n" +
532.186 + "public abstract class Test {\n" +
532.187 + " @Transformation(\n" +
532.188 + " displayName=\"O\",\n" +
532.189 + " pattern=@Pattern(\"$this.test()\"),\n" +
532.190 + " fix=@Fix(\"test.Test.test1().toString()\")\n" +
532.191 + " )\n" +
532.192 + " private void test() {\n" +
532.193 + " test();\n" +
532.194 + " }" +
532.195 + " static String test1() {return null;}\n" +
532.196 + "}\n",
532.197 + "12:9-12:13:verifier:O",
532.198 + "FixImpl",
532.199 + "package test;\n" +
532.200 + "import net.java.lang.annotations.Constraint;\n" +
532.201 + "import net.java.lang.annotations.Fix;\n" +
532.202 + "import net.java.lang.annotations.Pattern;\n" +
532.203 + "import net.java.lang.annotations.Transformation;\n" +
532.204 + "public abstract class Test {\n" +
532.205 + " @Transformation(\n" +
532.206 + " displayName=\"O\",\n" +
532.207 + " pattern=@Pattern(\"$this.test()\"),\n" +
532.208 + " fix=@Fix(\"test.Test.test1().toString()\")\n" +
532.209 + " )\n" +
532.210 + " private void test() {\n" +
532.211 + " Test.test1().toString();\n" +
532.212 + " }" +
532.213 + " static String test1() {return null;}\n" +
532.214 + "}\n");
532.215 + }
532.216 +
532.217 + public void testNoExceptions1() throws Exception {
532.218 + performNoExceptionsTest("package test;\n" +
532.219 + "import net.java.lang.annotations.Constraint;\n" +
532.220 + "import net.java.lang.annotations.Fix;\n" +
532.221 + "import net.java.lang.annotations.Pattern;\n" +
532.222 + "import net.java.lang.annotations.Transformation;\n" +
532.223 + "public abstract class Test {\n" +
532.224 + " |public abstract String getCookie();\n" +
532.225 + " private void test() {\n" +
532.226 + " getCookie().toString();\n" +
532.227 + " }\n" +
532.228 + "}\n",
532.229 + " @Transformation(\n" +
532.230 + " displayName=\"O\",\n" +
532.231 + " pattern=@Pattern(\"$0.getCookie().toString()\"),\n" +
532.232 + " constraint={\n" +
532.233 + " @Constraint(variable=\"$0\", type=Test.class)\n" +
532.234 + " },\n" +
532.235 + " fix={@Fix(\"$0.lookup($1)\")}\n" +
532.236 + " )\n".replaceAll("[ \n]+", " "));
532.237 + }
532.238 +
532.239 + public void testNoExceptions2() throws Exception {
532.240 + performNoExceptionsTest("package test;\n" +
532.241 + "import net.java.lang.annotations.Constraint;\n" +
532.242 + "import net.java.lang.annotations.Fix;\n" +
532.243 + "import net.java.lang.annotations.Pattern;\n" +
532.244 + "import net.java.lang.annotations.Transformation;\n" +
532.245 + "public abstract class Test {\n" +
532.246 + " |public abstract String getCookie();\n" +
532.247 + " private void test() {\n" +
532.248 + " getCookie().toString();\n" +
532.249 + " }\n" +
532.250 + "}\n",
532.251 + " @Transformation(\n" +
532.252 + " displayName=\"O\",\n" +
532.253 + " pattern=@Pattern(\"$0.getCookie().toString()\"),\n" +
532.254 + " constraint=\n" +
532.255 + " @Constraint(variable=\"$0\", type=Test.class)\n" +
532.256 + " ,\n" +
532.257 + " fix=@Fix(\"$0.lookup($1)\")\n" +
532.258 + " )\n".replaceAll("[ \n]+", " "));
532.259 + }
532.260 +
532.261 + public void testType1() throws Exception {
532.262 + performFixTest("test/Test.java",
532.263 + "package test;\n" +
532.264 + "import net.java.lang.annotations.Constraint;\n" +
532.265 + "import net.java.lang.annotations.Fix;\n" +
532.266 + "import net.java.lang.annotations.Pattern;\n" +
532.267 + "import net.java.lang.annotations.Transformation;\n" +
532.268 + "public abstract class Test {\n" +
532.269 + " @Transformation(\n" +
532.270 + " displayName=\"O\",\n" +
532.271 + " pattern=@Pattern(\"test.Test.Bad\"),\n" +
532.272 + " fix=@Fix(\"test.Test.Good\")\n" +
532.273 + " )\n" +
532.274 + " public static class Bad {}\n" +
532.275 + " public static class Good {}\n" +
532.276 + " static void test1() { Bad b; }\n" +
532.277 + "}\n",
532.278 + "13:26-13:29:verifier:O",
532.279 + "FixImpl",
532.280 + "package test;\n" +
532.281 + "import net.java.lang.annotations.Constraint;\n" +
532.282 + "import net.java.lang.annotations.Fix;\n" +
532.283 + "import net.java.lang.annotations.Pattern;\n" +
532.284 + "import net.java.lang.annotations.Transformation;\n" +
532.285 + "public abstract class Test {\n" +
532.286 + " @Transformation(\n" +
532.287 + " displayName=\"O\",\n" +
532.288 + " pattern=@Pattern(\"test.Test.Bad\"),\n" +
532.289 + " fix=@Fix(\"test.Test.Good\")\n" +
532.290 + " )\n" +
532.291 + " public static class Bad {}\n" +
532.292 + " public static class Good {}\n" +
532.293 + " static void test1() { Good b; }\n" +
532.294 + "}\n".replaceAll("[ \n]+", " "));
532.295 + }
532.296 +
532.297 + public void testCorrectReplace() throws Exception {
532.298 + performFixTest("test/Test.java",
532.299 + "package test;\n" +
532.300 + "import net.java.lang.annotations.Constraint;\n" +
532.301 + "import net.java.lang.annotations.Fix;\n" +
532.302 + "import net.java.lang.annotations.Pattern;\n" +
532.303 + "import net.java.lang.annotations.Transformation;\n" +
532.304 + "public class Test {\n" +
532.305 + " @Transformation(\n" +
532.306 + " displayName=\"O\",\n" +
532.307 + " pattern=@Pattern(\"$this.test()\"),\n" +
532.308 + " fix=@Fix(\"$this.test()\")\n" +
532.309 + " )\n" +
532.310 + " private void test() {\n" +
532.311 + " new Test().test();\n" +
532.312 + " }\n" +
532.313 + "}\n",
532.314 + "12:20-12:24:verifier:O",
532.315 + "FixImpl",
532.316 + "package test;\n" +
532.317 + "import net.java.lang.annotations.Constraint;\n" +
532.318 + "import net.java.lang.annotations.Fix;\n" +
532.319 + "import net.java.lang.annotations.Pattern;\n" +
532.320 + "import net.java.lang.annotations.Transformation;\n" +
532.321 + "public class Test {\n" +
532.322 + " @Transformation(\n" +
532.323 + " displayName=\"O\",\n" +
532.324 + " pattern=@Pattern(\"$this.test()\"),\n" +
532.325 + " fix=@Fix(\"$this.test()\")\n" +
532.326 + " )\n" +
532.327 + " private void test() {\n" +
532.328 + " new Test().test();\n" +
532.329 + " }\n" +
532.330 + "}\n");
532.331 + }
532.332 +
532.333 + @Override
532.334 + protected void setUp() throws Exception {
532.335 + super.setUp();
532.336 +
532.337 + File jar = FileUtil.archiveOrDirForURL(TransformationHintProviderImpl.class.getProtectionDomain().getCodeSource().getLocation());
532.338 +
532.339 + assertNotNull(jar);
532.340 +
532.341 + String nbHome = jar.getParentFile().getParentFile().getAbsolutePath();
532.342 +
532.343 + System.setProperty("netbeans.home",nbHome);
532.344 +
532.345 + SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml"}, new Object[0]);
532.346 + TreeLoader.DISABLE_CONFINEMENT_TEST = true;
532.347 + }
532.348 +
532.349 + private List<ErrorDescription> computeWarnings() {
532.350 + List<HintDescription> hints = new ArrayList<HintDescription>();
532.351 +
532.352 + RulesManager.computeElementBasedHintsXXX(info, new AtomicBoolean(), Collections.singletonList(new TransformationHintProviderImpl()), Collections.<ClassPathBasedHintProvider>emptyList(), hints);
532.353 +
532.354 + List<ErrorDescription> warnings = new HintsInvoker(info, new AtomicBoolean()).computeHints(info, hints);
532.355 +
532.356 + return warnings;
532.357 + }
532.358 +
532.359 + private void prepareTest(String fileName, String code) throws Exception {
532.360 + prepareTest(fileName, code, false);
532.361 + }
532.362 +
532.363 + private void prepareTest(String fileName, String code, boolean ignoreErrors) throws Exception {
532.364 + clearWorkDir();
532.365 +
532.366 + FileUtil.refreshFor(File.listRoots());
532.367 +
532.368 + FileObject workFO = FileUtil.toFileObject(getWorkDir());
532.369 +
532.370 + assertNotNull(workFO);
532.371 +
532.372 + workFO.refresh();
532.373 +
532.374 + sourceRoot = workFO.createFolder("src");
532.375 + FileObject buildRoot = workFO.createFolder("build");
532.376 + FileObject cache = workFO.createFolder("cache");
532.377 +
532.378 + FileObject data = FileUtil.createData(sourceRoot, fileName);
532.379 + File dataFile = FileUtil.toFile(data);
532.380 +
532.381 + assertNotNull(dataFile);
532.382 +
532.383 + TestUtilities.copyStringToFile(dataFile, code);
532.384 +
532.385 + File ann = InstalledFileLocator.getDefault().locate("libs/annotations.jar", null, false);
532.386 +
532.387 + if (ann == null) {
532.388 + ann = InstalledFileLocator.getDefault().locate("release/libs/annotations.jar", null, false);
532.389 + }
532.390 +
532.391 + assertNotNull(System.getProperty("netbeans.home"), ann);
532.392 +
532.393 + FileObject annFO = FileUtil.toFileObject(ann);
532.394 +
532.395 + assertNotNull(annFO);
532.396 +
532.397 + SourceUtilsTestUtil.prepareTest(sourceRoot, buildRoot, cache, new FileObject[] {FileUtil.getArchiveRoot(annFO)});
532.398 +
532.399 + DataObject od = DataObject.find(data);
532.400 + EditorCookie ec = od.getLookup().lookup(EditorCookie.class);
532.401 +
532.402 + assertNotNull(ec);
532.403 +
532.404 + doc = ec.openDocument();
532.405 + doc.putProperty(Language.class, JavaTokenId.language());
532.406 +
532.407 + JavaSource js = JavaSource.forFileObject(data);
532.408 +
532.409 + assertNotNull(js);
532.410 +
532.411 + info = SourceUtilsTestUtil.getCompilationInfo(js, Phase.RESOLVED);
532.412 +
532.413 + assertNotNull(info);
532.414 +
532.415 + if (!ignoreErrors) {
532.416 + assertEquals(info.getDiagnostics().toString(), 0, info.getDiagnostics().size());
532.417 + }
532.418 + }
532.419 +
532.420 + private FileObject sourceRoot;
532.421 + private CompilationInfo info;
532.422 + private Document doc;
532.423 + private String wordDirPath;
532.424 +
532.425 + protected void performNoExceptionsTest(String code, String type) throws Exception {
532.426 + String wDP = getWorkDirPath();
532.427 +
532.428 + int offset = code.indexOf('|');
532.429 +
532.430 + code = code.replace("|", "");
532.431 +
532.432 + File prev = null;
532.433 +
532.434 + for (int i = 0; i < type.length(); i++) {
532.435 + StringBuilder nueCode = new StringBuilder();
532.436 +
532.437 + nueCode.append(code);
532.438 + nueCode.insert(offset, type.substring(0, i + 1));
532.439 +
532.440 + this.wordDirPath = wDP + File.separatorChar + i;
532.441 +
532.442 + performAnalysisTest(nueCode.toString(), null, true);
532.443 +
532.444 + if (prev != null) {
532.445 + deleteFile(prev);
532.446 + FileUtil.refreshFor(File.listRoots());
532.447 + }
532.448 +
532.449 + prev = getWorkDir();
532.450 + }
532.451 + }
532.452 +
532.453 + protected void performAnalysisTest(String code, String... golden) throws Exception {
532.454 + performAnalysisTest(code, golden, false);
532.455 + }
532.456 +
532.457 + protected void performAnalysisTest(String code, String[] golden, boolean ignoreErrors) throws Exception {
532.458 + prepareTest("test/Test.java", code, ignoreErrors);
532.459 +
532.460 + List<ErrorDescription> warnings = computeWarnings();
532.461 + List<String> dns = new LinkedList<String>();
532.462 +
532.463 + for (ErrorDescription ed : warnings) {
532.464 + dns.add(ed.toString());
532.465 + }
532.466 +
532.467 + if (golden != null) {
532.468 + assertEquals(Arrays.asList(golden), dns);
532.469 + }
532.470 + }
532.471 +
532.472 + protected String performFixTest(String fileName, String code, String errorDescriptionToString, String fixDebugString, String golden) throws Exception {
532.473 + prepareTest(fileName, code);
532.474 +
532.475 + List<ErrorDescription> errors = computeWarnings();
532.476 +
532.477 + ErrorDescription toFix = null;
532.478 +
532.479 + for (ErrorDescription d : errors) {
532.480 + if (errorDescriptionToString.equals(d.toString())) {
532.481 + toFix = d;
532.482 + break;
532.483 + }
532.484 + }
532.485 +
532.486 + assertNotNull("Error: \"" + errorDescriptionToString + "\" not found. All ErrorDescriptions: " + errors.toString(), toFix);
532.487 +
532.488 + assertTrue("Must be computed", toFix.getFixes().isComputed());
532.489 +
532.490 + List<Fix> fixes = toFix.getFixes().getFixes();
532.491 + List<String> fixNames = new LinkedList<String>();
532.492 + Fix toApply = null;
532.493 +
532.494 + for (Fix f : fixes) {
532.495 + if (fixDebugString.equals(toDebugString(info, f))) {
532.496 + toApply = f;
532.497 + }
532.498 +
532.499 + fixNames.add(toDebugString(info, f));
532.500 + }
532.501 +
532.502 + assertNotNull("Cannot find fix to invoke: " + fixNames.toString(), toApply);
532.503 +
532.504 + toApply.implement();
532.505 +
532.506 + FileObject toCheck = sourceRoot.getFileObject(fileName);
532.507 +
532.508 + assertNotNull(toCheck);
532.509 +
532.510 + DataObject toCheckDO = DataObject.find(toCheck);
532.511 + EditorCookie ec = toCheckDO.getCookie(EditorCookie.class);
532.512 + Document toCheckDocument = ec.openDocument();
532.513 +
532.514 + String realCode = toCheckDocument.getText(0, toCheckDocument.getLength());
532.515 +
532.516 + //ignore whitespaces:
532.517 + realCode = realCode.replaceAll("[ \t\n]+", " ");
532.518 +
532.519 + if (golden != null) {
532.520 + golden = golden.replaceAll("[ \t\n]+", " ");
532.521 + assertEquals("The output code does not match the expected code.", golden, realCode);
532.522 + }
532.523 +
532.524 + LifecycleManager.getDefault().saveAll();
532.525 +
532.526 + return realCode;
532.527 + }
532.528 +
532.529 + private String toDebugString(CompilationInfo info, Fix f) {
532.530 + return "FixImpl";
532.531 + }
532.532 +
532.533 + @Override
532.534 + public String getWorkDirPath() {
532.535 + if (this.wordDirPath != null) {
532.536 + return this.wordDirPath;
532.537 + }
532.538 +
532.539 + return super.getWorkDirPath();
532.540 + }
532.541 +
532.542 + private static void deleteFile(File file) throws IOException {
532.543 + if (file.isDirectory()) {
532.544 + // file is a directory - delete sub files first
532.545 + File files[] = file.listFiles();
532.546 + for (int i = 0; i < files.length; i++) {
532.547 + deleteFile(files[i]);
532.548 + }
532.549 +
532.550 + }
532.551 + // file is a File :-)
532.552 + boolean result = file.delete();
532.553 + if (result == false ) {
532.554 + // a problem has appeared
532.555 + throw new IOException("Cannot delete file, file = "+file.getPath());
532.556 + }
532.557 + }
532.558 +}
533.1 --- a/server/do-indexing Fri Jan 27 13:35:56 2012 +0100
533.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
533.3 @@ -1,27 +0,0 @@
533.4 -#!/bin/bash -x
533.5 -
533.6 -performIndexing() {
533.7 - name=`basename $1`;
533.8 - if [ -d $name ] ; then
533.9 - HG_OUT=$(tempfile) || exit
533.10 - trap "rm -f -- '$HG_OUT'" EXIT
533.11 - MODIFIED=$(tempfile) || exit
533.12 - trap "rm -f -- '$HG_OUT' '$MODIFIED'" EXIT
533.13 - REMOVED=$(tempfile) || exit
533.14 - trap "rm -f -- '$HG_OUT' '$MODIFIED' '$REMOVED'" EXIT
533.15 -
533.16 - (cd $name; hg pull; hg --verbose up >$HG_OUT; grep <$HG_OUT "^getting " | cut -d ' ' -f 2- >$MODIFIED; grep <$HG_OUT "^removing " | cut -d ' ' -f 2- >$REMOVED;)
533.17 - java -Xbootclasspath/p:lib/javac-api-nb-7.0-b07.jar -jar indexer.jar $ADDITIONAL_INDEXING_PARAMS $name $2 "$MODIFIED" "$REMOVED"
533.18 - else
533.19 - hg clone $1
533.20 - java -Xbootclasspath/p:lib/javac-api-nb-7.0-b07.jar -jar indexer.jar $ADDITIONAL_INDEXING_PARAMS $name $2
533.21 - fi;
533.22 -}
533.23 -
533.24 -mkdir -p cache
533.25 -
533.26 -for f in `echo $1 | tr ',' '\n'`; do
533.27 - performIndexing $f cache
533.28 -done
533.29 -
533.30 -exit
534.1 --- a/server/download.xml Fri Jan 27 13:35:56 2012 +0100
534.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
534.3 @@ -1,69 +0,0 @@
534.4 -<project name="download" default="download">
534.5 - <target name="download">
534.6 - <property name="imported.basedir" value="${basedir}"/>
534.7 -
534.8 - <macrodef name="download">
534.9 - <attribute name="url"/>
534.10 - <attribute name="target"/>
534.11 - <sequential>
534.12 - <antcall target="-download" inheritAll="false">
534.13 - <param name="url" value="@{url}" />
534.14 - <param name="target" value="@{target}" />
534.15 - <param name="imported.basedir" value="${imported.basedir}" />
534.16 - </antcall>
534.17 - </sequential>
534.18 - </macrodef>
534.19 - <download url="http://download.java.net/maven/2/com/sun/jersey/jersey-client/1.0.1/jersey-client-1.0.1.jar" target="jersey-1.1/jersey-client-1.0.1.jar"/>
534.20 - <download url="http://download.java.net/maven/2/com/sun/jersey/jersey-client/1.0.1/jersey-client-1.0.1-javadoc.jar" target="jersey-1.1/jersey-client-1.0.1-javadoc.jar"/>
534.21 - <download url="http://download.java.net/maven/2/com/sun/jersey/jersey-client/1.0.1/jersey-client-1.0.1-sources.jar" target="jersey-1.1/jersey-client-1.0.1-sources.jar"/>
534.22 - <download url="http://download.java.net/maven/2/com/sun/jersey/jersey-core/1.0.1/jersey-core-1.0.1.jar" target="jersey-1.1/jersey-core-1.0.1.jar"/>
534.23 - <download url="http://download.java.net/maven/2/com/sun/jersey/jersey-core/1.0.1/jersey-core-1.0.1-javadoc.jar" target="jersey-1.1/jersey-core-1.0.1-javadoc.jar"/>
534.24 - <download url="http://download.java.net/maven/2/com/sun/jersey/jersey-core/1.0.1/jersey-core-1.0.1-sources.jar" target="jersey-1.1/jersey-core-1.0.1-sources.jar"/>
534.25 - <download url="http://download.java.net/maven/2/com/sun/jersey/jersey-server/1.0.1/jersey-server-1.0.1.jar" target="jersey-1.1/jersey-server-1.0.1.jar"/>
534.26 - <download url="http://download.java.net/maven/2/com/sun/jersey/jersey-server/1.0.1/jersey-server-1.0.1-javadoc.jar" target="jersey-1.1/jersey-server-1.0.1-javadoc.jar"/>
534.27 - <download url="http://download.java.net/maven/2/com/sun/jersey/jersey-server/1.0.1/jersey-server-1.0.1-sources.jar" target="jersey-1.1/jersey-server-1.0.1-sources.jar"/>
534.28 - <download url="http://download.java.net/maven/2/com/sun/grizzly/grizzly-servlet-webserver/1.8.6.3/grizzly-servlet-webserver-1.8.6.3.jar" target="jersey-1.1/grizzly-servlet-webserver-1.8.6.3.jar"/>
534.29 -<!-- <download url="http://download.java.net/maven/2/com/sun/grizzly/grizzly-servlet-webserver/1.9.14/grizzly-servlet-webserver-1.9.14-javadoc.jar" target="jersey-1.1/grizzly-servlet-webserver-1.9.14-javadoc.jar"/>-->
534.30 -<!-- <download url="http://download.java.net/maven/2/com/sun/grizzly/grizzly-servlet-webserver/1.9.14/grizzly-servlet-webserver-1.9.14-sources.jar" target="jersey-1.1/grizzly-servlet-webserver-1.9.14-sources.jar"/>-->
534.31 - <download url="http://download.java.net/maven/2/javax/ws/rs/jsr311-api/1.0/jsr311-api-1.0.jar" target="jersey-1.1/jsr311-api-1.0.jar"/>
534.32 - <download url="http://download.java.net/maven/2/javax/ws/rs/jsr311-api/1.0/jsr311-api-1.0-javadoc.jar" target="jersey-1.1/jsr311-api-1.0-javadoc.jar"/>
534.33 - <download url="http://download.java.net/maven/2/javax/ws/rs/jsr311-api/1.0/jsr311-api-1.0-sources.jar" target="jersey-1.1/jsr311-api-1.0-sources.jar"/>
534.34 - <download url="http://repo2.maven.org/maven2/asm/asm-all/3.1/asm-all-3.1.jar" target="jersey-1.1/asm-all-3.1.jar"/>
534.35 - <download url="http://repo2.maven.org/maven2/asm/asm-all/3.1/asm-all-3.1-sources.jar" target="jersey-1.1/asm-all-3.1-sources.jar"/>
534.36 -
534.37 - <download url="http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/3.5.0/lucene-core-3.5.0.jar" target="lucene-3.5.0/lucene-core-3.5.0.jar" />
534.38 - <download url="http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/3.5.0/lucene-core-3.5.0-javadoc.jar" target="lucene-3.5.0/lucene-core-3.5.0-javadoc.jar" />
534.39 - <download url="http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/3.5.0/lucene-core-3.5.0-sources.jar" target="lucene-3.5.0/lucene-core-3.5.0-sources.jar" />
534.40 -
534.41 - <download url="http://repo1.maven.org/maven2/junit/junit/4.5/junit-4.5.jar" target="junit_4/junit-4.5.jar" />
534.42 - <download url="http://switch.dl.sourceforge.net/project/junit/junit/4.5/junit4.5.zip" target="junit_4/junit-4.5-api.zip" />
534.43 - <download url="http://repo1.maven.org/maven2/junit/junit/4.5/junit-4.5-sources.jar" target="junit_4/junit-4.5-src.jar" />
534.44 -
534.45 - <download url="http://repo1.maven.org/maven2/junit/junit/3.8.2/junit-3.8.2.jar" target="junit/junit-3.8.2.jar" />
534.46 - <download url="http://repo1.maven.org/maven2/junit/junit/3.8.2/junit-3.8.2-javadoc.jar" target="junit/junit-3.8.2-javadoc.jar" />
534.47 - <download url="http://repo1.maven.org/maven2/junit/junit/3.8.2/junit-3.8.2-sources.jar" target="junit/junit-3.8.2-sources.jar" />
534.48 -
534.49 - <download url="http://cdn.bitbucket.org/jlahoda/jackpot30/downloads/org-netbeans-modules-java-j2seproject-copylibstask.jar" target="CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar" />
534.50 -
534.51 - <download url="http://mirrors.ibiblio.org/pub/mirrors/maven2/org/freemarker/freemarker/2.3.16/freemarker-2.3.16.jar" target="freemarker/freemarker-2.3.16.jar" />
534.52 -
534.53 - <download url="http://mirrors.ibiblio.org/pub/mirrors/maven2/net/sf/jopt-simple/jopt-simple/3.2/jopt-simple-3.2.jar" target="jopt-simple/jopt-simple-3.2.jar" />
534.54 - <download url="http://mirrors.ibiblio.org/pub/mirrors/maven2/net/sf/jopt-simple/jopt-simple/3.2/jopt-simple-3.2-sources.jar" target="jopt-simple/jopt-simple-3.2-sources.jar" />
534.55 - <download url="http://mirrors.ibiblio.org/pub/mirrors/maven2/net/sf/jopt-simple/jopt-simple/3.2/jopt-simple-3.2-javadoc.jar" target="jopt-simple/jopt-simple-3.2-javadoc.jar" />
534.56 - </target>
534.57 -
534.58 - <target name="-download-check-exists">
534.59 - <available property="file.exists" file="${imported.basedir}/lib/${target}"/>
534.60 - </target>
534.61 -
534.62 - <target name="-download" depends="-download-check-exists" unless="file.exists">
534.63 - <dirname property="dir" file="${imported.basedir}/lib/${target}" />
534.64 - <mkdir dir="${dir}" />
534.65 - <get src="${url}" dest="${imported.basedir}/lib/${target}" usetimestamp="true"/>
534.66 - </target>
534.67 -
534.68 - <target name="-prepare-imported-basedir-property">
534.69 - <dirname property="imported.basedir" file="${ant.file.download}"/>
534.70 - </target>
534.71 - <target name="-post-init" depends="-prepare-imported-basedir-property,download"/>
534.72 -</project>
535.1 --- a/server/indexer/build.xml Fri Jan 27 13:35:56 2012 +0100
535.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
535.3 @@ -1,86 +0,0 @@
535.4 -<?xml version="1.0" encoding="UTF-8"?>
535.5 -<!-- You may freely edit this file. See commented blocks below for -->
535.6 -<!-- some examples of how to customize the build. -->
535.7 -<!-- (If you delete it and reopen the project it will be recreated.) -->
535.8 -<!-- By default, only the Clean and Build commands use this build script. -->
535.9 -<!-- Commands such as Run, Debug, and Test only use this build script if -->
535.10 -<!-- the Compile on Save feature is turned off for the project. -->
535.11 -<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
535.12 -<!-- in the project's Project Properties dialog box.-->
535.13 -<project name="indexer" default="default" basedir=".">
535.14 - <description>Builds, tests, and runs the project indexer.</description>
535.15 - <import file="../download.xml"/>
535.16 - <import file="nbproject/build-impl.xml"/>
535.17 - <!--
535.18 -
535.19 - There exist several targets which are by default empty and which can be
535.20 - used for execution of your tasks. These targets are usually executed
535.21 - before and after some main targets. They are:
535.22 -
535.23 - -pre-init: called before initialization of project properties
535.24 - -post-init: called after initialization of project properties
535.25 - -pre-compile: called before javac compilation
535.26 - -post-compile: called after javac compilation
535.27 - -pre-compile-single: called before javac compilation of single file
535.28 - -post-compile-single: called after javac compilation of single file
535.29 - -pre-compile-test: called before javac compilation of JUnit tests
535.30 - -post-compile-test: called after javac compilation of JUnit tests
535.31 - -pre-compile-test-single: called before javac compilation of single JUnit test
535.32 - -post-compile-test-single: called after javac compilation of single JUunit test
535.33 - -pre-jar: called before JAR building
535.34 - -post-jar: called after JAR building
535.35 - -post-clean: called after cleaning build products
535.36 -
535.37 - (Targets beginning with '-' are not intended to be called on their own.)
535.38 -
535.39 - Example of inserting an obfuscator after compilation could look like this:
535.40 -
535.41 - <target name="-post-compile">
535.42 - <obfuscate>
535.43 - <fileset dir="${build.classes.dir}"/>
535.44 - </obfuscate>
535.45 - </target>
535.46 -
535.47 - For list of available properties check the imported
535.48 - nbproject/build-impl.xml file.
535.49 -
535.50 -
535.51 - Another way to customize the build is by overriding existing main targets.
535.52 - The targets of interest are:
535.53 -
535.54 - -init-macrodef-javac: defines macro for javac compilation
535.55 - -init-macrodef-junit: defines macro for junit execution
535.56 - -init-macrodef-debug: defines macro for class debugging
535.57 - -init-macrodef-java: defines macro for class execution
535.58 - -do-jar-with-manifest: JAR building (if you are using a manifest)
535.59 - -do-jar-without-manifest: JAR building (if you are not using a manifest)
535.60 - run: execution of project
535.61 - -javadoc-build: Javadoc generation
535.62 - test-report: JUnit report generation
535.63 -
535.64 - An example of overriding the target for project execution could look like this:
535.65 -
535.66 - <target name="run" depends="indexer-impl.jar">
535.67 - <exec dir="bin" executable="launcher.exe">
535.68 - <arg file="${dist.jar}"/>
535.69 - </exec>
535.70 - </target>
535.71 -
535.72 - Notice that the overridden target depends on the jar target and not only on
535.73 - the compile target as the regular run target does. Again, for a list of available
535.74 - properties which you can use, check the target you are overriding in the
535.75 - nbproject/build-impl.xml file.
535.76 -
535.77 - -->
535.78 -
535.79 - <target name="copy-to-hudson" depends="jar">
535.80 - <mkdir dir="${hudson.compiler.dir}" /> <!--only to be sure, should exist-->
535.81 - <copy todir="${hudson.compiler.dir}/indexer">
535.82 - <fileset dir="${dist.dir}"/>
535.83 - </copy>
535.84 - </target>
535.85 -
535.86 - <target name="-post-clean">
535.87 - <delete dir="${hudson.compiler.dir}/indexer"/>
535.88 - </target>
535.89 -</project>
536.1 --- a/server/indexer/manifest.mf Fri Jan 27 13:35:56 2012 +0100
536.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
536.3 @@ -1,3 +0,0 @@
536.4 -Manifest-Version: 1.0
536.5 -X-COMMENT: Main-Class will be added automatically by build
536.6 -
537.1 --- a/server/indexer/nbproject/build-impl.xml Fri Jan 27 13:35:56 2012 +0100
537.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
537.3 @@ -1,914 +0,0 @@
537.4 -<?xml version="1.0" encoding="UTF-8"?>
537.5 -<!--
537.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
537.7 -*** EDIT ../build.xml INSTEAD ***
537.8 -
537.9 -For the purpose of easier reading the script
537.10 -is divided into following sections:
537.11 -
537.12 - - initialization
537.13 - - compilation
537.14 - - jar
537.15 - - execution
537.16 - - debugging
537.17 - - javadoc
537.18 - - junit compilation
537.19 - - junit execution
537.20 - - junit debugging
537.21 - - applet
537.22 - - cleanup
537.23 -
537.24 - -->
537.25 -<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="indexer-impl">
537.26 - <fail message="Please build using Ant 1.7.1 or higher.">
537.27 - <condition>
537.28 - <not>
537.29 - <antversion atleast="1.7.1"/>
537.30 - </not>
537.31 - </condition>
537.32 - </fail>
537.33 - <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
537.34 - <!--
537.35 - ======================
537.36 - INITIALIZATION SECTION
537.37 - ======================
537.38 - -->
537.39 - <target name="-pre-init">
537.40 - <!-- Empty placeholder for easier customization. -->
537.41 - <!-- You can override this target in the ../build.xml file. -->
537.42 - </target>
537.43 - <target depends="-pre-init" name="-init-private">
537.44 - <property file="nbproject/private/config.properties"/>
537.45 - <property file="nbproject/private/configs/${config}.properties"/>
537.46 - <property file="nbproject/private/private.properties"/>
537.47 - </target>
537.48 - <target name="-pre-init-libraries">
537.49 - <property location="../lib/nblibraries.properties" name="libraries.path"/>
537.50 - <dirname file="${libraries.path}" property="libraries.dir.nativedirsep"/>
537.51 - <pathconvert dirsep="/" property="libraries.dir">
537.52 - <path path="${libraries.dir.nativedirsep}"/>
537.53 - </pathconvert>
537.54 - <basename file="${libraries.path}" property="libraries.basename" suffix=".properties"/>
537.55 - <available file="${libraries.dir}/${libraries.basename}-private.properties" property="private.properties.available"/>
537.56 - </target>
537.57 - <target depends="-pre-init-libraries" if="private.properties.available" name="-init-private-libraries">
537.58 - <loadproperties encoding="ISO-8859-1" srcfile="${libraries.dir}/${libraries.basename}-private.properties">
537.59 - <filterchain>
537.60 - <replacestring from="$${base}" to="${libraries.dir}"/>
537.61 - <escapeunicode/>
537.62 - </filterchain>
537.63 - </loadproperties>
537.64 - </target>
537.65 - <target depends="-pre-init,-init-private,-init-private-libraries" name="-init-libraries">
537.66 - <loadproperties encoding="ISO-8859-1" srcfile="${libraries.path}">
537.67 - <filterchain>
537.68 - <replacestring from="$${base}" to="${libraries.dir}"/>
537.69 - <escapeunicode/>
537.70 - </filterchain>
537.71 - </loadproperties>
537.72 - </target>
537.73 - <target depends="-pre-init,-init-private,-init-libraries" name="-init-user">
537.74 - <property file="${user.properties.file}"/>
537.75 - <!-- The two properties below are usually overridden -->
537.76 - <!-- by the active platform. Just a fallback. -->
537.77 - <property name="default.javac.source" value="1.4"/>
537.78 - <property name="default.javac.target" value="1.4"/>
537.79 - </target>
537.80 - <target depends="-pre-init,-init-private,-init-libraries,-init-user" name="-init-project">
537.81 - <property file="nbproject/configs/${config}.properties"/>
537.82 - <property file="nbproject/project.properties"/>
537.83 - </target>
537.84 - <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-init-macrodef-property" name="-do-init">
537.85 - <available file="${manifest.file}" property="manifest.available"/>
537.86 - <condition property="main.class.available">
537.87 - <and>
537.88 - <isset property="main.class"/>
537.89 - <not>
537.90 - <equals arg1="${main.class}" arg2="" trim="true"/>
537.91 - </not>
537.92 - </and>
537.93 - </condition>
537.94 - <condition property="manifest.available+main.class">
537.95 - <and>
537.96 - <isset property="manifest.available"/>
537.97 - <isset property="main.class.available"/>
537.98 - </and>
537.99 - </condition>
537.100 - <condition property="do.mkdist">
537.101 - <and>
537.102 - <isset property="libs.CopyLibs.classpath"/>
537.103 - <not>
537.104 - <istrue value="${mkdist.disabled}"/>
537.105 - </not>
537.106 - </and>
537.107 - </condition>
537.108 - <condition property="manifest.available+main.class+mkdist.available">
537.109 - <and>
537.110 - <istrue value="${manifest.available+main.class}"/>
537.111 - <isset property="do.mkdist"/>
537.112 - </and>
537.113 - </condition>
537.114 - <condition property="manifest.available+mkdist.available">
537.115 - <and>
537.116 - <istrue value="${manifest.available}"/>
537.117 - <isset property="do.mkdist"/>
537.118 - </and>
537.119 - </condition>
537.120 - <condition property="manifest.available-mkdist.available">
537.121 - <or>
537.122 - <istrue value="${manifest.available}"/>
537.123 - <isset property="do.mkdist"/>
537.124 - </or>
537.125 - </condition>
537.126 - <condition property="manifest.available+main.class-mkdist.available">
537.127 - <or>
537.128 - <istrue value="${manifest.available+main.class}"/>
537.129 - <isset property="do.mkdist"/>
537.130 - </or>
537.131 - </condition>
537.132 - <condition property="have.tests">
537.133 - <or>
537.134 - <available file="${test.src.dir}"/>
537.135 - </or>
537.136 - </condition>
537.137 - <condition property="have.sources">
537.138 - <or>
537.139 - <available file="${src.dir}"/>
537.140 - </or>
537.141 - </condition>
537.142 - <condition property="netbeans.home+have.tests">
537.143 - <and>
537.144 - <isset property="netbeans.home"/>
537.145 - <isset property="have.tests"/>
537.146 - </and>
537.147 - </condition>
537.148 - <condition property="no.javadoc.preview">
537.149 - <and>
537.150 - <isset property="javadoc.preview"/>
537.151 - <isfalse value="${javadoc.preview}"/>
537.152 - </and>
537.153 - </condition>
537.154 - <property name="run.jvmargs" value=""/>
537.155 - <property name="javac.compilerargs" value=""/>
537.156 - <property name="work.dir" value="${basedir}"/>
537.157 - <condition property="no.deps">
537.158 - <and>
537.159 - <istrue value="${no.dependencies}"/>
537.160 - </and>
537.161 - </condition>
537.162 - <property name="javac.debug" value="true"/>
537.163 - <property name="javadoc.preview" value="true"/>
537.164 - <property name="application.args" value=""/>
537.165 - <property name="source.encoding" value="${file.encoding}"/>
537.166 - <property name="runtime.encoding" value="${source.encoding}"/>
537.167 - <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
537.168 - <and>
537.169 - <isset property="javadoc.encoding"/>
537.170 - <not>
537.171 - <equals arg1="${javadoc.encoding}" arg2=""/>
537.172 - </not>
537.173 - </and>
537.174 - </condition>
537.175 - <property name="javadoc.encoding.used" value="${source.encoding}"/>
537.176 - <property name="includes" value="**"/>
537.177 - <property name="excludes" value=""/>
537.178 - <property name="do.depend" value="false"/>
537.179 - <condition property="do.depend.true">
537.180 - <istrue value="${do.depend}"/>
537.181 - </condition>
537.182 - <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
537.183 - <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
537.184 - <length length="0" string="${endorsed.classpath}" when="greater"/>
537.185 - </condition>
537.186 - <property name="javac.fork" value="false"/>
537.187 - </target>
537.188 - <target name="-post-init">
537.189 - <!-- Empty placeholder for easier customization. -->
537.190 - <!-- You can override this target in the ../build.xml file. -->
537.191 - </target>
537.192 - <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init" name="-init-check">
537.193 - <fail unless="src.dir">Must set src.dir</fail>
537.194 - <fail unless="test.src.dir">Must set test.src.dir</fail>
537.195 - <fail unless="build.dir">Must set build.dir</fail>
537.196 - <fail unless="dist.dir">Must set dist.dir</fail>
537.197 - <fail unless="build.classes.dir">Must set build.classes.dir</fail>
537.198 - <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
537.199 - <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
537.200 - <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
537.201 - <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
537.202 - <fail unless="dist.jar">Must set dist.jar</fail>
537.203 - </target>
537.204 - <target name="-init-macrodef-property">
537.205 - <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
537.206 - <attribute name="name"/>
537.207 - <attribute name="value"/>
537.208 - <sequential>
537.209 - <property name="@{name}" value="${@{value}}"/>
537.210 - </sequential>
537.211 - </macrodef>
537.212 - </target>
537.213 - <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors">
537.214 - <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
537.215 - <attribute default="${src.dir}" name="srcdir"/>
537.216 - <attribute default="${build.classes.dir}" name="destdir"/>
537.217 - <attribute default="${javac.classpath}" name="classpath"/>
537.218 - <attribute default="${javac.processorpath}" name="processorpath"/>
537.219 - <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
537.220 - <attribute default="${includes}" name="includes"/>
537.221 - <attribute default="${excludes}" name="excludes"/>
537.222 - <attribute default="${javac.debug}" name="debug"/>
537.223 - <attribute default="${empty.dir}" name="sourcepath"/>
537.224 - <attribute default="${empty.dir}" name="gensrcdir"/>
537.225 - <element name="customize" optional="true"/>
537.226 - <sequential>
537.227 - <property location="${build.dir}/empty" name="empty.dir"/>
537.228 - <mkdir dir="${empty.dir}"/>
537.229 - <mkdir dir="@{apgeneratedsrcdir}"/>
537.230 - <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
537.231 - <src>
537.232 - <dirset dir="@{gensrcdir}" erroronmissingdir="false">
537.233 - <include name="*"/>
537.234 - </dirset>
537.235 - </src>
537.236 - <classpath>
537.237 - <path path="@{classpath}"/>
537.238 - </classpath>
537.239 - <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
537.240 - <compilerarg line="${javac.compilerargs}"/>
537.241 - <compilerarg value="-processorpath"/>
537.242 - <compilerarg path="@{processorpath}"/>
537.243 - <compilerarg line="${ap.processors.internal}"/>
537.244 - <compilerarg value="-s"/>
537.245 - <compilerarg path="@{apgeneratedsrcdir}"/>
537.246 - <compilerarg line="${ap.proc.none.internal}"/>
537.247 - <customize/>
537.248 - </javac>
537.249 - </sequential>
537.250 - </macrodef>
537.251 - </target>
537.252 - <target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal">
537.253 - <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
537.254 - <attribute default="${src.dir}" name="srcdir"/>
537.255 - <attribute default="${build.classes.dir}" name="destdir"/>
537.256 - <attribute default="${javac.classpath}" name="classpath"/>
537.257 - <attribute default="${javac.processorpath}" name="processorpath"/>
537.258 - <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
537.259 - <attribute default="${includes}" name="includes"/>
537.260 - <attribute default="${excludes}" name="excludes"/>
537.261 - <attribute default="${javac.debug}" name="debug"/>
537.262 - <attribute default="${empty.dir}" name="sourcepath"/>
537.263 - <attribute default="${empty.dir}" name="gensrcdir"/>
537.264 - <element name="customize" optional="true"/>
537.265 - <sequential>
537.266 - <property location="${build.dir}/empty" name="empty.dir"/>
537.267 - <mkdir dir="${empty.dir}"/>
537.268 - <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
537.269 - <src>
537.270 - <dirset dir="@{gensrcdir}" erroronmissingdir="false">
537.271 - <include name="*"/>
537.272 - </dirset>
537.273 - </src>
537.274 - <classpath>
537.275 - <path path="@{classpath}"/>
537.276 - </classpath>
537.277 - <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
537.278 - <compilerarg line="${javac.compilerargs}"/>
537.279 - <customize/>
537.280 - </javac>
537.281 - </sequential>
537.282 - </macrodef>
537.283 - </target>
537.284 - <target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac">
537.285 - <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
537.286 - <attribute default="${src.dir}" name="srcdir"/>
537.287 - <attribute default="${build.classes.dir}" name="destdir"/>
537.288 - <attribute default="${javac.classpath}" name="classpath"/>
537.289 - <sequential>
537.290 - <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
537.291 - <classpath>
537.292 - <path path="@{classpath}"/>
537.293 - </classpath>
537.294 - </depend>
537.295 - </sequential>
537.296 - </macrodef>
537.297 - <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
537.298 - <attribute default="${build.classes.dir}" name="destdir"/>
537.299 - <sequential>
537.300 - <fail unless="javac.includes">Must set javac.includes</fail>
537.301 - <pathconvert pathsep="," property="javac.includes.binary">
537.302 - <path>
537.303 - <filelist dir="@{destdir}" files="${javac.includes}"/>
537.304 - </path>
537.305 - <globmapper from="*.java" to="*.class"/>
537.306 - </pathconvert>
537.307 - <delete>
537.308 - <files includes="${javac.includes.binary}"/>
537.309 - </delete>
537.310 - </sequential>
537.311 - </macrodef>
537.312 - </target>
537.313 - <target name="-init-macrodef-junit">
537.314 - <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
537.315 - <attribute default="${includes}" name="includes"/>
537.316 - <attribute default="${excludes}" name="excludes"/>
537.317 - <attribute default="**" name="testincludes"/>
537.318 - <sequential>
537.319 - <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}">
537.320 - <batchtest todir="${build.test.results.dir}">
537.321 - <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
537.322 - <filename name="@{testincludes}"/>
537.323 - </fileset>
537.324 - </batchtest>
537.325 - <classpath>
537.326 - <path path="${run.test.classpath}"/>
537.327 - </classpath>
537.328 - <syspropertyset>
537.329 - <propertyref prefix="test-sys-prop."/>
537.330 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
537.331 - </syspropertyset>
537.332 - <formatter type="brief" usefile="false"/>
537.333 - <formatter type="xml"/>
537.334 - <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
537.335 - <jvmarg line="${run.jvmargs}"/>
537.336 - </junit>
537.337 - </sequential>
537.338 - </macrodef>
537.339 - </target>
537.340 - <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
537.341 - <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
537.342 - <attribute default="${main.class}" name="name"/>
537.343 - <attribute default="${debug.classpath}" name="classpath"/>
537.344 - <attribute default="" name="stopclassname"/>
537.345 - <sequential>
537.346 - <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
537.347 - <classpath>
537.348 - <path path="@{classpath}"/>
537.349 - </classpath>
537.350 - </nbjpdastart>
537.351 - </sequential>
537.352 - </macrodef>
537.353 - <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
537.354 - <attribute default="${build.classes.dir}" name="dir"/>
537.355 - <sequential>
537.356 - <nbjpdareload>
537.357 - <fileset dir="@{dir}" includes="${fix.classes}">
537.358 - <include name="${fix.includes}*.class"/>
537.359 - </fileset>
537.360 - </nbjpdareload>
537.361 - </sequential>
537.362 - </macrodef>
537.363 - </target>
537.364 - <target name="-init-debug-args">
537.365 - <property name="version-output" value="java version "${ant.java.version}"/>
537.366 - <condition property="have-jdk-older-than-1.4">
537.367 - <or>
537.368 - <contains string="${version-output}" substring="java version "1.0"/>
537.369 - <contains string="${version-output}" substring="java version "1.1"/>
537.370 - <contains string="${version-output}" substring="java version "1.2"/>
537.371 - <contains string="${version-output}" substring="java version "1.3"/>
537.372 - </or>
537.373 - </condition>
537.374 - <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
537.375 - <istrue value="${have-jdk-older-than-1.4}"/>
537.376 - </condition>
537.377 - <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
537.378 - <os family="windows"/>
537.379 - </condition>
537.380 - <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
537.381 - <isset property="debug.transport"/>
537.382 - </condition>
537.383 - </target>
537.384 - <target depends="-init-debug-args" name="-init-macrodef-debug">
537.385 - <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
537.386 - <attribute default="${main.class}" name="classname"/>
537.387 - <attribute default="${debug.classpath}" name="classpath"/>
537.388 - <element name="customize" optional="true"/>
537.389 - <sequential>
537.390 - <java classname="@{classname}" dir="${work.dir}" fork="true">
537.391 - <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
537.392 - <jvmarg line="${debug-args-line}"/>
537.393 - <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
537.394 - <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
537.395 - <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
537.396 - <jvmarg line="${run.jvmargs}"/>
537.397 - <classpath>
537.398 - <path path="@{classpath}"/>
537.399 - </classpath>
537.400 - <syspropertyset>
537.401 - <propertyref prefix="run-sys-prop."/>
537.402 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
537.403 - </syspropertyset>
537.404 - <customize/>
537.405 - </java>
537.406 - </sequential>
537.407 - </macrodef>
537.408 - </target>
537.409 - <target name="-init-macrodef-java">
537.410 - <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
537.411 - <attribute default="${main.class}" name="classname"/>
537.412 - <attribute default="${run.classpath}" name="classpath"/>
537.413 - <element name="customize" optional="true"/>
537.414 - <sequential>
537.415 - <java classname="@{classname}" dir="${work.dir}" fork="true">
537.416 - <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
537.417 - <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
537.418 - <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
537.419 - <jvmarg line="${run.jvmargs}"/>
537.420 - <classpath>
537.421 - <path path="@{classpath}"/>
537.422 - </classpath>
537.423 - <syspropertyset>
537.424 - <propertyref prefix="run-sys-prop."/>
537.425 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
537.426 - </syspropertyset>
537.427 - <customize/>
537.428 - </java>
537.429 - </sequential>
537.430 - </macrodef>
537.431 - </target>
537.432 - <target name="-init-presetdef-jar">
537.433 - <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
537.434 - <jar compress="${jar.compress}" jarfile="${dist.jar}">
537.435 - <j2seproject1:fileset dir="${build.classes.dir}"/>
537.436 - </jar>
537.437 - </presetdef>
537.438 - </target>
537.439 - <target name="-init-ap-cmdline-properties">
537.440 - <property name="annotation.processing.enabled" value="true"/>
537.441 - <property name="annotation.processing.processors.list" value=""/>
537.442 - <property name="annotation.processing.run.all.processors" value="true"/>
537.443 - <property name="javac.processorpath" value="${javac.classpath}"/>
537.444 - <property name="javac.test.processorpath" value="${javac.test.classpath}"/>
537.445 - <condition property="ap.supported.internal" value="true">
537.446 - <not>
537.447 - <matches pattern="1\.[0-5](\..*)?" string="${javac.source}"/>
537.448 - </not>
537.449 - </condition>
537.450 - </target>
537.451 - <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-ap-cmdline-supported">
537.452 - <condition else="" property="ap.processors.internal" value="-processor ${annotation.processing.processors.list}">
537.453 - <isfalse value="${annotation.processing.run.all.processors}"/>
537.454 - </condition>
537.455 - <condition else="" property="ap.proc.none.internal" value="-proc:none">
537.456 - <isfalse value="${annotation.processing.enabled}"/>
537.457 - </condition>
537.458 - </target>
537.459 - <target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
537.460 - <property name="ap.cmd.line.internal" value=""/>
537.461 - </target>
537.462 - <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
537.463 - <!--
537.464 - ===================
537.465 - COMPILATION SECTION
537.466 - ===================
537.467 - -->
537.468 - <target name="-deps-jar-init" unless="built-jar.properties">
537.469 - <property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>
537.470 - <delete file="${built-jar.properties}" quiet="true"/>
537.471 - </target>
537.472 - <target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
537.473 - <echo level="warn" message="Cycle detected: indexer was already built"/>
537.474 - </target>
537.475 - <target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
537.476 - <mkdir dir="${build.dir}"/>
537.477 - <touch file="${built-jar.properties}" verbose="false"/>
537.478 - <property file="${built-jar.properties}" prefix="already.built.jar."/>
537.479 - <antcall target="-warn-already-built-jar"/>
537.480 - <propertyfile file="${built-jar.properties}">
537.481 - <entry key="${basedir}" value=""/>
537.482 - </propertyfile>
537.483 - <antcall target="-maybe-call-dep">
537.484 - <param name="call.built.properties" value="${built-jar.properties}"/>
537.485 - <param location="${project.org_netbeans_modules_jackpot30_api}" name="call.subproject"/>
537.486 - <param location="${project.org_netbeans_modules_jackpot30_api}/build.xml" name="call.script"/>
537.487 - <param name="call.target" value="netbeans"/>
537.488 - <param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
537.489 - </antcall>
537.490 - </target>
537.491 - <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
537.492 - <target depends="init" name="-check-automatic-build">
537.493 - <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
537.494 - </target>
537.495 - <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
537.496 - <antcall target="clean"/>
537.497 - </target>
537.498 - <target depends="init,deps-jar" name="-pre-pre-compile">
537.499 - <mkdir dir="${build.classes.dir}"/>
537.500 - </target>
537.501 - <target name="-pre-compile">
537.502 - <!-- Empty placeholder for easier customization. -->
537.503 - <!-- You can override this target in the ../build.xml file. -->
537.504 - </target>
537.505 - <target if="do.depend.true" name="-compile-depend">
537.506 - <pathconvert property="build.generated.subdirs">
537.507 - <dirset dir="${build.generated.sources.dir}" erroronmissingdir="false">
537.508 - <include name="*"/>
537.509 - </dirset>
537.510 - </pathconvert>
537.511 - <j2seproject3:depend srcdir="${src.dir}:${build.generated.subdirs}"/>
537.512 - </target>
537.513 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
537.514 - <j2seproject3:javac gensrcdir="${build.generated.sources.dir}"/>
537.515 - <copy todir="${build.classes.dir}">
537.516 - <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
537.517 - </copy>
537.518 - </target>
537.519 - <target name="-post-compile">
537.520 - <!-- Empty placeholder for easier customization. -->
537.521 - <!-- You can override this target in the ../build.xml file. -->
537.522 - </target>
537.523 - <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
537.524 - <target name="-pre-compile-single">
537.525 - <!-- Empty placeholder for easier customization. -->
537.526 - <!-- You can override this target in the ../build.xml file. -->
537.527 - </target>
537.528 - <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
537.529 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
537.530 - <j2seproject3:force-recompile/>
537.531 - <j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.dir}"/>
537.532 - </target>
537.533 - <target name="-post-compile-single">
537.534 - <!-- Empty placeholder for easier customization. -->
537.535 - <!-- You can override this target in the ../build.xml file. -->
537.536 - </target>
537.537 - <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
537.538 - <!--
537.539 - ====================
537.540 - JAR BUILDING SECTION
537.541 - ====================
537.542 - -->
537.543 - <target depends="init" name="-pre-pre-jar">
537.544 - <dirname file="${dist.jar}" property="dist.jar.dir"/>
537.545 - <mkdir dir="${dist.jar.dir}"/>
537.546 - </target>
537.547 - <target name="-pre-jar">
537.548 - <!-- Empty placeholder for easier customization. -->
537.549 - <!-- You can override this target in the ../build.xml file. -->
537.550 - </target>
537.551 - <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available-mkdist.available">
537.552 - <j2seproject1:jar/>
537.553 - </target>
537.554 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class-mkdist.available">
537.555 - <j2seproject1:jar manifest="${manifest.file}"/>
537.556 - </target>
537.557 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
537.558 - <j2seproject1:jar manifest="${manifest.file}">
537.559 - <j2seproject1:manifest>
537.560 - <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
537.561 - </j2seproject1:manifest>
537.562 - </j2seproject1:jar>
537.563 - <echo>To run this application from the command line without Ant, try:</echo>
537.564 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
537.565 - <property location="${dist.jar}" name="dist.jar.resolved"/>
537.566 - <pathconvert property="run.classpath.with.dist.jar">
537.567 - <path path="${run.classpath}"/>
537.568 - <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
537.569 - </pathconvert>
537.570 - <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
537.571 - </target>
537.572 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
537.573 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
537.574 - <pathconvert property="run.classpath.without.build.classes.dir">
537.575 - <path path="${run.classpath}"/>
537.576 - <map from="${build.classes.dir.resolved}" to=""/>
537.577 - </pathconvert>
537.578 - <pathconvert pathsep=" " property="jar.classpath">
537.579 - <path path="${run.classpath.without.build.classes.dir}"/>
537.580 - <chainedmapper>
537.581 - <flattenmapper/>
537.582 - <globmapper from="*" to="lib/*"/>
537.583 - </chainedmapper>
537.584 - </pathconvert>
537.585 - <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
537.586 - <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
537.587 - <fileset dir="${build.classes.dir}"/>
537.588 - <manifest>
537.589 - <attribute name="Main-Class" value="${main.class}"/>
537.590 - <attribute name="Class-Path" value="${jar.classpath}"/>
537.591 - </manifest>
537.592 - </copylibs>
537.593 - <echo>To run this application from the command line without Ant, try:</echo>
537.594 - <property location="${dist.jar}" name="dist.jar.resolved"/>
537.595 - <echo>java -jar "${dist.jar.resolved}"</echo>
537.596 - </target>
537.597 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+mkdist.available" name="-do-jar-with-libraries-without-mainclass" unless="main.class.available">
537.598 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
537.599 - <pathconvert property="run.classpath.without.build.classes.dir">
537.600 - <path path="${run.classpath}"/>
537.601 - <map from="${build.classes.dir.resolved}" to=""/>
537.602 - </pathconvert>
537.603 - <pathconvert pathsep=" " property="jar.classpath">
537.604 - <path path="${run.classpath.without.build.classes.dir}"/>
537.605 - <chainedmapper>
537.606 - <flattenmapper/>
537.607 - <globmapper from="*" to="lib/*"/>
537.608 - </chainedmapper>
537.609 - </pathconvert>
537.610 - <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
537.611 - <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
537.612 - <fileset dir="${build.classes.dir}"/>
537.613 - <manifest>
537.614 - <attribute name="Class-Path" value="${jar.classpath}"/>
537.615 - </manifest>
537.616 - </copylibs>
537.617 - </target>
537.618 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.mkdist" name="-do-jar-with-libraries-without-manifest" unless="manifest.available">
537.619 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
537.620 - <pathconvert property="run.classpath.without.build.classes.dir">
537.621 - <path path="${run.classpath}"/>
537.622 - <map from="${build.classes.dir.resolved}" to=""/>
537.623 - </pathconvert>
537.624 - <pathconvert pathsep=" " property="jar.classpath">
537.625 - <path path="${run.classpath.without.build.classes.dir}"/>
537.626 - <chainedmapper>
537.627 - <flattenmapper/>
537.628 - <globmapper from="*" to="lib/*"/>
537.629 - </chainedmapper>
537.630 - </pathconvert>
537.631 - <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
537.632 - <copylibs compress="${jar.compress}" jarfile="${dist.jar}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
537.633 - <fileset dir="${build.classes.dir}"/>
537.634 - <manifest>
537.635 - <attribute name="Class-Path" value="${jar.classpath}"/>
537.636 - </manifest>
537.637 - </copylibs>
537.638 - </target>
537.639 - <target name="-post-jar">
537.640 - <!-- Empty placeholder for easier customization. -->
537.641 - <!-- You can override this target in the ../build.xml file. -->
537.642 - </target>
537.643 - <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-do-jar-with-libraries-without-mainclass,-do-jar-with-libraries-without-manifest,-post-jar" description="Build JAR." name="jar"/>
537.644 - <!--
537.645 - =================
537.646 - EXECUTION SECTION
537.647 - =================
537.648 - -->
537.649 - <target depends="init,compile" description="Run a main class." name="run">
537.650 - <j2seproject1:java>
537.651 - <customize>
537.652 - <arg line="${application.args}"/>
537.653 - </customize>
537.654 - </j2seproject1:java>
537.655 - </target>
537.656 - <target name="-do-not-recompile">
537.657 - <property name="javac.includes.binary" value=""/>
537.658 - </target>
537.659 - <target depends="init,compile-single" name="run-single">
537.660 - <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
537.661 - <j2seproject1:java classname="${run.class}"/>
537.662 - </target>
537.663 - <target depends="init,compile-test-single" name="run-test-with-main">
537.664 - <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
537.665 - <j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
537.666 - </target>
537.667 - <!--
537.668 - =================
537.669 - DEBUGGING SECTION
537.670 - =================
537.671 - -->
537.672 - <target depends="init" if="netbeans.home" name="-debug-start-debugger">
537.673 - <j2seproject1:nbjpdastart name="${debug.class}"/>
537.674 - </target>
537.675 - <target depends="init" if="netbeans.home" name="-debug-start-debugger-main-test">
537.676 - <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${debug.class}"/>
537.677 - </target>
537.678 - <target depends="init,compile" name="-debug-start-debuggee">
537.679 - <j2seproject3:debug>
537.680 - <customize>
537.681 - <arg line="${application.args}"/>
537.682 - </customize>
537.683 - </j2seproject3:debug>
537.684 - </target>
537.685 - <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
537.686 - <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
537.687 - <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
537.688 - </target>
537.689 - <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
537.690 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
537.691 - <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
537.692 - <j2seproject3:debug classname="${debug.class}"/>
537.693 - </target>
537.694 - <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
537.695 - <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">
537.696 - <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
537.697 - <j2seproject3:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>
537.698 - </target>
537.699 - <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
537.700 - <target depends="init" name="-pre-debug-fix">
537.701 - <fail unless="fix.includes">Must set fix.includes</fail>
537.702 - <property name="javac.includes" value="${fix.includes}.java"/>
537.703 - </target>
537.704 - <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
537.705 - <j2seproject1:nbjpdareload/>
537.706 - </target>
537.707 - <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
537.708 - <!--
537.709 - ===============
537.710 - JAVADOC SECTION
537.711 - ===============
537.712 - -->
537.713 - <target depends="init" name="-javadoc-build">
537.714 - <mkdir dir="${dist.javadoc.dir}"/>
537.715 - <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
537.716 - <classpath>
537.717 - <path path="${javac.classpath}"/>
537.718 - </classpath>
537.719 - <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
537.720 - <filename name="**/*.java"/>
537.721 - </fileset>
537.722 - <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
537.723 - <include name="**/*.java"/>
537.724 - </fileset>
537.725 - </javadoc>
537.726 - </target>
537.727 - <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
537.728 - <nbbrowse file="${dist.javadoc.dir}/index.html"/>
537.729 - </target>
537.730 - <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
537.731 - <!--
537.732 - =========================
537.733 - JUNIT COMPILATION SECTION
537.734 - =========================
537.735 - -->
537.736 - <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
537.737 - <mkdir dir="${build.test.classes.dir}"/>
537.738 - </target>
537.739 - <target name="-pre-compile-test">
537.740 - <!-- Empty placeholder for easier customization. -->
537.741 - <!-- You can override this target in the ../build.xml file. -->
537.742 - </target>
537.743 - <target if="do.depend.true" name="-compile-test-depend">
537.744 - <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
537.745 - </target>
537.746 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
537.747 - <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.src.dir}"/>
537.748 - <copy todir="${build.test.classes.dir}">
537.749 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
537.750 - </copy>
537.751 - </target>
537.752 - <target name="-post-compile-test">
537.753 - <!-- Empty placeholder for easier customization. -->
537.754 - <!-- You can override this target in the ../build.xml file. -->
537.755 - </target>
537.756 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
537.757 - <target name="-pre-compile-test-single">
537.758 - <!-- Empty placeholder for easier customization. -->
537.759 - <!-- You can override this target in the ../build.xml file. -->
537.760 - </target>
537.761 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
537.762 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
537.763 - <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
537.764 - <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
537.765 - <copy todir="${build.test.classes.dir}">
537.766 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
537.767 - </copy>
537.768 - </target>
537.769 - <target name="-post-compile-test-single">
537.770 - <!-- Empty placeholder for easier customization. -->
537.771 - <!-- You can override this target in the ../build.xml file. -->
537.772 - </target>
537.773 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
537.774 - <!--
537.775 - =======================
537.776 - JUNIT EXECUTION SECTION
537.777 - =======================
537.778 - -->
537.779 - <target depends="init" if="have.tests" name="-pre-test-run">
537.780 - <mkdir dir="${build.test.results.dir}"/>
537.781 - </target>
537.782 - <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
537.783 - <j2seproject3:junit testincludes="**/*Test.java"/>
537.784 - </target>
537.785 - <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
537.786 - <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
537.787 - </target>
537.788 - <target depends="init" if="have.tests" name="test-report"/>
537.789 - <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
537.790 - <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
537.791 - <target depends="init" if="have.tests" name="-pre-test-run-single">
537.792 - <mkdir dir="${build.test.results.dir}"/>
537.793 - </target>
537.794 - <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
537.795 - <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
537.796 - <j2seproject3:junit excludes="" includes="${test.includes}"/>
537.797 - </target>
537.798 - <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
537.799 - <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
537.800 - </target>
537.801 - <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
537.802 - <!--
537.803 - =======================
537.804 - JUNIT DEBUGGING SECTION
537.805 - =======================
537.806 - -->
537.807 - <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
537.808 - <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
537.809 - <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
537.810 - <delete file="${test.report.file}"/>
537.811 - <mkdir dir="${build.test.results.dir}"/>
537.812 - <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
537.813 - <customize>
537.814 - <syspropertyset>
537.815 - <propertyref prefix="test-sys-prop."/>
537.816 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
537.817 - </syspropertyset>
537.818 - <arg value="${test.class}"/>
537.819 - <arg value="showoutput=true"/>
537.820 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
537.821 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
537.822 - </customize>
537.823 - </j2seproject3:debug>
537.824 - </target>
537.825 - <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
537.826 - <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
537.827 - </target>
537.828 - <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
537.829 - <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
537.830 - <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
537.831 - </target>
537.832 - <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
537.833 - <!--
537.834 - =========================
537.835 - APPLET EXECUTION SECTION
537.836 - =========================
537.837 - -->
537.838 - <target depends="init,compile-single" name="run-applet">
537.839 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
537.840 - <j2seproject1:java classname="sun.applet.AppletViewer">
537.841 - <customize>
537.842 - <arg value="${applet.url}"/>
537.843 - </customize>
537.844 - </j2seproject1:java>
537.845 - </target>
537.846 - <!--
537.847 - =========================
537.848 - APPLET DEBUGGING SECTION
537.849 - =========================
537.850 - -->
537.851 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
537.852 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
537.853 - <j2seproject3:debug classname="sun.applet.AppletViewer">
537.854 - <customize>
537.855 - <arg value="${applet.url}"/>
537.856 - </customize>
537.857 - </j2seproject3:debug>
537.858 - </target>
537.859 - <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
537.860 - <!--
537.861 - ===============
537.862 - CLEANUP SECTION
537.863 - ===============
537.864 - -->
537.865 - <target name="-deps-clean-init" unless="built-clean.properties">
537.866 - <property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>
537.867 - <delete file="${built-clean.properties}" quiet="true"/>
537.868 - </target>
537.869 - <target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
537.870 - <echo level="warn" message="Cycle detected: indexer was already built"/>
537.871 - </target>
537.872 - <target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
537.873 - <mkdir dir="${build.dir}"/>
537.874 - <touch file="${built-clean.properties}" verbose="false"/>
537.875 - <property file="${built-clean.properties}" prefix="already.built.clean."/>
537.876 - <antcall target="-warn-already-built-clean"/>
537.877 - <propertyfile file="${built-clean.properties}">
537.878 - <entry key="${basedir}" value=""/>
537.879 - </propertyfile>
537.880 - <antcall target="-maybe-call-dep">
537.881 - <param name="call.built.properties" value="${built-clean.properties}"/>
537.882 - <param location="${project.org_netbeans_modules_jackpot30_api}" name="call.subproject"/>
537.883 - <param location="${project.org_netbeans_modules_jackpot30_api}/build.xml" name="call.script"/>
537.884 - <param name="call.target" value="clean"/>
537.885 - <param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
537.886 - </antcall>
537.887 - </target>
537.888 - <target depends="init" name="-do-clean">
537.889 - <delete dir="${build.dir}"/>
537.890 - <delete dir="${dist.dir}" followsymlinks="false" includeemptydirs="true"/>
537.891 - </target>
537.892 - <target name="-post-clean">
537.893 - <!-- Empty placeholder for easier customization. -->
537.894 - <!-- You can override this target in the ../build.xml file. -->
537.895 - </target>
537.896 - <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
537.897 - <target name="-check-call-dep">
537.898 - <property file="${call.built.properties}" prefix="already.built."/>
537.899 - <condition property="should.call.dep">
537.900 - <not>
537.901 - <isset property="already.built.${call.subproject}"/>
537.902 - </not>
537.903 - </condition>
537.904 - <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
537.905 - <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:${toString:endorsed.classpath.path}">
537.906 - <length length="0" string="${endorsed.classpath}" when="greater"/>
537.907 - </condition>
537.908 - </target>
537.909 - <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
537.910 - <ant antfile="${call.script}" inheritall="false" target="${call.target}">
537.911 - <propertyset>
537.912 - <propertyref prefix="transfer."/>
537.913 - <mapper from="transfer.*" to="*" type="glob"/>
537.914 - </propertyset>
537.915 - </ant>
537.916 - </target>
537.917 -</project>
538.1 --- a/server/indexer/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
538.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
538.3 @@ -1,8 +0,0 @@
538.4 -build.xml.data.CRC32=8f49f787
538.5 -build.xml.script.CRC32=48d52495
538.6 -build.xml.stylesheet.CRC32=958a1d3e@1.27.0.45
538.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
538.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
538.9 -nbproject/build-impl.xml.data.CRC32=8f49f787
538.10 -nbproject/build-impl.xml.script.CRC32=81f22719
538.11 -nbproject/build-impl.xml.stylesheet.CRC32=1cdc5be9@1.35.0.45
539.1 --- a/server/indexer/nbproject/project.properties Fri Jan 27 13:35:56 2012 +0100
539.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
539.3 @@ -1,95 +0,0 @@
539.4 -annotation.processing.enabled=true
539.5 -annotation.processing.enabled.in.editor=false
539.6 -annotation.processing.run.all.processors=true
539.7 -application.title=indexer
539.8 -application.vendor=lahvac
539.9 -build.classes.dir=${build.dir}/classes
539.10 -build.classes.excludes=**/*.java,**/*.form
539.11 -# This directory is removed when the project is cleaned:
539.12 -build.dir=build
539.13 -build.generated.dir=${build.dir}/generated
539.14 -build.generated.sources.dir=${build.dir}/generated-sources
539.15 -# Only compile against the classpath explicitly listed here:
539.16 -build.sysclasspath=ignore
539.17 -build.test.classes.dir=${build.dir}/test/classes
539.18 -build.test.results.dir=${build.dir}/test/results
539.19 -# Uncomment to specify the preferred debugger connection transport:
539.20 -#debug.transport=dt_socket
539.21 -debug.classpath=\
539.22 - ${run.classpath}
539.23 -debug.test.classpath=\
539.24 - ${run.test.classpath}
539.25 -# This directory is removed when the project is cleaned:
539.26 -dist.dir=dist
539.27 -dist.jar=${dist.dir}/indexer.jar
539.28 -dist.javadoc.dir=${dist.dir}/javadoc
539.29 -endorsed.classpath=\
539.30 - ${libs.javac.classpath}
539.31 -excludes=
539.32 -file.reference.org-netbeans-modules-java-hints.jar=../lib/org-netbeans-modules-java-hints.jar
539.33 -file.reference.org-netbeans-modules-java-source.jar=../lib/org-netbeans-modules-java-source.jar
539.34 -file.reference.org-netbeans-spi-editor-hints.jar=../lib/org-netbeans-spi-editor-hints.jar
539.35 -file.reference.org-openide-filesystems.jar=../lib/org-openide-filesystems.jar
539.36 -file.reference.org-openide-util-lookup.jar=../lib/org-openide-util-lookup.jar
539.37 -file.reference.org-openide-util.jar=../lib/org-openide-util.jar
539.38 -file.reference.util-commons.jar-1=../../remoting/ide/api/external/util-commons.jar
539.39 -file.reference.util-pojson.jar-1=../../remoting/ide/api/external/util-pojson.jar
539.40 -includes=**
539.41 -jar.compress=false
539.42 -javac.classpath=\
539.43 - ${reference.org_netbeans_modules_jackpot30_api.module}:\
539.44 - ${libs.lucene.classpath}:\
539.45 - ${libs.javac.classpath}:\
539.46 - ${file.reference.org-netbeans-modules-java-source.jar}:\
539.47 - ${file.reference.org-openide-filesystems.jar}:\
539.48 - ${file.reference.org-openide-util.jar}:\
539.49 - ${file.reference.org-openide-util-lookup.jar}:\
539.50 - ${file.reference.org-netbeans-spi-editor-hints.jar}:\
539.51 - ${file.reference.org-netbeans-modules-java-hints.jar}:\
539.52 - ${file.reference.util-commons.jar-1}:\
539.53 - ${file.reference.util-pojson.jar-1}
539.54 -# Space-separated list of extra javac options
539.55 -javac.compilerargs=
539.56 -javac.deprecation=false
539.57 -javac.processorpath=\
539.58 - ${javac.classpath}
539.59 -javac.source=1.5
539.60 -javac.target=1.5
539.61 -javac.test.classpath=\
539.62 - ${javac.classpath}:\
539.63 - ${build.classes.dir}:\
539.64 - ${libs.junit_4.classpath}
539.65 -javadoc.additionalparam=
539.66 -javadoc.author=false
539.67 -javadoc.encoding=${source.encoding}
539.68 -javadoc.noindex=false
539.69 -javadoc.nonavbar=false
539.70 -javadoc.notree=false
539.71 -javadoc.private=false
539.72 -javadoc.splitindex=true
539.73 -javadoc.use=true
539.74 -javadoc.version=false
539.75 -javadoc.windowtitle=
539.76 -jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api"
539.77 -main.class=org.netbeans.modules.jackpot30.server.indexer.Index
539.78 -manifest.file=manifest.mf
539.79 -meta.inf.dir=${src.dir}/META-INF
539.80 -mkdist.disabled=false
539.81 -platform.active=default_platform
539.82 -project.org_netbeans_modules_jackpot30_api=../../api
539.83 -reference.org_netbeans_modules_jackpot30_api.module=${project.org_netbeans_modules_jackpot30_api}/../build/cluster/modules/org-netbeans-modules-jackpot30-api.jar
539.84 -run.classpath=\
539.85 - ${javac.classpath}:\
539.86 - ${build.classes.dir}
539.87 -# Space-separated list of JVM arguments used when running the project
539.88 -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
539.89 -# or test-sys-prop.name=value to set system properties for unit tests):
539.90 -run.jvmargs=
539.91 -run.test.classpath=\
539.92 - ${javac.test.classpath}:\
539.93 - ${build.test.classes.dir}
539.94 -source.encoding=UTF-8
539.95 -src.dir=src
539.96 -test.src.dir=test
539.97 -
539.98 -hudson.compiler.dir=../hudson/data/compiler
540.1 --- a/server/indexer/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
540.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
540.3 @@ -1,28 +0,0 @@
540.4 -<?xml version="1.0" encoding="UTF-8"?>
540.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
540.6 - <type>org.netbeans.modules.java.j2seproject</type>
540.7 - <configuration>
540.8 - <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
540.9 - <name>indexer</name>
540.10 - <source-roots>
540.11 - <root id="src.dir"/>
540.12 - </source-roots>
540.13 - <test-roots>
540.14 - <root id="test.src.dir"/>
540.15 - </test-roots>
540.16 - </data>
540.17 - <libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
540.18 - <definitions>../lib/nblibraries.properties</definitions>
540.19 - </libraries>
540.20 - <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
540.21 - <reference>
540.22 - <foreign-project>org_netbeans_modules_jackpot30_api</foreign-project>
540.23 - <artifact-type>jar</artifact-type>
540.24 - <script>build.xml</script>
540.25 - <target>netbeans</target>
540.26 - <clean-target>clean</clean-target>
540.27 - <id>module</id>
540.28 - </reference>
540.29 - </references>
540.30 - </configuration>
540.31 -</project>
541.1 --- a/server/indexer/src/org/netbeans/modules/jackpot30/server/indexer/Index.java Fri Jan 27 13:35:56 2012 +0100
541.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
541.3 @@ -1,106 +0,0 @@
541.4 -/*
541.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
541.6 - *
541.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
541.8 - *
541.9 - * The contents of this file are subject to the terms of either the GNU
541.10 - * General Public License Version 2 only ("GPL") or the Common
541.11 - * Development and Distribution License("CDDL") (collectively, the
541.12 - * "License"). You may not use this file except in compliance with the
541.13 - * License. You can obtain a copy of the License at
541.14 - * http://www.netbeans.org/cddl-gplv2.html
541.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
541.16 - * specific language governing permissions and limitations under the
541.17 - * License. When distributing the software, include this License Header
541.18 - * Notice in each file and include the License file at
541.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
541.20 - * particular file as subject to the "Classpath" exception as provided
541.21 - * by Sun in the GPL Version 2 section of the License file that
541.22 - * accompanied this code. If applicable, add the following below the
541.23 - * License Header, with the fields enclosed by brackets [] replaced by
541.24 - * your own identifying information:
541.25 - * "Portions Copyrighted [year] [name of copyright owner]"
541.26 - *
541.27 - * If you wish your version of this file to be governed by only the CDDL
541.28 - * or only the GPL Version 2, indicate your decision by adding
541.29 - * "[Contributor] elects to include this software in this distribution
541.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
541.31 - * single choice of license, a recipient has the option to distribute
541.32 - * your version of this file under either the CDDL, the GPL Version 2 or
541.33 - * to extend the choice of license to its licensees as provided above.
541.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
541.35 - * Version 2 license, then the option applies only if the new code is
541.36 - * made subject to such option by the copyright holder.
541.37 - *
541.38 - * Contributor(s):
541.39 - *
541.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
541.41 - */
541.42 -
541.43 -package org.netbeans.modules.jackpot30.server.indexer;
541.44 -
541.45 -import java.io.File;
541.46 -import java.io.IOException;
541.47 -import java.util.ArrayList;
541.48 -import java.util.Arrays;
541.49 -import java.util.List;
541.50 -import org.netbeans.modules.jackpot30.impl.indexing.Cache;
541.51 -import org.netbeans.modules.java.hints.jackpot.impl.Utilities;
541.52 -
541.53 -/**
541.54 - *
541.55 - * @author lahvac
541.56 - */
541.57 -public class Index {
541.58 -
541.59 - static final String PARAM_CONSTRUCT_DUPLICATES_INDEX = "-construct-duplicates-index";
541.60 - static final String PARAM_STORE_SOURCES = "-store-sources";
541.61 -
541.62 - /**
541.63 - * @param args the command line arguments
541.64 - */
541.65 - public static void main(String[] args) throws IOException {
541.66 - new Index().index(args);
541.67 - }
541.68 -
541.69 - void index(String[] args) throws IOException {
541.70 - List<String> argsList = new ArrayList<String>(Arrays.asList(args));
541.71 - boolean constructDuplicatesIndex = !argsList.isEmpty() && PARAM_CONSTRUCT_DUPLICATES_INDEX.equals(argsList.get(0));
541.72 -
541.73 - if (constructDuplicatesIndex) argsList.remove(0);
541.74 -
541.75 - boolean storeSources = !argsList.isEmpty() && PARAM_STORE_SOURCES.equals(argsList.get(0));
541.76 -
541.77 - if (storeSources) argsList.remove(0);
541.78 -
541.79 - String modified = null;
541.80 - String removed = null;
541.81 -
541.82 - if (argsList.size() != 2 && argsList.size() != 4) {
541.83 - printHelp();
541.84 - return ;
541.85 - }
541.86 -
541.87 - if (argsList.size() == 4) {
541.88 - modified = argsList.get(2);
541.89 - removed = argsList.get(3);
541.90 - }
541.91 -
541.92 - long startTime = System.currentTimeMillis();
541.93 -
541.94 - Cache.setStandaloneCacheRoot(new File(argsList.get(1)));
541.95 - invokeIndexer(new File(argsList.get(0)), constructDuplicatesIndex, storeSources, modified, removed);
541.96 -
541.97 - long endTime = System.currentTimeMillis();
541.98 -
541.99 - System.out.println("indexing took: " + Utilities.toHumanReadableTime(endTime - startTime));
541.100 - }
541.101 -
541.102 - protected void invokeIndexer(File root, boolean duplicatesIndex, boolean storeSources, String modified, String removed) throws IOException {
541.103 - StandaloneIndexer.index(root, duplicatesIndex, storeSources, modified, removed);
541.104 - }
541.105 -
541.106 - protected void printHelp() {
541.107 - System.err.println("Usage: java -jar " + Index.class.getProtectionDomain().getCodeSource().getLocation().getPath() + " [" + PARAM_CONSTRUCT_DUPLICATES_INDEX + "] [" + PARAM_STORE_SOURCES + "] <source-root> <cache> [<modified-files> <removed-files>]");
541.108 - }
541.109 -}
542.1 --- a/server/indexer/src/org/netbeans/modules/jackpot30/server/indexer/StandaloneFinder.java Fri Jan 27 13:35:56 2012 +0100
542.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
542.3 @@ -1,202 +0,0 @@
542.4 -/*
542.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
542.6 - *
542.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
542.8 - *
542.9 - * The contents of this file are subject to the terms of either the GNU
542.10 - * General Public License Version 2 only ("GPL") or the Common
542.11 - * Development and Distribution License("CDDL") (collectively, the
542.12 - * "License"). You may not use this file except in compliance with the
542.13 - * License. You can obtain a copy of the License at
542.14 - * http://www.netbeans.org/cddl-gplv2.html
542.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
542.16 - * specific language governing permissions and limitations under the
542.17 - * License. When distributing the software, include this License Header
542.18 - * Notice in each file and include the License file at
542.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
542.20 - * particular file as subject to the "Classpath" exception as provided
542.21 - * by Sun in the GPL Version 2 section of the License file that
542.22 - * accompanied this code. If applicable, add the following below the
542.23 - * License Header, with the fields enclosed by brackets [] replaced by
542.24 - * your own identifying information:
542.25 - * "Portions Copyrighted [year] [name of copyright owner]"
542.26 - *
542.27 - * If you wish your version of this file to be governed by only the CDDL
542.28 - * or only the GPL Version 2, indicate your decision by adding
542.29 - * "[Contributor] elects to include this software in this distribution
542.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
542.31 - * single choice of license, a recipient has the option to distribute
542.32 - * your version of this file under either the CDDL, the GPL Version 2 or
542.33 - * to extend the choice of license to its licensees as provided above.
542.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
542.35 - * Version 2 license, then the option applies only if the new code is
542.36 - * made subject to such option by the copyright holder.
542.37 - *
542.38 - * Contributor(s):
542.39 - *
542.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
542.41 - */
542.42 -
542.43 -package org.netbeans.modules.jackpot30.server.indexer;
542.44 -
542.45 -import com.sun.source.tree.CompilationUnitTree;
542.46 -import com.sun.source.tree.Tree;
542.47 -import com.sun.source.util.TreePath;
542.48 -import com.sun.source.util.Trees;
542.49 -import com.sun.tools.javac.api.JavacTaskImpl;
542.50 -import java.io.File;
542.51 -import java.io.IOException;
542.52 -import java.net.URI;
542.53 -import java.util.Arrays;
542.54 -import java.util.BitSet;
542.55 -import java.util.Collection;
542.56 -import java.util.Collections;
542.57 -import java.util.HashMap;
542.58 -import java.util.LinkedList;
542.59 -import java.util.Map;
542.60 -import javax.tools.Diagnostic;
542.61 -import javax.tools.JavaCompiler;
542.62 -import javax.tools.JavaFileObject;
542.63 -import javax.tools.SimpleJavaFileObject;
542.64 -import javax.tools.ToolProvider;
542.65 -import org.apache.lucene.document.Document;
542.66 -import org.apache.lucene.index.IndexReader;
542.67 -import org.apache.lucene.index.Term;
542.68 -import org.apache.lucene.search.Collector;
542.69 -import org.apache.lucene.search.IndexSearcher;
542.70 -import org.apache.lucene.search.Query;
542.71 -import org.apache.lucene.search.Searcher;
542.72 -import org.apache.lucene.search.TermQuery;
542.73 -import org.apache.lucene.store.FSDirectory;
542.74 -import org.netbeans.modules.jackpot30.impl.duplicates.indexing.DuplicatesIndex;
542.75 -import org.netbeans.modules.jackpot30.impl.indexing.AbstractLuceneIndex.BitSetCollector;
542.76 -import org.netbeans.modules.jackpot30.impl.indexing.Cache;
542.77 -import org.netbeans.modules.jackpot30.impl.indexing.FileBasedIndex;
542.78 -import org.netbeans.modules.java.hints.jackpot.impl.Utilities;
542.79 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch;
542.80 -import org.netbeans.modules.java.hints.jackpot.impl.pm.BulkSearch.BulkPattern;
542.81 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
542.82 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription.AdditionalQueryConstraints;
542.83 -import org.netbeans.modules.java.hints.jackpot.spi.PatternConvertor;
542.84 -import org.netbeans.modules.java.hints.jackpot.spi.Trigger.PatternDescription;
542.85 -
542.86 -/**
542.87 - *
542.88 - * @author lahvac
542.89 - */
542.90 -public class StandaloneFinder {
542.91 -
542.92 - public static Collection<? extends String> findCandidates(File sourceRoot, String pattern) throws IOException {
542.93 - BulkPattern bulkPattern = preparePattern(pattern, null);
542.94 -
542.95 - return FileBasedIndex.get(sourceRoot.toURI().toURL()).findCandidates(bulkPattern);
542.96 - }
542.97 -
542.98 - public static int[] findCandidateOccurrenceSpans(File sourceRoot, String relativePath, String pattern) throws IOException {
542.99 - BulkPattern bulkPattern = preparePattern(pattern, null);
542.100 - CharSequence source = FileBasedIndex.get(sourceRoot.toURI().toURL()).getSourceCode(relativePath).toString().replaceAll("\r\n", "\n");
542.101 - JavacTaskImpl jti = prepareJavacTaskImpl();
542.102 - CompilationUnitTree cut = jti.parse(new JFOImpl(source)).iterator().next();
542.103 - Collection<TreePath> paths = new LinkedList<TreePath>();
542.104 -
542.105 - for (Collection<TreePath> c : BulkSearch.getDefault().match(null, new TreePath(cut), bulkPattern).values()) {
542.106 - paths.addAll(c);
542.107 - }
542.108 -
542.109 - Trees t = Trees.instance(jti);
542.110 - int[] result = new int[2 * paths.size()];
542.111 - int i = 0;
542.112 -
542.113 - for (TreePath tp : paths) {
542.114 - result[i++] = (int) t.getSourcePositions().getStartPosition(cut, tp.getLeaf());
542.115 - result[i++] = (int) t.getSourcePositions().getEndPosition(cut, tp.getLeaf());
542.116 - }
542.117 -
542.118 - return result;
542.119 - }
542.120 -
542.121 - public static Collection<Diagnostic<? extends JavaFileObject>> parseAndReportErrors(String pattern) {
542.122 - Collection<Diagnostic<? extends JavaFileObject>> errors = new LinkedList<Diagnostic<? extends JavaFileObject>>();
542.123 -
542.124 - preparePattern(pattern, errors);
542.125 -
542.126 - return errors;
542.127 - }
542.128 -
542.129 - public static Map<String, Collection<? extends String>> containsHash(File sourceRoot, Iterable<? extends String> hashes) throws IOException {
542.130 - File cacheRoot = Cache.findCache(DuplicatesIndex.NAME, DuplicatesIndex.VERSION).findCacheRoot(sourceRoot.toURI().toURL());
542.131 - File dir = new File(cacheRoot, "fulltext");
542.132 -
542.133 - if (dir.listFiles() != null && dir.listFiles().length > 0) {
542.134 - IndexReader reader = IndexReader.open(FSDirectory.open(dir), true);
542.135 - Map<String, Collection<? extends String>> result = new HashMap<String, Collection<? extends String>>();
542.136 -
542.137 - for (String hash : hashes) {
542.138 - Collection<String> found = new LinkedList<String>();
542.139 - Query query = new TermQuery(new Term("generalized", hash));
542.140 - Searcher s = new IndexSearcher(reader);
542.141 - BitSet matchingDocuments = new BitSet(reader.maxDoc());
542.142 - Collector c = new BitSetCollector(matchingDocuments);
542.143 -
542.144 - s.search(query, c);
542.145 -
542.146 - for (int docNum = matchingDocuments.nextSetBit(0); docNum >= 0; docNum = matchingDocuments.nextSetBit(docNum + 1)) {
542.147 - final Document doc = reader.document(docNum);
542.148 -
542.149 - found.add(doc.getField("path").stringValue());
542.150 - }
542.151 -
542.152 - result.put(hash, found);
542.153 - }
542.154 -
542.155 - return result;
542.156 - }
542.157 -
542.158 - return Collections.emptyMap();
542.159 - }
542.160 -
542.161 - private static BulkPattern preparePattern(String pattern, Collection<Diagnostic<? extends JavaFileObject>> errors) {
542.162 - return preparePattern(PatternConvertor.create(pattern), errors);
542.163 - }
542.164 -
542.165 - //XXX: copied from BatchSearch, may be possible to merge once CompilationInfo is accessible in server mode
542.166 - private static BulkPattern preparePattern(final Iterable<? extends HintDescription> patterns, Collection<Diagnostic<? extends JavaFileObject>> errors) {
542.167 - JavacTaskImpl javac = prepareJavacTaskImpl();
542.168 - Collection<String> code = new LinkedList<String>();
542.169 - Collection<Tree> trees = new LinkedList<Tree>();
542.170 - Collection<AdditionalQueryConstraints> additionalConstraints = new LinkedList<AdditionalQueryConstraints>();
542.171 -
542.172 - for (HintDescription pattern : patterns) {
542.173 - String textPattern = ((PatternDescription) pattern.getTrigger()).getPattern();
542.174 -
542.175 - code.add(textPattern);
542.176 - trees.add(Utilities.parseAndAttribute(javac, textPattern, errors));
542.177 - additionalConstraints.add(pattern.getAdditionalConstraints());
542.178 - }
542.179 -
542.180 - return BulkSearch.getDefault().create(code, trees, additionalConstraints);
542.181 - }
542.182 -
542.183 - private static JavacTaskImpl prepareJavacTaskImpl() {
542.184 - final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
542.185 - final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
542.186 -
542.187 - assert tool != null;
542.188 -
542.189 - JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, Arrays.asList("-bootclasspath", bootPath, "-Xjcov"), null, Collections.<JavaFileObject>emptyList());
542.190 -
542.191 - return ct;
542.192 - }
542.193 -
542.194 - private static final class JFOImpl extends SimpleJavaFileObject {
542.195 - private final CharSequence code;
542.196 - public JFOImpl(CharSequence code) {
542.197 - super(URI.create(""), Kind.SOURCE);
542.198 - this.code = code;
542.199 - }
542.200 - @Override
542.201 - public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
542.202 - return code;
542.203 - }
542.204 - }
542.205 -}
543.1 --- a/server/indexer/src/org/netbeans/modules/jackpot30/server/indexer/StandaloneIndexer.java Fri Jan 27 13:35:56 2012 +0100
543.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
543.3 @@ -1,169 +0,0 @@
543.4 -/*
543.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
543.6 - *
543.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
543.8 - *
543.9 - * The contents of this file are subject to the terms of either the GNU
543.10 - * General Public License Version 2 only ("GPL") or the Common
543.11 - * Development and Distribution License("CDDL") (collectively, the
543.12 - * "License"). You may not use this file except in compliance with the
543.13 - * License. You can obtain a copy of the License at
543.14 - * http://www.netbeans.org/cddl-gplv2.html
543.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
543.16 - * specific language governing permissions and limitations under the
543.17 - * License. When distributing the software, include this License Header
543.18 - * Notice in each file and include the License file at
543.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
543.20 - * particular file as subject to the "Classpath" exception as provided
543.21 - * by Sun in the GPL Version 2 section of the License file that
543.22 - * accompanied this code. If applicable, add the following below the
543.23 - * License Header, with the fields enclosed by brackets [] replaced by
543.24 - * your own identifying information:
543.25 - * "Portions Copyrighted [year] [name of copyright owner]"
543.26 - *
543.27 - * If you wish your version of this file to be governed by only the CDDL
543.28 - * or only the GPL Version 2, indicate your decision by adding
543.29 - * "[Contributor] elects to include this software in this distribution
543.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
543.31 - * single choice of license, a recipient has the option to distribute
543.32 - * your version of this file under either the CDDL, the GPL Version 2 or
543.33 - * to extend the choice of license to its licensees as provided above.
543.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
543.35 - * Version 2 license, then the option applies only if the new code is
543.36 - * made subject to such option by the copyright holder.
543.37 - *
543.38 - * Contributor(s):
543.39 - *
543.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
543.41 - */
543.42 -
543.43 -package org.netbeans.modules.jackpot30.server.indexer;
543.44 -
543.45 -import com.sun.source.tree.CompilationUnitTree;
543.46 -import com.sun.tools.javac.api.JavacTaskImpl;
543.47 -import java.io.BufferedReader;
543.48 -import java.io.File;
543.49 -import java.io.FileReader;
543.50 -import java.io.IOException;
543.51 -import java.util.Arrays;
543.52 -import java.util.Collection;
543.53 -import java.util.Collections;
543.54 -import java.util.LinkedList;
543.55 -import java.util.logging.Level;
543.56 -import java.util.logging.Logger;
543.57 -import javax.tools.Diagnostic;
543.58 -import javax.tools.DiagnosticListener;
543.59 -import javax.tools.JavaCompiler;
543.60 -import javax.tools.JavaFileObject;
543.61 -import javax.tools.StandardJavaFileManager;
543.62 -import javax.tools.StandardLocation;
543.63 -import javax.tools.ToolProvider;
543.64 -import org.netbeans.modules.jackpot30.impl.duplicates.indexing.DuplicatesIndex;
543.65 -import org.netbeans.modules.jackpot30.impl.indexing.FileBasedIndex;
543.66 -import org.netbeans.modules.jackpot30.impl.indexing.Index;
543.67 -import org.netbeans.modules.jackpot30.impl.indexing.Index.IndexWriter;
543.68 -import org.netbeans.modules.jackpot30.impl.indexing.IndexInfo;
543.69 -
543.70 -/**
543.71 - *
543.72 - * @author lahvac
543.73 - */
543.74 -public class StandaloneIndexer {
543.75 -
543.76 - public static void index(File root, boolean duplicatesIndex, boolean storeSources, String modified, String removed) throws IOException {
543.77 - Index index = FileBasedIndex.create(root.toURI().toURL(), storeSources);
543.78 - IndexInfo ii = index.getIndexInfo();
543.79 - boolean clearIndexing = ii.totalFiles < 0 || ii.majorVersion != FileBasedIndex.MAJOR_VERSION || ii.minorVersion != FileBasedIndex.MINOR_VERSION;
543.80 - IndexWriter w = index.openForWriting();
543.81 - DuplicatesIndex.IndexWriter dw = duplicatesIndex ? DuplicatesIndex.get(root.toURI().toURL()).openForWriting() : null;
543.82 -
543.83 - try {
543.84 - StandaloneIndexer i = new StandaloneIndexer();
543.85 -
543.86 - if (!clearIndexing && modified != null && removed != null) {
543.87 - i.doIndex(w, dw, root, modified, removed);
543.88 - } else {
543.89 - w.clear();
543.90 - i.doIndex(w, dw, root);
543.91 - }
543.92 - } finally {
543.93 - w.close();
543.94 - if (dw != null) {
543.95 - dw.close();
543.96 - }
543.97 - }
543.98 - }
543.99 -
543.100 - private void doIndex(IndexWriter w, DuplicatesIndex.IndexWriter dw, File fileOrDir) throws IOException {
543.101 - if (fileOrDir.isDirectory()) {
543.102 - for (File f : fileOrDir.listFiles()) {
543.103 - doIndex(w, dw, f);
543.104 - }
543.105 - } else {
543.106 - indexFile(w, dw, fileOrDir);
543.107 - }
543.108 - }
543.109 -
543.110 - private void doIndex(IndexWriter w, DuplicatesIndex.IndexWriter dw, File root, String modified, String removed) throws IOException {
543.111 - for (String r : read(removed)) {
543.112 - w.remove(r);
543.113 - if (dw != null) dw.remove(r);
543.114 - }
543.115 -
543.116 - for (String m : read(modified)) {
543.117 - indexFile(w, dw, new File(root, m));
543.118 - }
543.119 - }
543.120 -
543.121 - private void indexFile(IndexWriter w, DuplicatesIndex.IndexWriter dw, File source) throws IOException {
543.122 - if (!source.getName().endsWith(".java"))
543.123 - return ;
543.124 -
543.125 - final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
543.126 - final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
543.127 - assert tool != null;
543.128 -
543.129 - DiagnosticListener<JavaFileObject> devNull = new DiagnosticListener<JavaFileObject>() {
543.130 - public void report(Diagnostic<? extends JavaFileObject> diagnostic) {}
543.131 - };
543.132 - StandardJavaFileManager m = tool.getStandardFileManager(devNull, null, null);
543.133 -
543.134 - m.setLocation(StandardLocation.CLASS_PATH, Collections.<File>emptyList());
543.135 - m.setLocation(StandardLocation.SOURCE_PATH, Collections.<File>emptyList());
543.136 -
543.137 - Iterable<? extends JavaFileObject> fos = m.getJavaFileObjects(source);
543.138 - JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, null, devNull, Arrays.asList("-bootclasspath", bootPath), null, fos);
543.139 - CompilationUnitTree cut = ct.parse().iterator().next();
543.140 -
543.141 - w.record(source.toURI().toURL(), cut, null);
543.142 -
543.143 - if (dw != null) {
543.144 - ct.analyze(ct.enter(Collections.singletonList(cut)));
543.145 -
543.146 - dw.record(ct, source.toURI().toURL(), cut);
543.147 - }
543.148 - }
543.149 -
543.150 - private static Iterable<? extends String> read(String file) throws IOException {
543.151 - Collection<String> result = new LinkedList<String>();
543.152 - BufferedReader r = new BufferedReader(new FileReader(file));
543.153 -
543.154 - try {
543.155 - String line;
543.156 -
543.157 - while ((line = r.readLine()) != null) {
543.158 - if (!line.isEmpty()) {
543.159 - result.add(line);
543.160 - }
543.161 - }
543.162 - } finally {
543.163 - try {
543.164 - r.close();
543.165 - } catch (IOException ex) {
543.166 - Logger.getLogger(StandaloneIndexer.class.getName()).log(Level.SEVERE, null, ex);
543.167 - }
543.168 - }
543.169 -
543.170 - return result;
543.171 - }
543.172 -}
544.1 --- a/server/indexer/test/org/netbeans/modules/jackpot30/server/indexer/IndexTest.java Fri Jan 27 13:35:56 2012 +0100
544.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
544.3 @@ -1,96 +0,0 @@
544.4 -/*
544.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
544.6 - *
544.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
544.8 - *
544.9 - * The contents of this file are subject to the terms of either the GNU
544.10 - * General Public License Version 2 only ("GPL") or the Common
544.11 - * Development and Distribution License("CDDL") (collectively, the
544.12 - * "License"). You may not use this file except in compliance with the
544.13 - * License. You can obtain a copy of the License at
544.14 - * http://www.netbeans.org/cddl-gplv2.html
544.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
544.16 - * specific language governing permissions and limitations under the
544.17 - * License. When distributing the software, include this License Header
544.18 - * Notice in each file and include the License file at
544.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
544.20 - * particular file as subject to the "Classpath" exception as provided
544.21 - * by Sun in the GPL Version 2 section of the License file that
544.22 - * accompanied this code. If applicable, add the following below the
544.23 - * License Header, with the fields enclosed by brackets [] replaced by
544.24 - * your own identifying information:
544.25 - * "Portions Copyrighted [year] [name of copyright owner]"
544.26 - *
544.27 - * If you wish your version of this file to be governed by only the CDDL
544.28 - * or only the GPL Version 2, indicate your decision by adding
544.29 - * "[Contributor] elects to include this software in this distribution
544.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
544.31 - * single choice of license, a recipient has the option to distribute
544.32 - * your version of this file under either the CDDL, the GPL Version 2 or
544.33 - * to extend the choice of license to its licensees as provided above.
544.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
544.35 - * Version 2 license, then the option applies only if the new code is
544.36 - * made subject to such option by the copyright holder.
544.37 - *
544.38 - * Contributor(s):
544.39 - *
544.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
544.41 - */
544.42 -
544.43 -package org.netbeans.modules.jackpot30.server.indexer;
544.44 -
544.45 -import java.io.File;
544.46 -import java.io.IOException;
544.47 -import junit.framework.TestCase;
544.48 -
544.49 -/**
544.50 - *
544.51 - * @author lahvac
544.52 - */
544.53 -public class IndexTest extends TestCase {
544.54 -
544.55 - public IndexTest(String name) {
544.56 - super(name);
544.57 - }
544.58 -
544.59 - public void testCmdLine() throws IOException {
544.60 - assertCmdLineOk("/foo", false, false, null, null, "/foo", "/cache");
544.61 - assertCmdLineOk("/foo", false, false, "/modified.list", "/removed.list", "/foo", "/cache", "/modified.list", "/removed.list");
544.62 - assertCmdLineOk("/foo", true, false, null, null, Index.PARAM_CONSTRUCT_DUPLICATES_INDEX, "/foo", "/cache");
544.63 - assertCmdLineOk("/foo", true, false, "/modified.list", "/removed.list", Index.PARAM_CONSTRUCT_DUPLICATES_INDEX, "/foo", "/cache", "/modified.list", "/removed.list");
544.64 - assertCmdLineOk("/foo", false, true, null, null, Index.PARAM_STORE_SOURCES, "/foo", "/cache");
544.65 - assertCmdLineOk("/foo", false, true, "/modified.list", "/removed.list", Index.PARAM_STORE_SOURCES, "/foo", "/cache", "/modified.list", "/removed.list");
544.66 - assertCmdLineOk("/foo", true, true, null, null, Index.PARAM_CONSTRUCT_DUPLICATES_INDEX, Index.PARAM_STORE_SOURCES, "/foo", "/cache");
544.67 - assertCmdLineOk("/foo", true, true, "/modified.list", "/removed.list", Index.PARAM_CONSTRUCT_DUPLICATES_INDEX, Index.PARAM_STORE_SOURCES, "/foo", "/cache", "/modified.list", "/removed.list");
544.68 - assertCmdLineFailed();
544.69 - assertCmdLineFailed("/foo");
544.70 - }
544.71 -
544.72 - private static void assertCmdLineOk(final String rootGolden, final boolean duplicatesIndexGolden, final boolean storeSourcesGolden, final String modifiedGolden, final String removedGolden, String... cmdLine) throws IOException {
544.73 - new Index() {
544.74 - @Override
544.75 - protected void invokeIndexer(File root, boolean duplicatesIndex, boolean storeSources, String modified, String removed) throws IOException {
544.76 - assertEquals(rootGolden, root.getPath());
544.77 - assertEquals(duplicatesIndexGolden, duplicatesIndex);
544.78 - assertEquals(storeSourcesGolden, storeSources);
544.79 - assertEquals(modifiedGolden, modified);
544.80 - assertEquals(removedGolden, removed);
544.81 - }
544.82 - @Override
544.83 - protected void printHelp() {
544.84 - fail();
544.85 - }
544.86 - }.index(cmdLine);
544.87 - }
544.88 -
544.89 - private static void assertCmdLineFailed(String... cmdLine) throws IOException {
544.90 - new Index() {
544.91 - @Override
544.92 - protected void invokeIndexer(File root, boolean duplicatesIndex, boolean storeSources, String modified, String removed) throws IOException {
544.93 - fail();
544.94 - }
544.95 - @Override
544.96 - protected void printHelp() {}
544.97 - }.index(cmdLine);
544.98 - }
544.99 -}
544.100 \ No newline at end of file
545.1 --- a/server/indexer/test/org/netbeans/modules/jackpot30/server/indexer/LargeScaleTester.java Fri Jan 27 13:35:56 2012 +0100
545.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
545.3 @@ -1,147 +0,0 @@
545.4 -/*
545.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
545.6 - *
545.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
545.8 - *
545.9 - * The contents of this file are subject to the terms of either the GNU
545.10 - * General Public License Version 2 only ("GPL") or the Common
545.11 - * Development and Distribution License("CDDL") (collectively, the
545.12 - * "License"). You may not use this file except in compliance with the
545.13 - * License. You can obtain a copy of the License at
545.14 - * http://www.netbeans.org/cddl-gplv2.html
545.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
545.16 - * specific language governing permissions and limitations under the
545.17 - * License. When distributing the software, include this License Header
545.18 - * Notice in each file and include the License file at
545.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
545.20 - * particular file as subject to the "Classpath" exception as provided
545.21 - * by Sun in the GPL Version 2 section of the License file that
545.22 - * accompanied this code. If applicable, add the following below the
545.23 - * License Header, with the fields enclosed by brackets [] replaced by
545.24 - * your own identifying information:
545.25 - * "Portions Copyrighted [year] [name of copyright owner]"
545.26 - *
545.27 - * If you wish your version of this file to be governed by only the CDDL
545.28 - * or only the GPL Version 2, indicate your decision by adding
545.29 - * "[Contributor] elects to include this software in this distribution
545.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
545.31 - * single choice of license, a recipient has the option to distribute
545.32 - * your version of this file under either the CDDL, the GPL Version 2 or
545.33 - * to extend the choice of license to its licensees as provided above.
545.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
545.35 - * Version 2 license, then the option applies only if the new code is
545.36 - * made subject to such option by the copyright holder.
545.37 - *
545.38 - * Contributor(s):
545.39 - *
545.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
545.41 - */
545.42 -
545.43 -package org.netbeans.modules.jackpot30.server.indexer;
545.44 -
545.45 -import java.io.File;
545.46 -import java.io.IOException;
545.47 -import java.util.logging.Handler;
545.48 -import java.util.logging.Level;
545.49 -import java.util.logging.LogRecord;
545.50 -import java.util.logging.Logger;
545.51 -import java.util.logging.SimpleFormatter;
545.52 -import junit.framework.TestCase;
545.53 -import org.netbeans.modules.jackpot30.impl.indexing.Cache;
545.54 -import org.netbeans.modules.jackpot30.impl.indexing.FileBasedIndex;
545.55 -
545.56 -/**
545.57 - *
545.58 - * @author lahvac
545.59 - */
545.60 -public class LargeScaleTester extends TestCase {
545.61 -
545.62 - public LargeScaleTester(String name) {
545.63 - super(name);
545.64 - }
545.65 -
545.66 - private static final boolean createIndex = true;
545.67 -
545.68 - private File src;
545.69 -
545.70 - public void setUp() throws Exception {
545.71 - Logger.getLogger(FileBasedIndex.class.getName()).setLevel(Level.ALL);
545.72 - Logger.getLogger(FileBasedIndex.class.getName()).addHandler(new Handler() {
545.73 - @Override
545.74 - public void publish(LogRecord record) {
545.75 - System.err.println(new SimpleFormatter().formatMessage(record));
545.76 - }
545.77 - @Override
545.78 - public void flush() {
545.79 - System.err.flush();
545.80 - }
545.81 - @Override
545.82 - public void close() throws SecurityException {}
545.83 - });
545.84 -
545.85 - File source = new File(LargeScaleTester.class.getProtectionDomain().getCodeSource().getLocation().getPath());
545.86 - File workingDirectory = new File(new File(source.getParentFile(), "wd"), this.getName());
545.87 -
545.88 - if (createIndex)
545.89 - deleteRecursively(workingDirectory);
545.90 -
545.91 - File cache = new File(workingDirectory, "cache");
545.92 - String toIndex = System.getProperty("index-folder");
545.93 -
545.94 - if (toIndex == null || !(src = new File(toIndex)).isDirectory()) {
545.95 - throw new IllegalStateException("Directory to index not correctly specified - add 'test-sys-prop.index-folder=<directory>' to private.properties");
545.96 - }
545.97 -
545.98 - Cache.setStandaloneCacheRoot(cache);
545.99 -
545.100 - if (createIndex) {
545.101 - long start = System.currentTimeMillis();
545.102 - StandaloneIndexer.index(src, false, false, null, null);
545.103 - long end = System.currentTimeMillis();
545.104 - System.err.println("indexing took: " + (end - start));
545.105 - System.err.println("cache size total: " + totalSize(cache) + ", lucene=" + totalSize(new File(cache, "s1/jackpot30/fulltext")));
545.106 - }
545.107 - }
545.108 -
545.109 - private static void deleteRecursively(File d) throws IOException {
545.110 - if (!d.exists()) return;
545.111 -
545.112 - if (d.isDirectory()) {
545.113 - for (File c : d.listFiles()) {
545.114 - deleteRecursively(c);
545.115 - }
545.116 - }
545.117 -
545.118 - if (!d.delete()) throw new IOException();
545.119 - }
545.120 -
545.121 - private static long totalSize(File d) throws IOException {
545.122 - if (!d.exists()) return 0;
545.123 -
545.124 - if (d.isDirectory()) {
545.125 - long total = 0;
545.126 -
545.127 - for (File c : d.listFiles()) {
545.128 - total += totalSize(c);
545.129 - }
545.130 -
545.131 - return total;
545.132 - } else {
545.133 - return d.length();
545.134 - }
545.135 - }
545.136 -
545.137 - public void testFind() throws Exception {
545.138 - performTest("new $type() { $mods$ $resultType $methodName($args$) { $statements$; } }");
545.139 - performTest("$1.isDirectory()");
545.140 - }
545.141 -
545.142 - private void performTest(String code) throws Exception {
545.143 - System.err.println("searching for " + code);
545.144 - long start = System.currentTimeMillis();
545.145 - System.err.println("Found occurrences: " + StandaloneFinder.findCandidates(src, code).size());
545.146 - long end = System.currentTimeMillis();
545.147 -
545.148 - System.err.println("total search time: " + (end - start));
545.149 - }
545.150 -}
546.1 --- a/server/indexer/test/org/netbeans/modules/jackpot30/server/indexer/StandaloneFinderTest.java Fri Jan 27 13:35:56 2012 +0100
546.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
546.3 @@ -1,154 +0,0 @@
546.4 -/*
546.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
546.6 - *
546.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
546.8 - *
546.9 - * The contents of this file are subject to the terms of either the GNU
546.10 - * General Public License Version 2 only ("GPL") or the Common
546.11 - * Development and Distribution License("CDDL") (collectively, the
546.12 - * "License"). You may not use this file except in compliance with the
546.13 - * License. You can obtain a copy of the License at
546.14 - * http://www.netbeans.org/cddl-gplv2.html
546.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
546.16 - * specific language governing permissions and limitations under the
546.17 - * License. When distributing the software, include this License Header
546.18 - * Notice in each file and include the License file at
546.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
546.20 - * particular file as subject to the "Classpath" exception as provided
546.21 - * by Sun in the GPL Version 2 section of the License file that
546.22 - * accompanied this code. If applicable, add the following below the
546.23 - * License Header, with the fields enclosed by brackets [] replaced by
546.24 - * your own identifying information:
546.25 - * "Portions Copyrighted [year] [name of copyright owner]"
546.26 - *
546.27 - * If you wish your version of this file to be governed by only the CDDL
546.28 - * or only the GPL Version 2, indicate your decision by adding
546.29 - * "[Contributor] elects to include this software in this distribution
546.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
546.31 - * single choice of license, a recipient has the option to distribute
546.32 - * your version of this file under either the CDDL, the GPL Version 2 or
546.33 - * to extend the choice of license to its licensees as provided above.
546.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
546.35 - * Version 2 license, then the option applies only if the new code is
546.36 - * made subject to such option by the copyright holder.
546.37 - *
546.38 - * Contributor(s):
546.39 - *
546.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
546.41 - */
546.42 -
546.43 -package org.netbeans.modules.jackpot30.server.indexer;
546.44 -
546.45 -import java.io.ByteArrayInputStream;
546.46 -import java.io.File;
546.47 -import java.io.FileOutputStream;
546.48 -import java.io.IOException;
546.49 -import java.io.InputStream;
546.50 -import java.util.ArrayList;
546.51 -import java.util.Arrays;
546.52 -import java.util.HashSet;
546.53 -import java.util.LinkedList;
546.54 -import java.util.List;
546.55 -import junit.framework.Assert;
546.56 -import junit.framework.TestCase;
546.57 -import org.netbeans.modules.jackpot30.impl.indexing.Cache;
546.58 -
546.59 -/**
546.60 - *
546.61 - * @author lahvac
546.62 - */
546.63 -public class StandaloneFinderTest extends TestCase {
546.64 -
546.65 - public StandaloneFinderTest(String name) {
546.66 - super(name);
546.67 - }
546.68 -
546.69 - private File src;
546.70 -
546.71 - public void setUp() throws Exception {
546.72 - File source = new File(StandaloneFinderTest.class.getProtectionDomain().getCodeSource().getLocation().getPath());
546.73 - File workingDirectory = new File(new File(source.getParentFile(), "wd"), this.getName());
546.74 -
546.75 - deleteRecursively(workingDirectory);
546.76 -
546.77 - File cache = new File(workingDirectory, "cache");
546.78 -
546.79 - src = new File(workingDirectory, "src");
546.80 -
546.81 - Cache.setStandaloneCacheRoot(cache);
546.82 -
546.83 - copyStringToFile(new File(src, "test/Test1.java"), "package test; public class Test {private void test() { new java.io.File(\"\").isDirectory(); } }");
546.84 - copyStringToFile(new File(src, "test/TestLambda.java"), "package test; public class Test1 { private void test() { Runnable r = new Runnable() { public void run() { System.err.println(); } }; } }");
546.85 -
546.86 - StandaloneIndexer.index(src, false, false, null, null);
546.87 - }
546.88 -
546.89 - public final static void copyStringToFile (File f, String content) throws Exception {
546.90 - f.getParentFile().mkdirs();
546.91 -
546.92 - FileOutputStream os = new FileOutputStream(f);
546.93 - InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
546.94 - int read;
546.95 - while ((read = is.read()) != (-1)) {
546.96 - os.write(read);
546.97 - }
546.98 - os.close ();
546.99 - is.close();
546.100 - }
546.101 -
546.102 - private static List<Integer> toIntegerList(int[] arr) {
546.103 - List<Integer> res = new ArrayList<Integer>(arr.length);
546.104 -
546.105 - for (int e : arr) {
546.106 - res.add(e);
546.107 - }
546.108 -
546.109 - return res;
546.110 - }
546.111 -
546.112 - private static void deleteRecursively(File d) throws IOException {
546.113 - if (!d.exists()) return;
546.114 -
546.115 - if (d.isDirectory()) {
546.116 - for (File c : d.listFiles()) {
546.117 - deleteRecursively(c);
546.118 - }
546.119 - }
546.120 -
546.121 - if (!d.delete()) throw new IOException();
546.122 - }
546.123 -
546.124 - public void testFindSpans() throws Exception {
546.125 - Assert.assertEquals(Arrays.asList(55, 89), toIntegerList(StandaloneFinder.findCandidateOccurrenceSpans(src, "test/Test1.java", "$1.isDirectory()")));
546.126 - }
546.127 -
546.128 - public void testMultiplePatterns() throws Exception {
546.129 - String patterns = "$1.isDirectory();; new java.io.File($1);;";
546.130 - Assert.assertEquals(Arrays.asList("test/Test1.java"), new LinkedList<String>(StandaloneFinder.findCandidates(src, patterns)));
546.131 - Assert.assertEquals(Arrays.asList(55, 75, 55, 89), toIntegerList(StandaloneFinder.findCandidateOccurrenceSpans(src, "test/Test1.java", patterns)));
546.132 - }
546.133 -
546.134 - public void testUpdate() throws Exception {
546.135 - File modified = new File(src.getParentFile(), "modified");
546.136 - File removed = new File(src.getParentFile(), "removed");
546.137 -
546.138 - copyStringToFile(removed, "test/Test1.java");
546.139 - copyStringToFile(modified, "test/Test2.java\ntest/Test3.java");
546.140 -
546.141 - new File(src, "test/Test1.java").delete();
546.142 -
546.143 - copyStringToFile(new File(src, "test/Test2.java"), "package test; public class Test {private void test() { new java.io.File(\"\").isDirectory(); } }");
546.144 - copyStringToFile(new File(src, "test/Test3.java"), "package test; public class Test {private void test() { new java.io.File(\"\").isDirectory(); } }");
546.145 -
546.146 - StandaloneIndexer.index(src, false, false, modified.getAbsolutePath(), removed.getAbsolutePath());
546.147 -
546.148 - String patterns = "$1.isDirectory();; new java.io.File($1);;";
546.149 - Assert.assertEquals(new HashSet<String>(Arrays.asList("test/Test2.java", "test/Test3.java")), new HashSet<String>(StandaloneFinder.findCandidates(src, patterns)));
546.150 - }
546.151 -
546.152 - public void testLambdaPattern() throws Exception {
546.153 - String patterns = "new $type() {\n $mods$ $resultType $methodName($args$) {\n $statements$;\n }\n }\n";
546.154 - Assert.assertEquals(Arrays.asList("test/TestLambda.java"), new LinkedList<String>(StandaloneFinder.findCandidates(src, patterns)));
546.155 - Assert.assertEquals(Arrays.asList(70, 132), toIntegerList(StandaloneFinder.findCandidateOccurrenceSpans(src, "test/TestLambda.java", patterns)));
546.156 - }
546.157 -}
547.1 --- a/server/lib/nblibraries.properties Fri Jan 27 13:35:56 2012 +0100
547.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
547.3 @@ -1,50 +0,0 @@
547.4 -libs.jopt-simple.classpath=\
547.5 - ${base}/jopt-simple/jopt-simple-3.2.jar
547.6 -libs.jopt-simple.javadoc=\
547.7 - ${base}/jopt-simple/jopt-simple-3.2-javadoc.jar!//
547.8 -libs.jopt-simple.src=\
547.9 - ${base}/jopt-simple/jopt-simple-3.2-sources.jar
547.10 -libs.junit.classpath=\
547.11 - ${base}/junit/junit-3.8.2.jar
547.12 -libs.junit.javadoc=\
547.13 - ${base}/junit/junit-3.8.2-api.zip
547.14 -libs.junit_4.classpath=\
547.15 - ${base}/junit_4/junit-4.5.jar
547.16 -libs.junit_4.javadoc=\
547.17 - ${base}/junit_4/junit-4.5-api.zip
547.18 -libs.junit_4.src=\
547.19 - ${base}/junit_4/junit-4.5-src.jar
547.20 -libs.CopyLibs.classpath=\
547.21 - ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar
547.22 -libs.jersey.classpath=\
547.23 - ${base}/jersey-1.1/grizzly-servlet-webserver-1.8.6.3.jar:\
547.24 - ${base}/jersey-1.1/jersey-client-1.0.1.jar:\
547.25 - ${base}/jersey-1.1/jersey-core-1.0.1.jar:\
547.26 - ${base}/jersey-1.1/jersey-server-1.0.1.jar:\
547.27 - ${base}/jersey-1.1/asm-all-3.1.jar:\
547.28 - ${base}/jersey-1.1/jsr311-api-1.0.jar
547.29 -libs.jersey.src=\
547.30 - ${base}/jersey-1.1/jersey-client-1.0.1-sources.jar:\
547.31 - ${base}/jersey-1.1/jersey-core-1.0.1-sources.jar:\
547.32 - ${base}/jersey-1.1/jersey-server-1.0.1-sources.jar:\
547.33 - ${base}/jersey-1.1/asm-all-3.1-sources.jar:\
547.34 - ${base}/jersey-1.1/jsr311-api-1.0-sources.jar
547.35 -libs.lucene.classpath=\
547.36 - ${base}/lucene-3.5.0/lucene-core-3.5.0.jar
547.37 -libs.jersey.javadoc=\
547.38 - ${base}/jersey-1.1/jersey-client-1.0.1-javadoc.jar!//:\
547.39 - ${base}/jersey-1.1/jersey-core-1.0.1-javadoc.jar!//:\
547.40 - ${base}/jersey-1.1/jersey-server-1.0.1-javadoc.jar!//:\
547.41 - ${base}/jersey-1.1/jsr311-api-1.0-javadoc.jar!//
547.42 -libs.lucene.javadoc=\
547.43 - ${base}/lucene-3.5.0/lucene-core-3.5.0-javadoc.jar!//
547.44 -libs.lucene.src=\
547.45 - ${base}/lucene-3.5.0/lucene-core-3.5.0-sources.jar
547.46 -libs.javac.classpath=\
547.47 - ${base}/javac/javac-api-nb-7.0-b07.jar:\
547.48 - ${base}/javac/javac-impl-nb-7.0-b07.jar
547.49 -libs.freemarker.classpath=\
547.50 - ${base}/freemarker/freemarker-2.3.16.jar
547.51 -libs.freemarker.src=\
547.52 - ${base}/freemarker/freemarker-src.zip
547.53 -
548.1 --- a/server/web.api/build.xml Fri Jan 27 13:35:56 2012 +0100
548.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
548.3 @@ -1,75 +0,0 @@
548.4 -<?xml version="1.0" encoding="UTF-8"?>
548.5 -<!-- You may freely edit this file. See commented blocks below for -->
548.6 -<!-- some examples of how to customize the build. -->
548.7 -<!-- (If you delete it and reopen the project it will be recreated.) -->
548.8 -<!-- By default, only the Clean and Build commands use this build script. -->
548.9 -<!-- Commands such as Run, Debug, and Test only use this build script if -->
548.10 -<!-- the Compile on Save feature is turned off for the project. -->
548.11 -<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
548.12 -<!-- in the project's Project Properties dialog box.-->
548.13 -<project name="web.api" default="default" basedir=".">
548.14 - <description>Builds, tests, and runs the project web.api.</description>
548.15 - <import file="../download.xml"/>
548.16 - <import file="nbproject/build-impl.xml"/>
548.17 - <!--
548.18 -
548.19 - There exist several targets which are by default empty and which can be
548.20 - used for execution of your tasks. These targets are usually executed
548.21 - before and after some main targets. They are:
548.22 -
548.23 - -pre-init: called before initialization of project properties
548.24 - -post-init: called after initialization of project properties
548.25 - -pre-compile: called before javac compilation
548.26 - -post-compile: called after javac compilation
548.27 - -pre-compile-single: called before javac compilation of single file
548.28 - -post-compile-single: called after javac compilation of single file
548.29 - -pre-compile-test: called before javac compilation of JUnit tests
548.30 - -post-compile-test: called after javac compilation of JUnit tests
548.31 - -pre-compile-test-single: called before javac compilation of single JUnit test
548.32 - -post-compile-test-single: called after javac compilation of single JUunit test
548.33 - -pre-jar: called before JAR building
548.34 - -post-jar: called after JAR building
548.35 - -post-clean: called after cleaning build products
548.36 -
548.37 - (Targets beginning with '-' are not intended to be called on their own.)
548.38 -
548.39 - Example of inserting an obfuscator after compilation could look like this:
548.40 -
548.41 - <target name="-post-compile">
548.42 - <obfuscate>
548.43 - <fileset dir="${build.classes.dir}"/>
548.44 - </obfuscate>
548.45 - </target>
548.46 -
548.47 - For list of available properties check the imported
548.48 - nbproject/build-impl.xml file.
548.49 -
548.50 -
548.51 - Another way to customize the build is by overriding existing main targets.
548.52 - The targets of interest are:
548.53 -
548.54 - -init-macrodef-javac: defines macro for javac compilation
548.55 - -init-macrodef-junit: defines macro for junit execution
548.56 - -init-macrodef-debug: defines macro for class debugging
548.57 - -init-macrodef-java: defines macro for class execution
548.58 - -do-jar-with-manifest: JAR building (if you are using a manifest)
548.59 - -do-jar-without-manifest: JAR building (if you are not using a manifest)
548.60 - run: execution of project
548.61 - -javadoc-build: Javadoc generation
548.62 - test-report: JUnit report generation
548.63 -
548.64 - An example of overriding the target for project execution could look like this:
548.65 -
548.66 - <target name="run" depends="web.api-impl.jar">
548.67 - <exec dir="bin" executable="launcher.exe">
548.68 - <arg file="${dist.jar}"/>
548.69 - </exec>
548.70 - </target>
548.71 -
548.72 - Notice that the overridden target depends on the jar target and not only on
548.73 - the compile target as the regular run target does. Again, for a list of available
548.74 - properties which you can use, check the target you are overriding in the
548.75 - nbproject/build-impl.xml file.
548.76 -
548.77 - -->
548.78 -</project>
549.1 --- a/server/web.api/manifest.mf Fri Jan 27 13:35:56 2012 +0100
549.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
549.3 @@ -1,3 +0,0 @@
549.4 -Manifest-Version: 1.0
549.5 -X-COMMENT: Main-Class will be added automatically by build
549.6 -
550.1 --- a/server/web.api/nbproject/build-impl.xml Fri Jan 27 13:35:56 2012 +0100
550.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
550.3 @@ -1,966 +0,0 @@
550.4 -<?xml version="1.0" encoding="UTF-8"?>
550.5 -<!--
550.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
550.7 -*** EDIT ../build.xml INSTEAD ***
550.8 -
550.9 -For the purpose of easier reading the script
550.10 -is divided into following sections:
550.11 -
550.12 - - initialization
550.13 - - compilation
550.14 - - jar
550.15 - - execution
550.16 - - debugging
550.17 - - javadoc
550.18 - - junit compilation
550.19 - - junit execution
550.20 - - junit debugging
550.21 - - applet
550.22 - - cleanup
550.23 -
550.24 - -->
550.25 -<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="web.api-impl">
550.26 - <fail message="Please build using Ant 1.7.1 or higher.">
550.27 - <condition>
550.28 - <not>
550.29 - <antversion atleast="1.7.1"/>
550.30 - </not>
550.31 - </condition>
550.32 - </fail>
550.33 - <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
550.34 - <!--
550.35 - ======================
550.36 - INITIALIZATION SECTION
550.37 - ======================
550.38 - -->
550.39 - <target name="-pre-init">
550.40 - <!-- Empty placeholder for easier customization. -->
550.41 - <!-- You can override this target in the ../build.xml file. -->
550.42 - </target>
550.43 - <target depends="-pre-init" name="-init-private">
550.44 - <property file="nbproject/private/config.properties"/>
550.45 - <property file="nbproject/private/configs/${config}.properties"/>
550.46 - <property file="nbproject/private/private.properties"/>
550.47 - </target>
550.48 - <target name="-pre-init-libraries">
550.49 - <property location="../lib/nblibraries.properties" name="libraries.path"/>
550.50 - <dirname file="${libraries.path}" property="libraries.dir.nativedirsep"/>
550.51 - <pathconvert dirsep="/" property="libraries.dir">
550.52 - <path path="${libraries.dir.nativedirsep}"/>
550.53 - </pathconvert>
550.54 - <basename file="${libraries.path}" property="libraries.basename" suffix=".properties"/>
550.55 - <available file="${libraries.dir}/${libraries.basename}-private.properties" property="private.properties.available"/>
550.56 - </target>
550.57 - <target depends="-pre-init-libraries" if="private.properties.available" name="-init-private-libraries">
550.58 - <loadproperties encoding="ISO-8859-1" srcfile="${libraries.dir}/${libraries.basename}-private.properties">
550.59 - <filterchain>
550.60 - <replacestring from="$${base}" to="${libraries.dir}"/>
550.61 - <escapeunicode/>
550.62 - </filterchain>
550.63 - </loadproperties>
550.64 - </target>
550.65 - <target depends="-pre-init,-init-private,-init-private-libraries" name="-init-libraries">
550.66 - <loadproperties encoding="ISO-8859-1" srcfile="${libraries.path}">
550.67 - <filterchain>
550.68 - <replacestring from="$${base}" to="${libraries.dir}"/>
550.69 - <escapeunicode/>
550.70 - </filterchain>
550.71 - </loadproperties>
550.72 - </target>
550.73 - <target depends="-pre-init,-init-private,-init-libraries" name="-init-user">
550.74 - <property file="${user.properties.file}"/>
550.75 - <!-- The two properties below are usually overridden -->
550.76 - <!-- by the active platform. Just a fallback. -->
550.77 - <property name="default.javac.source" value="1.4"/>
550.78 - <property name="default.javac.target" value="1.4"/>
550.79 - </target>
550.80 - <target depends="-pre-init,-init-private,-init-libraries,-init-user" name="-init-project">
550.81 - <property file="nbproject/configs/${config}.properties"/>
550.82 - <property file="nbproject/project.properties"/>
550.83 - </target>
550.84 - <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-init-macrodef-property" name="-do-init">
550.85 - <available file="${manifest.file}" property="manifest.available"/>
550.86 - <available file="${application.splash}" property="splashscreen.available"/>
550.87 - <condition property="main.class.available">
550.88 - <and>
550.89 - <isset property="main.class"/>
550.90 - <not>
550.91 - <equals arg1="${main.class}" arg2="" trim="true"/>
550.92 - </not>
550.93 - </and>
550.94 - </condition>
550.95 - <condition property="manifest.available+main.class">
550.96 - <and>
550.97 - <isset property="manifest.available"/>
550.98 - <isset property="main.class.available"/>
550.99 - </and>
550.100 - </condition>
550.101 - <condition property="do.mkdist">
550.102 - <and>
550.103 - <isset property="libs.CopyLibs.classpath"/>
550.104 - <not>
550.105 - <istrue value="${mkdist.disabled}"/>
550.106 - </not>
550.107 - </and>
550.108 - </condition>
550.109 - <condition property="manifest.available+main.class+mkdist.available">
550.110 - <and>
550.111 - <istrue value="${manifest.available+main.class}"/>
550.112 - <isset property="do.mkdist"/>
550.113 - </and>
550.114 - </condition>
550.115 - <condition property="manifest.available+main.class+mkdist.available+splashscreen.available">
550.116 - <and>
550.117 - <istrue value="${manifest.available+main.class+mkdist.available}"/>
550.118 - <istrue value="${splashscreen.available}"/>
550.119 - </and>
550.120 - </condition>
550.121 - <condition property="manifest.available+main.class+mkdist.available+splashscreen.available">
550.122 - <and>
550.123 - <istrue value="${manifest.available+main.class+mkdist.available}"/>
550.124 - <istrue value="${splashscreen.available}"/>
550.125 - </and>
550.126 - </condition>
550.127 - <condition property="manifest.available+mkdist.available">
550.128 - <and>
550.129 - <istrue value="${manifest.available}"/>
550.130 - <isset property="do.mkdist"/>
550.131 - </and>
550.132 - </condition>
550.133 - <condition property="manifest.available-mkdist.available">
550.134 - <or>
550.135 - <istrue value="${manifest.available}"/>
550.136 - <isset property="do.mkdist"/>
550.137 - </or>
550.138 - </condition>
550.139 - <condition property="manifest.available+main.class-mkdist.available">
550.140 - <or>
550.141 - <istrue value="${manifest.available+main.class}"/>
550.142 - <isset property="do.mkdist"/>
550.143 - </or>
550.144 - </condition>
550.145 - <condition property="have.tests">
550.146 - <or>
550.147 - <available file="${test.src.dir}"/>
550.148 - </or>
550.149 - </condition>
550.150 - <condition property="have.sources">
550.151 - <or>
550.152 - <available file="${src.dir}"/>
550.153 - </or>
550.154 - </condition>
550.155 - <condition property="netbeans.home+have.tests">
550.156 - <and>
550.157 - <isset property="netbeans.home"/>
550.158 - <isset property="have.tests"/>
550.159 - </and>
550.160 - </condition>
550.161 - <condition property="no.javadoc.preview">
550.162 - <and>
550.163 - <isset property="javadoc.preview"/>
550.164 - <isfalse value="${javadoc.preview}"/>
550.165 - </and>
550.166 - </condition>
550.167 - <property name="run.jvmargs" value=""/>
550.168 - <property name="javac.compilerargs" value=""/>
550.169 - <property name="work.dir" value="${basedir}"/>
550.170 - <condition property="no.deps">
550.171 - <and>
550.172 - <istrue value="${no.dependencies}"/>
550.173 - </and>
550.174 - </condition>
550.175 - <property name="javac.debug" value="true"/>
550.176 - <property name="javadoc.preview" value="true"/>
550.177 - <property name="application.args" value=""/>
550.178 - <property name="source.encoding" value="${file.encoding}"/>
550.179 - <property name="runtime.encoding" value="${source.encoding}"/>
550.180 - <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
550.181 - <and>
550.182 - <isset property="javadoc.encoding"/>
550.183 - <not>
550.184 - <equals arg1="${javadoc.encoding}" arg2=""/>
550.185 - </not>
550.186 - </and>
550.187 - </condition>
550.188 - <property name="javadoc.encoding.used" value="${source.encoding}"/>
550.189 - <property name="includes" value="**"/>
550.190 - <property name="excludes" value=""/>
550.191 - <property name="do.depend" value="false"/>
550.192 - <condition property="do.depend.true">
550.193 - <istrue value="${do.depend}"/>
550.194 - </condition>
550.195 - <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
550.196 - <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
550.197 - <length length="0" string="${endorsed.classpath}" when="greater"/>
550.198 - </condition>
550.199 - <property name="javac.fork" value="false"/>
550.200 - </target>
550.201 - <target name="-post-init">
550.202 - <!-- Empty placeholder for easier customization. -->
550.203 - <!-- You can override this target in the ../build.xml file. -->
550.204 - </target>
550.205 - <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init" name="-init-check">
550.206 - <fail unless="src.dir">Must set src.dir</fail>
550.207 - <fail unless="test.src.dir">Must set test.src.dir</fail>
550.208 - <fail unless="build.dir">Must set build.dir</fail>
550.209 - <fail unless="dist.dir">Must set dist.dir</fail>
550.210 - <fail unless="build.classes.dir">Must set build.classes.dir</fail>
550.211 - <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
550.212 - <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
550.213 - <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
550.214 - <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
550.215 - <fail unless="dist.jar">Must set dist.jar</fail>
550.216 - </target>
550.217 - <target name="-init-macrodef-property">
550.218 - <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
550.219 - <attribute name="name"/>
550.220 - <attribute name="value"/>
550.221 - <sequential>
550.222 - <property name="@{name}" value="${@{value}}"/>
550.223 - </sequential>
550.224 - </macrodef>
550.225 - </target>
550.226 - <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors">
550.227 - <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
550.228 - <attribute default="${src.dir}" name="srcdir"/>
550.229 - <attribute default="${build.classes.dir}" name="destdir"/>
550.230 - <attribute default="${javac.classpath}" name="classpath"/>
550.231 - <attribute default="${javac.processorpath}" name="processorpath"/>
550.232 - <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
550.233 - <attribute default="${includes}" name="includes"/>
550.234 - <attribute default="${excludes}" name="excludes"/>
550.235 - <attribute default="${javac.debug}" name="debug"/>
550.236 - <attribute default="${empty.dir}" name="sourcepath"/>
550.237 - <attribute default="${empty.dir}" name="gensrcdir"/>
550.238 - <element name="customize" optional="true"/>
550.239 - <sequential>
550.240 - <property location="${build.dir}/empty" name="empty.dir"/>
550.241 - <mkdir dir="${empty.dir}"/>
550.242 - <mkdir dir="@{apgeneratedsrcdir}"/>
550.243 - <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
550.244 - <src>
550.245 - <dirset dir="@{gensrcdir}" erroronmissingdir="false">
550.246 - <include name="*"/>
550.247 - </dirset>
550.248 - </src>
550.249 - <classpath>
550.250 - <path path="@{classpath}"/>
550.251 - </classpath>
550.252 - <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
550.253 - <compilerarg line="${javac.compilerargs}"/>
550.254 - <compilerarg value="-processorpath"/>
550.255 - <compilerarg path="@{processorpath}"/>
550.256 - <compilerarg line="${ap.processors.internal}"/>
550.257 - <compilerarg value="-s"/>
550.258 - <compilerarg path="@{apgeneratedsrcdir}"/>
550.259 - <compilerarg line="${ap.proc.none.internal}"/>
550.260 - <customize/>
550.261 - </javac>
550.262 - </sequential>
550.263 - </macrodef>
550.264 - </target>
550.265 - <target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal">
550.266 - <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
550.267 - <attribute default="${src.dir}" name="srcdir"/>
550.268 - <attribute default="${build.classes.dir}" name="destdir"/>
550.269 - <attribute default="${javac.classpath}" name="classpath"/>
550.270 - <attribute default="${javac.processorpath}" name="processorpath"/>
550.271 - <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
550.272 - <attribute default="${includes}" name="includes"/>
550.273 - <attribute default="${excludes}" name="excludes"/>
550.274 - <attribute default="${javac.debug}" name="debug"/>
550.275 - <attribute default="${empty.dir}" name="sourcepath"/>
550.276 - <attribute default="${empty.dir}" name="gensrcdir"/>
550.277 - <element name="customize" optional="true"/>
550.278 - <sequential>
550.279 - <property location="${build.dir}/empty" name="empty.dir"/>
550.280 - <mkdir dir="${empty.dir}"/>
550.281 - <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
550.282 - <src>
550.283 - <dirset dir="@{gensrcdir}" erroronmissingdir="false">
550.284 - <include name="*"/>
550.285 - </dirset>
550.286 - </src>
550.287 - <classpath>
550.288 - <path path="@{classpath}"/>
550.289 - </classpath>
550.290 - <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
550.291 - <compilerarg line="${javac.compilerargs}"/>
550.292 - <customize/>
550.293 - </javac>
550.294 - </sequential>
550.295 - </macrodef>
550.296 - </target>
550.297 - <target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac">
550.298 - <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
550.299 - <attribute default="${src.dir}" name="srcdir"/>
550.300 - <attribute default="${build.classes.dir}" name="destdir"/>
550.301 - <attribute default="${javac.classpath}" name="classpath"/>
550.302 - <sequential>
550.303 - <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
550.304 - <classpath>
550.305 - <path path="@{classpath}"/>
550.306 - </classpath>
550.307 - </depend>
550.308 - </sequential>
550.309 - </macrodef>
550.310 - <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
550.311 - <attribute default="${build.classes.dir}" name="destdir"/>
550.312 - <sequential>
550.313 - <fail unless="javac.includes">Must set javac.includes</fail>
550.314 - <pathconvert pathsep="," property="javac.includes.binary">
550.315 - <path>
550.316 - <filelist dir="@{destdir}" files="${javac.includes}"/>
550.317 - </path>
550.318 - <globmapper from="*.java" to="*.class"/>
550.319 - </pathconvert>
550.320 - <delete>
550.321 - <files includes="${javac.includes.binary}"/>
550.322 - </delete>
550.323 - </sequential>
550.324 - </macrodef>
550.325 - </target>
550.326 - <target name="-init-macrodef-junit">
550.327 - <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
550.328 - <attribute default="${includes}" name="includes"/>
550.329 - <attribute default="${excludes}" name="excludes"/>
550.330 - <attribute default="**" name="testincludes"/>
550.331 - <sequential>
550.332 - <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}">
550.333 - <batchtest todir="${build.test.results.dir}">
550.334 - <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
550.335 - <filename name="@{testincludes}"/>
550.336 - </fileset>
550.337 - </batchtest>
550.338 - <classpath>
550.339 - <path path="${run.test.classpath}"/>
550.340 - </classpath>
550.341 - <syspropertyset>
550.342 - <propertyref prefix="test-sys-prop."/>
550.343 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
550.344 - </syspropertyset>
550.345 - <formatter type="brief" usefile="false"/>
550.346 - <formatter type="xml"/>
550.347 - <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
550.348 - <jvmarg line="${run.jvmargs}"/>
550.349 - </junit>
550.350 - </sequential>
550.351 - </macrodef>
550.352 - </target>
550.353 - <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
550.354 - <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
550.355 - <attribute default="${main.class}" name="name"/>
550.356 - <attribute default="${debug.classpath}" name="classpath"/>
550.357 - <attribute default="" name="stopclassname"/>
550.358 - <sequential>
550.359 - <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
550.360 - <classpath>
550.361 - <path path="@{classpath}"/>
550.362 - </classpath>
550.363 - </nbjpdastart>
550.364 - </sequential>
550.365 - </macrodef>
550.366 - <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
550.367 - <attribute default="${build.classes.dir}" name="dir"/>
550.368 - <sequential>
550.369 - <nbjpdareload>
550.370 - <fileset dir="@{dir}" includes="${fix.classes}">
550.371 - <include name="${fix.includes}*.class"/>
550.372 - </fileset>
550.373 - </nbjpdareload>
550.374 - </sequential>
550.375 - </macrodef>
550.376 - </target>
550.377 - <target name="-init-debug-args">
550.378 - <property name="version-output" value="java version "${ant.java.version}"/>
550.379 - <condition property="have-jdk-older-than-1.4">
550.380 - <or>
550.381 - <contains string="${version-output}" substring="java version "1.0"/>
550.382 - <contains string="${version-output}" substring="java version "1.1"/>
550.383 - <contains string="${version-output}" substring="java version "1.2"/>
550.384 - <contains string="${version-output}" substring="java version "1.3"/>
550.385 - </or>
550.386 - </condition>
550.387 - <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
550.388 - <istrue value="${have-jdk-older-than-1.4}"/>
550.389 - </condition>
550.390 - <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
550.391 - <os family="windows"/>
550.392 - </condition>
550.393 - <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
550.394 - <isset property="debug.transport"/>
550.395 - </condition>
550.396 - </target>
550.397 - <target depends="-init-debug-args" name="-init-macrodef-debug">
550.398 - <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
550.399 - <attribute default="${main.class}" name="classname"/>
550.400 - <attribute default="${debug.classpath}" name="classpath"/>
550.401 - <element name="customize" optional="true"/>
550.402 - <sequential>
550.403 - <java classname="@{classname}" dir="${work.dir}" fork="true">
550.404 - <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
550.405 - <jvmarg line="${debug-args-line}"/>
550.406 - <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
550.407 - <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
550.408 - <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
550.409 - <jvmarg line="${run.jvmargs}"/>
550.410 - <classpath>
550.411 - <path path="@{classpath}"/>
550.412 - </classpath>
550.413 - <syspropertyset>
550.414 - <propertyref prefix="run-sys-prop."/>
550.415 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
550.416 - </syspropertyset>
550.417 - <customize/>
550.418 - </java>
550.419 - </sequential>
550.420 - </macrodef>
550.421 - </target>
550.422 - <target name="-init-macrodef-java">
550.423 - <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
550.424 - <attribute default="${main.class}" name="classname"/>
550.425 - <attribute default="${run.classpath}" name="classpath"/>
550.426 - <element name="customize" optional="true"/>
550.427 - <sequential>
550.428 - <java classname="@{classname}" dir="${work.dir}" fork="true">
550.429 - <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
550.430 - <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
550.431 - <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
550.432 - <jvmarg line="${run.jvmargs}"/>
550.433 - <classpath>
550.434 - <path path="@{classpath}"/>
550.435 - </classpath>
550.436 - <syspropertyset>
550.437 - <propertyref prefix="run-sys-prop."/>
550.438 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
550.439 - </syspropertyset>
550.440 - <customize/>
550.441 - </java>
550.442 - </sequential>
550.443 - </macrodef>
550.444 - </target>
550.445 - <target name="-init-presetdef-jar">
550.446 - <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
550.447 - <jar compress="${jar.compress}" jarfile="${dist.jar}">
550.448 - <j2seproject1:fileset dir="${build.classes.dir}"/>
550.449 - </jar>
550.450 - </presetdef>
550.451 - </target>
550.452 - <target name="-init-ap-cmdline-properties">
550.453 - <property name="annotation.processing.enabled" value="true"/>
550.454 - <property name="annotation.processing.processors.list" value=""/>
550.455 - <property name="annotation.processing.run.all.processors" value="true"/>
550.456 - <property name="javac.processorpath" value="${javac.classpath}"/>
550.457 - <property name="javac.test.processorpath" value="${javac.test.classpath}"/>
550.458 - <condition property="ap.supported.internal" value="true">
550.459 - <not>
550.460 - <matches pattern="1\.[0-5](\..*)?" string="${javac.source}"/>
550.461 - </not>
550.462 - </condition>
550.463 - </target>
550.464 - <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-ap-cmdline-supported">
550.465 - <condition else="" property="ap.processors.internal" value="-processor ${annotation.processing.processors.list}">
550.466 - <isfalse value="${annotation.processing.run.all.processors}"/>
550.467 - </condition>
550.468 - <condition else="" property="ap.proc.none.internal" value="-proc:none">
550.469 - <isfalse value="${annotation.processing.enabled}"/>
550.470 - </condition>
550.471 - </target>
550.472 - <target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
550.473 - <property name="ap.cmd.line.internal" value=""/>
550.474 - </target>
550.475 - <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
550.476 - <!--
550.477 - ===================
550.478 - COMPILATION SECTION
550.479 - ===================
550.480 - -->
550.481 - <target name="-deps-jar-init" unless="built-jar.properties">
550.482 - <property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>
550.483 - <delete file="${built-jar.properties}" quiet="true"/>
550.484 - </target>
550.485 - <target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
550.486 - <echo level="warn" message="Cycle detected: web.api was already built"/>
550.487 - </target>
550.488 - <target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
550.489 - <mkdir dir="${build.dir}"/>
550.490 - <touch file="${built-jar.properties}" verbose="false"/>
550.491 - <property file="${built-jar.properties}" prefix="already.built.jar."/>
550.492 - <antcall target="-warn-already-built-jar"/>
550.493 - <propertyfile file="${built-jar.properties}">
550.494 - <entry key="${basedir}" value=""/>
550.495 - </propertyfile>
550.496 - <antcall target="-maybe-call-dep">
550.497 - <param name="call.built.properties" value="${built-jar.properties}"/>
550.498 - <param location="${project.indexer}" name="call.subproject"/>
550.499 - <param location="${project.indexer}/build.xml" name="call.script"/>
550.500 - <param name="call.target" value="jar"/>
550.501 - <param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
550.502 - </antcall>
550.503 - <antcall target="-maybe-call-dep">
550.504 - <param name="call.built.properties" value="${built-jar.properties}"/>
550.505 - <param location="${project.org_netbeans_modules_jackpot30_api}" name="call.subproject"/>
550.506 - <param location="${project.org_netbeans_modules_jackpot30_api}/build.xml" name="call.script"/>
550.507 - <param name="call.target" value="netbeans"/>
550.508 - <param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
550.509 - </antcall>
550.510 - </target>
550.511 - <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
550.512 - <target depends="init" name="-check-automatic-build">
550.513 - <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
550.514 - </target>
550.515 - <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
550.516 - <antcall target="clean"/>
550.517 - </target>
550.518 - <target depends="init,deps-jar" name="-pre-pre-compile">
550.519 - <mkdir dir="${build.classes.dir}"/>
550.520 - </target>
550.521 - <target name="-pre-compile">
550.522 - <!-- Empty placeholder for easier customization. -->
550.523 - <!-- You can override this target in the ../build.xml file. -->
550.524 - </target>
550.525 - <target if="do.depend.true" name="-compile-depend">
550.526 - <pathconvert property="build.generated.subdirs">
550.527 - <dirset dir="${build.generated.sources.dir}" erroronmissingdir="false">
550.528 - <include name="*"/>
550.529 - </dirset>
550.530 - </pathconvert>
550.531 - <j2seproject3:depend srcdir="${src.dir}:${build.generated.subdirs}"/>
550.532 - </target>
550.533 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
550.534 - <j2seproject3:javac gensrcdir="${build.generated.sources.dir}"/>
550.535 - <copy todir="${build.classes.dir}">
550.536 - <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
550.537 - </copy>
550.538 - </target>
550.539 - <target name="-post-compile">
550.540 - <!-- Empty placeholder for easier customization. -->
550.541 - <!-- You can override this target in the ../build.xml file. -->
550.542 - </target>
550.543 - <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
550.544 - <target name="-pre-compile-single">
550.545 - <!-- Empty placeholder for easier customization. -->
550.546 - <!-- You can override this target in the ../build.xml file. -->
550.547 - </target>
550.548 - <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
550.549 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
550.550 - <j2seproject3:force-recompile/>
550.551 - <j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.dir}"/>
550.552 - </target>
550.553 - <target name="-post-compile-single">
550.554 - <!-- Empty placeholder for easier customization. -->
550.555 - <!-- You can override this target in the ../build.xml file. -->
550.556 - </target>
550.557 - <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
550.558 - <!--
550.559 - ====================
550.560 - JAR BUILDING SECTION
550.561 - ====================
550.562 - -->
550.563 - <target depends="init" name="-pre-pre-jar">
550.564 - <dirname file="${dist.jar}" property="dist.jar.dir"/>
550.565 - <mkdir dir="${dist.jar.dir}"/>
550.566 - </target>
550.567 - <target name="-pre-jar">
550.568 - <!-- Empty placeholder for easier customization. -->
550.569 - <!-- You can override this target in the ../build.xml file. -->
550.570 - </target>
550.571 - <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available-mkdist.available">
550.572 - <j2seproject1:jar/>
550.573 - </target>
550.574 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class-mkdist.available">
550.575 - <j2seproject1:jar manifest="${manifest.file}"/>
550.576 - </target>
550.577 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
550.578 - <j2seproject1:jar manifest="${manifest.file}">
550.579 - <j2seproject1:manifest>
550.580 - <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
550.581 - </j2seproject1:manifest>
550.582 - </j2seproject1:jar>
550.583 - <echo>To run this application from the command line without Ant, try:</echo>
550.584 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
550.585 - <property location="${dist.jar}" name="dist.jar.resolved"/>
550.586 - <pathconvert property="run.classpath.with.dist.jar">
550.587 - <path path="${run.classpath}"/>
550.588 - <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
550.589 - </pathconvert>
550.590 - <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
550.591 - </target>
550.592 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available+splashscreen.available" name="-do-jar-with-libraries-and-splashscreen">
550.593 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
550.594 - <pathconvert property="run.classpath.without.build.classes.dir">
550.595 - <path path="${run.classpath}"/>
550.596 - <map from="${build.classes.dir.resolved}" to=""/>
550.597 - </pathconvert>
550.598 - <pathconvert pathsep=" " property="jar.classpath">
550.599 - <path path="${run.classpath.without.build.classes.dir}"/>
550.600 - <chainedmapper>
550.601 - <flattenmapper/>
550.602 - <globmapper from="*" to="lib/*"/>
550.603 - </chainedmapper>
550.604 - </pathconvert>
550.605 - <basename file="${application.splash}" property="splashscreen.basename"/>
550.606 - <mkdir dir="${build.classes.dir}/META-INF"/>
550.607 - <copy failonerror="false" file="${application.splash}" todir="${build.classes.dir}/META-INF"/>
550.608 - <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
550.609 - <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
550.610 - <fileset dir="${build.classes.dir}"/>
550.611 - <manifest>
550.612 - <attribute name="Main-Class" value="${main.class}"/>
550.613 - <attribute name="Class-Path" value="${jar.classpath}"/>
550.614 - <attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/>
550.615 - </manifest>
550.616 - </copylibs>
550.617 - <echo>To run this application from the command line without Ant, try:</echo>
550.618 - <property location="${dist.jar}" name="dist.jar.resolved"/>
550.619 - <echo>java -jar "${dist.jar.resolved}"</echo>
550.620 - </target>
550.621 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries" unless="splashscreen.available">
550.622 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
550.623 - <pathconvert property="run.classpath.without.build.classes.dir">
550.624 - <path path="${run.classpath}"/>
550.625 - <map from="${build.classes.dir.resolved}" to=""/>
550.626 - </pathconvert>
550.627 - <pathconvert pathsep=" " property="jar.classpath">
550.628 - <path path="${run.classpath.without.build.classes.dir}"/>
550.629 - <chainedmapper>
550.630 - <flattenmapper/>
550.631 - <globmapper from="*" to="lib/*"/>
550.632 - </chainedmapper>
550.633 - </pathconvert>
550.634 - <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
550.635 - <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
550.636 - <fileset dir="${build.classes.dir}"/>
550.637 - <manifest>
550.638 - <attribute name="Main-Class" value="${main.class}"/>
550.639 - <attribute name="Class-Path" value="${jar.classpath}"/>
550.640 - </manifest>
550.641 - </copylibs>
550.642 - <echo>To run this application from the command line without Ant, try:</echo>
550.643 - <property location="${dist.jar}" name="dist.jar.resolved"/>
550.644 - <echo>java -jar "${dist.jar.resolved}"</echo>
550.645 - </target>
550.646 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+mkdist.available" name="-do-jar-with-libraries-without-mainclass" unless="main.class.available">
550.647 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
550.648 - <pathconvert property="run.classpath.without.build.classes.dir">
550.649 - <path path="${run.classpath}"/>
550.650 - <map from="${build.classes.dir.resolved}" to=""/>
550.651 - </pathconvert>
550.652 - <pathconvert pathsep=" " property="jar.classpath">
550.653 - <path path="${run.classpath.without.build.classes.dir}"/>
550.654 - <chainedmapper>
550.655 - <flattenmapper/>
550.656 - <globmapper from="*" to="lib/*"/>
550.657 - </chainedmapper>
550.658 - </pathconvert>
550.659 - <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
550.660 - <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
550.661 - <fileset dir="${build.classes.dir}"/>
550.662 - <manifest>
550.663 - <attribute name="Class-Path" value="${jar.classpath}"/>
550.664 - </manifest>
550.665 - </copylibs>
550.666 - </target>
550.667 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.mkdist" name="-do-jar-with-libraries-without-manifest" unless="manifest.available">
550.668 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
550.669 - <pathconvert property="run.classpath.without.build.classes.dir">
550.670 - <path path="${run.classpath}"/>
550.671 - <map from="${build.classes.dir.resolved}" to=""/>
550.672 - </pathconvert>
550.673 - <pathconvert pathsep=" " property="jar.classpath">
550.674 - <path path="${run.classpath.without.build.classes.dir}"/>
550.675 - <chainedmapper>
550.676 - <flattenmapper/>
550.677 - <globmapper from="*" to="lib/*"/>
550.678 - </chainedmapper>
550.679 - </pathconvert>
550.680 - <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
550.681 - <copylibs compress="${jar.compress}" jarfile="${dist.jar}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
550.682 - <fileset dir="${build.classes.dir}"/>
550.683 - <manifest>
550.684 - <attribute name="Class-Path" value="${jar.classpath}"/>
550.685 - </manifest>
550.686 - </copylibs>
550.687 - </target>
550.688 - <target name="-post-jar">
550.689 - <!-- Empty placeholder for easier customization. -->
550.690 - <!-- You can override this target in the ../build.xml file. -->
550.691 - </target>
550.692 - <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries-and-splashscreen,-do-jar-with-libraries,-do-jar-with-libraries-without-mainclass,-do-jar-with-libraries-without-manifest,-post-jar" description="Build JAR." name="jar"/>
550.693 - <!--
550.694 - =================
550.695 - EXECUTION SECTION
550.696 - =================
550.697 - -->
550.698 - <target depends="init,compile" description="Run a main class." name="run">
550.699 - <j2seproject1:java>
550.700 - <customize>
550.701 - <arg line="${application.args}"/>
550.702 - </customize>
550.703 - </j2seproject1:java>
550.704 - </target>
550.705 - <target name="-do-not-recompile">
550.706 - <property name="javac.includes.binary" value=""/>
550.707 - </target>
550.708 - <target depends="init,compile-single" name="run-single">
550.709 - <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
550.710 - <j2seproject1:java classname="${run.class}"/>
550.711 - </target>
550.712 - <target depends="init,compile-test-single" name="run-test-with-main">
550.713 - <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
550.714 - <j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
550.715 - </target>
550.716 - <!--
550.717 - =================
550.718 - DEBUGGING SECTION
550.719 - =================
550.720 - -->
550.721 - <target depends="init" if="netbeans.home" name="-debug-start-debugger">
550.722 - <j2seproject1:nbjpdastart name="${debug.class}"/>
550.723 - </target>
550.724 - <target depends="init" if="netbeans.home" name="-debug-start-debugger-main-test">
550.725 - <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${debug.class}"/>
550.726 - </target>
550.727 - <target depends="init,compile" name="-debug-start-debuggee">
550.728 - <j2seproject3:debug>
550.729 - <customize>
550.730 - <arg line="${application.args}"/>
550.731 - </customize>
550.732 - </j2seproject3:debug>
550.733 - </target>
550.734 - <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
550.735 - <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
550.736 - <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
550.737 - </target>
550.738 - <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
550.739 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
550.740 - <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
550.741 - <j2seproject3:debug classname="${debug.class}"/>
550.742 - </target>
550.743 - <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
550.744 - <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">
550.745 - <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
550.746 - <j2seproject3:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>
550.747 - </target>
550.748 - <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
550.749 - <target depends="init" name="-pre-debug-fix">
550.750 - <fail unless="fix.includes">Must set fix.includes</fail>
550.751 - <property name="javac.includes" value="${fix.includes}.java"/>
550.752 - </target>
550.753 - <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
550.754 - <j2seproject1:nbjpdareload/>
550.755 - </target>
550.756 - <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
550.757 - <!--
550.758 - ===============
550.759 - JAVADOC SECTION
550.760 - ===============
550.761 - -->
550.762 - <target depends="init" if="have.sources" name="-javadoc-build">
550.763 - <mkdir dir="${dist.javadoc.dir}"/>
550.764 - <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
550.765 - <classpath>
550.766 - <path path="${javac.classpath}"/>
550.767 - </classpath>
550.768 - <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
550.769 - <filename name="**/*.java"/>
550.770 - </fileset>
550.771 - <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
550.772 - <include name="**/*.java"/>
550.773 - </fileset>
550.774 - </javadoc>
550.775 - </target>
550.776 - <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
550.777 - <nbbrowse file="${dist.javadoc.dir}/index.html"/>
550.778 - </target>
550.779 - <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
550.780 - <!--
550.781 - =========================
550.782 - JUNIT COMPILATION SECTION
550.783 - =========================
550.784 - -->
550.785 - <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
550.786 - <mkdir dir="${build.test.classes.dir}"/>
550.787 - </target>
550.788 - <target name="-pre-compile-test">
550.789 - <!-- Empty placeholder for easier customization. -->
550.790 - <!-- You can override this target in the ../build.xml file. -->
550.791 - </target>
550.792 - <target if="do.depend.true" name="-compile-test-depend">
550.793 - <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
550.794 - </target>
550.795 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
550.796 - <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.src.dir}"/>
550.797 - <copy todir="${build.test.classes.dir}">
550.798 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
550.799 - </copy>
550.800 - </target>
550.801 - <target name="-post-compile-test">
550.802 - <!-- Empty placeholder for easier customization. -->
550.803 - <!-- You can override this target in the ../build.xml file. -->
550.804 - </target>
550.805 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
550.806 - <target name="-pre-compile-test-single">
550.807 - <!-- Empty placeholder for easier customization. -->
550.808 - <!-- You can override this target in the ../build.xml file. -->
550.809 - </target>
550.810 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
550.811 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
550.812 - <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
550.813 - <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
550.814 - <copy todir="${build.test.classes.dir}">
550.815 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
550.816 - </copy>
550.817 - </target>
550.818 - <target name="-post-compile-test-single">
550.819 - <!-- Empty placeholder for easier customization. -->
550.820 - <!-- You can override this target in the ../build.xml file. -->
550.821 - </target>
550.822 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
550.823 - <!--
550.824 - =======================
550.825 - JUNIT EXECUTION SECTION
550.826 - =======================
550.827 - -->
550.828 - <target depends="init" if="have.tests" name="-pre-test-run">
550.829 - <mkdir dir="${build.test.results.dir}"/>
550.830 - </target>
550.831 - <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
550.832 - <j2seproject3:junit testincludes="**/*Test.java"/>
550.833 - </target>
550.834 - <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
550.835 - <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
550.836 - </target>
550.837 - <target depends="init" if="have.tests" name="test-report"/>
550.838 - <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
550.839 - <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
550.840 - <target depends="init" if="have.tests" name="-pre-test-run-single">
550.841 - <mkdir dir="${build.test.results.dir}"/>
550.842 - </target>
550.843 - <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
550.844 - <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
550.845 - <j2seproject3:junit excludes="" includes="${test.includes}"/>
550.846 - </target>
550.847 - <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
550.848 - <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
550.849 - </target>
550.850 - <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
550.851 - <!--
550.852 - =======================
550.853 - JUNIT DEBUGGING SECTION
550.854 - =======================
550.855 - -->
550.856 - <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
550.857 - <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
550.858 - <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
550.859 - <delete file="${test.report.file}"/>
550.860 - <mkdir dir="${build.test.results.dir}"/>
550.861 - <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
550.862 - <customize>
550.863 - <syspropertyset>
550.864 - <propertyref prefix="test-sys-prop."/>
550.865 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
550.866 - </syspropertyset>
550.867 - <arg value="${test.class}"/>
550.868 - <arg value="showoutput=true"/>
550.869 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
550.870 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
550.871 - </customize>
550.872 - </j2seproject3:debug>
550.873 - </target>
550.874 - <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
550.875 - <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
550.876 - </target>
550.877 - <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
550.878 - <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
550.879 - <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
550.880 - </target>
550.881 - <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
550.882 - <!--
550.883 - =========================
550.884 - APPLET EXECUTION SECTION
550.885 - =========================
550.886 - -->
550.887 - <target depends="init,compile-single" name="run-applet">
550.888 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
550.889 - <j2seproject1:java classname="sun.applet.AppletViewer">
550.890 - <customize>
550.891 - <arg value="${applet.url}"/>
550.892 - </customize>
550.893 - </j2seproject1:java>
550.894 - </target>
550.895 - <!--
550.896 - =========================
550.897 - APPLET DEBUGGING SECTION
550.898 - =========================
550.899 - -->
550.900 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
550.901 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
550.902 - <j2seproject3:debug classname="sun.applet.AppletViewer">
550.903 - <customize>
550.904 - <arg value="${applet.url}"/>
550.905 - </customize>
550.906 - </j2seproject3:debug>
550.907 - </target>
550.908 - <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
550.909 - <!--
550.910 - ===============
550.911 - CLEANUP SECTION
550.912 - ===============
550.913 - -->
550.914 - <target name="-deps-clean-init" unless="built-clean.properties">
550.915 - <property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>
550.916 - <delete file="${built-clean.properties}" quiet="true"/>
550.917 - </target>
550.918 - <target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
550.919 - <echo level="warn" message="Cycle detected: web.api was already built"/>
550.920 - </target>
550.921 - <target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
550.922 - <mkdir dir="${build.dir}"/>
550.923 - <touch file="${built-clean.properties}" verbose="false"/>
550.924 - <property file="${built-clean.properties}" prefix="already.built.clean."/>
550.925 - <antcall target="-warn-already-built-clean"/>
550.926 - <propertyfile file="${built-clean.properties}">
550.927 - <entry key="${basedir}" value=""/>
550.928 - </propertyfile>
550.929 - <antcall target="-maybe-call-dep">
550.930 - <param name="call.built.properties" value="${built-clean.properties}"/>
550.931 - <param location="${project.indexer}" name="call.subproject"/>
550.932 - <param location="${project.indexer}/build.xml" name="call.script"/>
550.933 - <param name="call.target" value="clean"/>
550.934 - <param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
550.935 - </antcall>
550.936 - <antcall target="-maybe-call-dep">
550.937 - <param name="call.built.properties" value="${built-clean.properties}"/>
550.938 - <param location="${project.org_netbeans_modules_jackpot30_api}" name="call.subproject"/>
550.939 - <param location="${project.org_netbeans_modules_jackpot30_api}/build.xml" name="call.script"/>
550.940 - <param name="call.target" value="clean"/>
550.941 - <param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
550.942 - </antcall>
550.943 - </target>
550.944 - <target depends="init" name="-do-clean">
550.945 - <delete dir="${build.dir}"/>
550.946 - <delete dir="${dist.dir}" followsymlinks="false" includeemptydirs="true"/>
550.947 - </target>
550.948 - <target name="-post-clean">
550.949 - <!-- Empty placeholder for easier customization. -->
550.950 - <!-- You can override this target in the ../build.xml file. -->
550.951 - </target>
550.952 - <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
550.953 - <target name="-check-call-dep">
550.954 - <property file="${call.built.properties}" prefix="already.built."/>
550.955 - <condition property="should.call.dep">
550.956 - <not>
550.957 - <isset property="already.built.${call.subproject}"/>
550.958 - </not>
550.959 - </condition>
550.960 - </target>
550.961 - <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
550.962 - <ant antfile="${call.script}" inheritall="false" target="${call.target}">
550.963 - <propertyset>
550.964 - <propertyref prefix="transfer."/>
550.965 - <mapper from="transfer.*" to="*" type="glob"/>
550.966 - </propertyset>
550.967 - </ant>
550.968 - </target>
550.969 -</project>
551.1 --- a/server/web.api/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
551.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
551.3 @@ -1,8 +0,0 @@
551.4 -build.xml.data.CRC32=2d84667c
551.5 -build.xml.script.CRC32=0d0c4a18
551.6 -build.xml.stylesheet.CRC32=958a1d3e@1.27.0.45
551.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
551.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
551.9 -nbproject/build-impl.xml.data.CRC32=2d84667c
551.10 -nbproject/build-impl.xml.script.CRC32=8250004f
551.11 -nbproject/build-impl.xml.stylesheet.CRC32=ff4aa3ed@1.35.0.45
552.1 --- a/server/web.api/nbproject/project.properties Fri Jan 27 13:35:56 2012 +0100
552.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
552.3 @@ -1,99 +0,0 @@
552.4 -annotation.processing.enabled=true
552.5 -annotation.processing.enabled.in.editor=false
552.6 -annotation.processing.run.all.processors=true
552.7 -application.title=web.api
552.8 -application.vendor=lahvac
552.9 -build.classes.dir=${build.dir}/classes
552.10 -build.classes.excludes=**/*.java,**/*.form
552.11 -# This directory is removed when the project is cleaned:
552.12 -build.dir=build
552.13 -build.generated.dir=${build.dir}/generated
552.14 -build.generated.sources.dir=${build.dir}/generated-sources
552.15 -# Only compile against the classpath explicitly listed here:
552.16 -build.sysclasspath=ignore
552.17 -build.test.classes.dir=${build.dir}/test/classes
552.18 -build.test.results.dir=${build.dir}/test/results
552.19 -# Uncomment to specify the preferred debugger connection transport:
552.20 -#debug.transport=dt_socket
552.21 -debug.classpath=\
552.22 - ${run.classpath}
552.23 -debug.test.classpath=\
552.24 - ${run.test.classpath}
552.25 -# This directory is removed when the project is cleaned:
552.26 -dist.dir=dist
552.27 -dist.jar=${dist.dir}/web.api.jar
552.28 -dist.javadoc.dir=${dist.dir}/javadoc
552.29 -endorsed.classpath=\
552.30 - ${libs.javac.classpath}
552.31 -excludes=
552.32 -file.reference.org-netbeans-modules-java-source.jar=../lib/org-netbeans-modules-java-source.jar
552.33 -file.reference.org-netbeans-spi-editor-hints.jar=../lib/org-netbeans-spi-editor-hints.jar
552.34 -file.reference.org-openide-filesystems.jar=../lib/org-openide-filesystems.jar
552.35 -file.reference.org-openide-util-lookup.jar=../lib/org-openide-util-lookup.jar
552.36 -file.reference.org-openide-util.jar=../lib/org-openide-util.jar
552.37 -file.reference.util-commons.jar=../../remoting/ide/api/external/util-commons.jar
552.38 -file.reference.util-pojson.jar=../../remoting/ide/api/external/util-pojson.jar
552.39 -includes=**
552.40 -jar.compress=false
552.41 -javac.classpath=\
552.42 - ${reference.org_netbeans_modules_jackpot30_api.module}:\
552.43 - ${libs.jersey.classpath}:\
552.44 - ${libs.lucene.classpath}:\
552.45 - ${libs.javac.classpath}:\
552.46 - ${reference.indexer.jar}:\
552.47 - ${file.reference.org-netbeans-modules-java-source.jar}:\
552.48 - ${file.reference.org-openide-filesystems.jar}:\
552.49 - ${file.reference.util-commons.jar}:\
552.50 - ${file.reference.util-pojson.jar}:\
552.51 - ${libs.freemarker.classpath}:\
552.52 - ${file.reference.org-openide-util.jar}:\
552.53 - ${file.reference.org-openide-util-lookup.jar}:\
552.54 - ${file.reference.org-netbeans-spi-editor-hints.jar}:\
552.55 - ${reference.org_netbeans_modules_jackpot30_remoting_api.module}
552.56 -# Space-separated list of extra javac options
552.57 -javac.compilerargs=
552.58 -javac.deprecation=false
552.59 -javac.processorpath=\
552.60 - ${javac.classpath}
552.61 -javac.source=1.5
552.62 -javac.target=1.5
552.63 -javac.test.classpath=\
552.64 - ${javac.classpath}:\
552.65 - ${build.classes.dir}:\
552.66 - ${libs.junit_4.classpath}
552.67 -javadoc.additionalparam=
552.68 -javadoc.author=false
552.69 -javadoc.encoding=${source.encoding}
552.70 -javadoc.noindex=false
552.71 -javadoc.nonavbar=false
552.72 -javadoc.notree=false
552.73 -javadoc.private=false
552.74 -javadoc.splitindex=true
552.75 -javadoc.use=true
552.76 -javadoc.version=false
552.77 -javadoc.windowtitle=
552.78 -jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api"
552.79 -main.class=org.netbeans.modules.jackpot30.server.webapi.Main
552.80 -manifest.file=manifest.mf
552.81 -meta.inf.dir=${src.dir}/META-INF
552.82 -mkdist.disabled=false
552.83 -platform.active=default_platform
552.84 -project.indexer=../indexer
552.85 -project.org_netbeans_modules_jackpot30_api=../../api
552.86 -project.org_netbeans_modules_jackpot30_remoting_api=../../remoting/ide/api
552.87 -reference.indexer.jar=${project.indexer}/dist/indexer.jar
552.88 -reference.org_netbeans_modules_jackpot30_api.module=${project.org_netbeans_modules_jackpot30_api}/../build/cluster/modules/org-netbeans-modules-jackpot30-api.jar
552.89 -reference.org_netbeans_modules_jackpot30_remoting_api.module=${project.org_netbeans_modules_jackpot30_remoting_api}/../build/cluster/modules/org-netbeans-modules-jackpot30-remoting-api.jar
552.90 -run.classpath=\
552.91 - ${javac.classpath}:\
552.92 - ${build.classes.dir}
552.93 -# Space-separated list of JVM arguments used when running the project
552.94 -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
552.95 -# or test-sys-prop.name=value to set system properties for unit tests):
552.96 -run.jvmargs=-Xbootclasspath/p:${libs.javac.classpath}
552.97 -run.test.classpath=\
552.98 - ${javac.test.classpath}:\
552.99 - ${build.test.classes.dir}
552.100 -source.encoding=UTF-8
552.101 -src.dir=src
552.102 -test.src.dir=test
553.1 --- a/server/web.api/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
553.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
553.3 @@ -1,44 +0,0 @@
553.4 -<?xml version="1.0" encoding="UTF-8"?>
553.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
553.6 - <type>org.netbeans.modules.java.j2seproject</type>
553.7 - <configuration>
553.8 - <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
553.9 - <name>web.api</name>
553.10 - <source-roots>
553.11 - <root id="src.dir"/>
553.12 - </source-roots>
553.13 - <test-roots>
553.14 - <root id="test.src.dir"/>
553.15 - </test-roots>
553.16 - </data>
553.17 - <libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
553.18 - <definitions>../lib/nblibraries.properties</definitions>
553.19 - </libraries>
553.20 - <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
553.21 - <reference>
553.22 - <foreign-project>indexer</foreign-project>
553.23 - <artifact-type>jar</artifact-type>
553.24 - <script>build.xml</script>
553.25 - <target>jar</target>
553.26 - <clean-target>clean</clean-target>
553.27 - <id>jar</id>
553.28 - </reference>
553.29 - <reference>
553.30 - <foreign-project>org_netbeans_modules_jackpot30_api</foreign-project>
553.31 - <artifact-type>jar</artifact-type>
553.32 - <script>build.xml</script>
553.33 - <target>netbeans</target>
553.34 - <clean-target>clean</clean-target>
553.35 - <id>module</id>
553.36 - </reference>
553.37 - <reference>
553.38 - <foreign-project>org_netbeans_modules_jackpot30_remoting_api</foreign-project>
553.39 - <artifact-type>jar</artifact-type>
553.40 - <script>build.xml</script>
553.41 - <target>netbeans</target>
553.42 - <clean-target>clean</clean-target>
553.43 - <id>module</id>
553.44 - </reference>
553.45 - </references>
553.46 - </configuration>
553.47 -</project>
554.1 --- a/server/web.api/src/org/netbeans/modules/jackpot30/server/webapi/API.java Fri Jan 27 13:35:56 2012 +0100
554.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
554.3 @@ -1,233 +0,0 @@
554.4 -/*
554.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
554.6 - *
554.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
554.8 - *
554.9 - * The contents of this file are subject to the terms of either the GNU
554.10 - * General Public License Version 2 only ("GPL") or the Common
554.11 - * Development and Distribution License("CDDL") (collectively, the
554.12 - * "License"). You may not use this file except in compliance with the
554.13 - * License. You can obtain a copy of the License at
554.14 - * http://www.netbeans.org/cddl-gplv2.html
554.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
554.16 - * specific language governing permissions and limitations under the
554.17 - * License. When distributing the software, include this License Header
554.18 - * Notice in each file and include the License file at
554.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
554.20 - * particular file as subject to the "Classpath" exception as provided
554.21 - * by Sun in the GPL Version 2 section of the License file that
554.22 - * accompanied this code. If applicable, add the following below the
554.23 - * License Header, with the fields enclosed by brackets [] replaced by
554.24 - * your own identifying information:
554.25 - * "Portions Copyrighted [year] [name of copyright owner]"
554.26 - *
554.27 - * If you wish your version of this file to be governed by only the CDDL
554.28 - * or only the GPL Version 2, indicate your decision by adding
554.29 - * "[Contributor] elects to include this software in this distribution
554.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
554.31 - * single choice of license, a recipient has the option to distribute
554.32 - * your version of this file under either the CDDL, the GPL Version 2 or
554.33 - * to extend the choice of license to its licensees as provided above.
554.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
554.35 - * Version 2 license, then the option applies only if the new code is
554.36 - * made subject to such option by the copyright holder.
554.37 - *
554.38 - * Contributor(s):
554.39 - *
554.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
554.41 - */
554.42 -
554.43 -package org.netbeans.modules.jackpot30.server.webapi;
554.44 -
554.45 -import java.io.IOException;
554.46 -import java.net.URL;
554.47 -import java.util.Arrays;
554.48 -import java.util.Collection;
554.49 -import java.util.HashMap;
554.50 -import java.util.LinkedList;
554.51 -import java.util.List;
554.52 -import java.util.Map;
554.53 -import java.util.Map.Entry;
554.54 -import javax.tools.Diagnostic;
554.55 -import javax.tools.JavaFileObject;
554.56 -import javax.ws.rs.DefaultValue;
554.57 -import javax.ws.rs.GET;
554.58 -import javax.ws.rs.Path;
554.59 -import javax.ws.rs.Produces;
554.60 -import javax.ws.rs.QueryParam;
554.61 -import org.codeviation.pojson.Pojson;
554.62 -import org.netbeans.modules.jackpot30.impl.examples.Example;
554.63 -import org.netbeans.modules.jackpot30.impl.examples.Example.Option;
554.64 -import org.netbeans.modules.jackpot30.impl.examples.LoadExamples;
554.65 -import org.netbeans.modules.jackpot30.impl.indexing.Cache;
554.66 -import org.netbeans.modules.jackpot30.impl.indexing.FileBasedIndex;
554.67 -import org.netbeans.modules.jackpot30.impl.indexing.Index;
554.68 -import org.netbeans.modules.jackpot30.server.indexer.StandaloneFinder;
554.69 -
554.70 -/**
554.71 - *
554.72 - * @author lahvac
554.73 - */
554.74 -@Path("/")
554.75 -public class API {
554.76 -
554.77 - @GET
554.78 - @Path("/find")
554.79 - @Produces("text/plain")
554.80 - public String find(@QueryParam("path") String segment, @QueryParam("pattern") String pattern) throws IOException {
554.81 - StringBuilder sb = new StringBuilder();
554.82 -
554.83 - for (String candidate : StandaloneFinder.findCandidates(Cache.sourceRootForKey(segment), pattern)) {
554.84 - sb.append(candidate);
554.85 - sb.append("\n");
554.86 - }
554.87 -
554.88 - return sb.toString();
554.89 - }
554.90 -
554.91 - @GET
554.92 - @Path("/findSpans")
554.93 - @Produces("text/plain")
554.94 - public String findSpans(@QueryParam("path") String segment, @QueryParam("relativePath") String relativePath, @QueryParam("pattern") String pattern) throws IOException {
554.95 - StringBuilder sb = new StringBuilder();
554.96 -
554.97 - for (int o : StandaloneFinder.findCandidateOccurrenceSpans(Cache.sourceRootForKey(segment), relativePath, pattern)) {
554.98 - sb.append(o);
554.99 - sb.append(":");
554.100 - }
554.101 -
554.102 - if (sb.length() > 0) {
554.103 - sb.delete(sb.length() - 1, sb.length());
554.104 - }
554.105 -
554.106 - return sb.toString();
554.107 - }
554.108 -
554.109 - @GET
554.110 - @Path("/list")
554.111 - @Produces("text/plain")
554.112 - public String list() throws IOException {
554.113 - StringBuilder sb = new StringBuilder();
554.114 -
554.115 - for (String root : Cache.knownSourceRoots()) {
554.116 - URL sourceRoot = Cache.sourceRootForKey(root).toURI().toURL();
554.117 - Index index = FileBasedIndex.get(sourceRoot);
554.118 - String displayName;
554.119 -
554.120 - if (index != null && index.getIndexInfo().displayName != null) {
554.121 - displayName = index.getIndexInfo().displayName;
554.122 - } else {
554.123 - String path = sourceRoot.getPath().replaceFirst("/$", "");
554.124 -
554.125 - displayName = path.substring(path.lastIndexOf('/') + 1);
554.126 - }
554.127 -
554.128 - sb.append(root);
554.129 - sb.append(":");
554.130 - sb.append(displayName);
554.131 - sb.append("\n");
554.132 - }
554.133 -
554.134 - return sb.toString();
554.135 - }
554.136 -
554.137 - @GET
554.138 - @Path("/cat")
554.139 - @Produces("text/plain")
554.140 - public String cat(@QueryParam("path") String segment, @QueryParam("relative") String relative) throws IOException {
554.141 - URL sourceRoot = Cache.sourceRootForKey(segment).toURI().toURL();
554.142 - Index index = FileBasedIndex.get(sourceRoot);
554.143 -
554.144 - if (index == null) {
554.145 - throw new IOException("No index");
554.146 - }
554.147 -
554.148 - CharSequence source = index.getSourceCode(relative);
554.149 -
554.150 - if (source == null) {
554.151 - throw new IOException("Source code not found");
554.152 - }
554.153 -
554.154 - return source.toString().replaceAll("\r\n", "\n");
554.155 - }
554.156 -
554.157 - @GET
554.158 - @Path("/info")
554.159 - @Produces("text/plain")
554.160 - public String info(@QueryParam("path") String segment) throws IOException {
554.161 - URL sourceRoot = Cache.sourceRootForKey(segment).toURI().toURL();
554.162 - Index index = FileBasedIndex.get(sourceRoot);
554.163 -
554.164 - if (index == null) {
554.165 - throw new IOException("No index");
554.166 - }
554.167 -
554.168 - return Pojson.save(index.getIndexInfo());
554.169 - }
554.170 -
554.171 - @GET
554.172 - @Path("/examples")
554.173 - @Produces("text/plain")
554.174 - public String examples() throws IOException {
554.175 - List<Map<String, String>> examples = new LinkedList<Map<String, String>>();
554.176 -
554.177 - for (Example ex : LoadExamples.loadExamples()) {
554.178 - if (ex.getOptions().contains(Option.VERIFY) || ex.getOptions().contains(Option.FIX)) continue;
554.179 - Map<String, String> desc = new HashMap<String, String>();
554.180 -
554.181 - desc.put("displayName", ex.getDisplayName());
554.182 - desc.put("pattern", ex.getCode());
554.183 -
554.184 - examples.add(desc);
554.185 - }
554.186 -
554.187 - return Pojson.save(examples);
554.188 - }
554.189 -
554.190 - @GET
554.191 - @Path("/errors")
554.192 - @Produces("text/plain")
554.193 - public String errors(@QueryParam("pattern") String pattern) throws IOException {
554.194 - StringBuilder sb = new StringBuilder();
554.195 -
554.196 - for (Diagnostic<? extends JavaFileObject> d : StandaloneFinder.parseAndReportErrors(pattern)) {
554.197 - sb.append(d.getMessage(null));
554.198 - sb.append("\n");
554.199 - }
554.200 -
554.201 - return sb.toString();
554.202 - }
554.203 -
554.204 - @GET
554.205 - @Path("/findDuplicates")
554.206 - @Produces("text/plain")
554.207 - public String findDuplicates(@QueryParam("path") String segment, @QueryParam("hashes") String hashes) throws IOException {
554.208 - Map<String, Map<String, Collection<? extends String>>> hash2Segment2Contains = new HashMap<String, Map<String, Collection<? extends String>>>();
554.209 - Collection<String> segments = new LinkedList<String>();
554.210 -
554.211 - if (segment != null) segments.add(segment);
554.212 - else {
554.213 - for (String key : Cache.knownSourceRoots()) {
554.214 - segments.add(key);
554.215 - }
554.216 - }
554.217 -
554.218 - Iterable<? extends String> hashesList = Arrays.asList(Pojson.load(String[].class, hashes));
554.219 -
554.220 - for (String key : segments) {
554.221 - Map<String, Collection<? extends String>> found = StandaloneFinder.containsHash(Cache.sourceRootForKey(key), hashesList);
554.222 -
554.223 - for (Entry<String, Collection<? extends String>> e : found.entrySet()) {
554.224 - Map<String, Collection<? extends String>> perRoot = hash2Segment2Contains.get(e.getKey());
554.225 -
554.226 - if (perRoot == null) {
554.227 - hash2Segment2Contains.put(e.getKey(), perRoot = new HashMap<String, Collection<? extends String>>());
554.228 - }
554.229 -
554.230 - perRoot.put(key, e.getValue());
554.231 - }
554.232 - }
554.233 -
554.234 - return Pojson.save(hash2Segment2Contains);
554.235 - }
554.236 -}
555.1 --- a/server/web.api/src/org/netbeans/modules/jackpot30/server/webapi/Main.java Fri Jan 27 13:35:56 2012 +0100
555.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
555.3 @@ -1,93 +0,0 @@
555.4 -/*
555.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
555.6 - *
555.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
555.8 - *
555.9 - * The contents of this file are subject to the terms of either the GNU
555.10 - * General Public License Version 2 only ("GPL") or the Common
555.11 - * Development and Distribution License("CDDL") (collectively, the
555.12 - * "License"). You may not use this file except in compliance with the
555.13 - * License. You can obtain a copy of the License at
555.14 - * http://www.netbeans.org/cddl-gplv2.html
555.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
555.16 - * specific language governing permissions and limitations under the
555.17 - * License. When distributing the software, include this License Header
555.18 - * Notice in each file and include the License file at
555.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
555.20 - * particular file as subject to the "Classpath" exception as provided
555.21 - * by Sun in the GPL Version 2 section of the License file that
555.22 - * accompanied this code. If applicable, add the following below the
555.23 - * License Header, with the fields enclosed by brackets [] replaced by
555.24 - * your own identifying information:
555.25 - * "Portions Copyrighted [year] [name of copyright owner]"
555.26 - *
555.27 - * If you wish your version of this file to be governed by only the CDDL
555.28 - * or only the GPL Version 2, indicate your decision by adding
555.29 - * "[Contributor] elects to include this software in this distribution
555.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
555.31 - * single choice of license, a recipient has the option to distribute
555.32 - * your version of this file under either the CDDL, the GPL Version 2 or
555.33 - * to extend the choice of license to its licensees as provided above.
555.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
555.35 - * Version 2 license, then the option applies only if the new code is
555.36 - * made subject to such option by the copyright holder.
555.37 - *
555.38 - * Contributor(s):
555.39 - *
555.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
555.41 - */
555.42 -
555.43 -package org.netbeans.modules.jackpot30.server.webapi;
555.44 -
555.45 -import com.sun.grizzly.http.embed.GrizzlyWebServer;
555.46 -import com.sun.grizzly.http.servlet.ServletAdapter;
555.47 -import com.sun.grizzly.tcp.http11.GrizzlyAdapter;
555.48 -import com.sun.grizzly.tcp.http11.GrizzlyRequest;
555.49 -import com.sun.grizzly.tcp.http11.GrizzlyResponse;
555.50 -import com.sun.jersey.spi.container.servlet.ServletContainer;
555.51 -import java.io.File;
555.52 -import java.io.IOException;
555.53 -import org.netbeans.modules.jackpot30.impl.indexing.Cache;
555.54 -
555.55 -/**
555.56 - *
555.57 - * @author lahvac
555.58 - */
555.59 -public class Main {
555.60 -
555.61 - /**
555.62 - * @param args the command line arguments
555.63 - */
555.64 - public static void main(String[] args) throws IOException {
555.65 - if (args.length != 1 && args.length != 2) {
555.66 - System.err.println("Usage: java -jar " + Main.class.getProtectionDomain().getCodeSource().getLocation().getPath() + " <cache> [<static-content>]");
555.67 - return ;
555.68 - }
555.69 -
555.70 - Cache.setStandaloneCacheRoot(new File(args[0]));
555.71 -
555.72 - GrizzlyWebServer gws;
555.73 -
555.74 - if (args.length == 2) {
555.75 - gws = new GrizzlyWebServer(9998, args[1]);
555.76 - } else {
555.77 - gws = new GrizzlyWebServer(9998);
555.78 - }
555.79 -
555.80 - // Jersey web resources
555.81 - ServletAdapter jerseyAdapter = new ServletAdapter();
555.82 - jerseyAdapter.addInitParameter("com.sun.jersey.config.property.packages", "org.netbeans.modules.jackpot30.server.webapi");
555.83 - jerseyAdapter.setContextPath("/index");
555.84 - jerseyAdapter.setServletInstance(new ServletContainer());
555.85 -
555.86 - // register all above defined adapters
555.87 - gws.addGrizzlyAdapter(jerseyAdapter);
555.88 - gws.addGrizzlyAdapter(new GrizzlyAdapter(){
555.89 - public void service(GrizzlyRequest request, GrizzlyResponse response){}
555.90 - });
555.91 -
555.92 - // let Grizzly run
555.93 - gws.start();
555.94 - }
555.95 -
555.96 -}
556.1 --- a/server/web.api/src/org/netbeans/modules/jackpot30/server/webapi/UI.java Fri Jan 27 13:35:56 2012 +0100
556.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
556.3 @@ -1,274 +0,0 @@
556.4 -/*
556.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
556.6 - *
556.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
556.8 - *
556.9 - * The contents of this file are subject to the terms of either the GNU
556.10 - * General Public License Version 2 only ("GPL") or the Common
556.11 - * Development and Distribution License("CDDL") (collectively, the
556.12 - * "License"). You may not use this file except in compliance with the
556.13 - * License. You can obtain a copy of the License at
556.14 - * http://www.netbeans.org/cddl-gplv2.html
556.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
556.16 - * specific language governing permissions and limitations under the
556.17 - * License. When distributing the software, include this License Header
556.18 - * Notice in each file and include the License file at
556.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
556.20 - * particular file as subject to the "Classpath" exception as provided
556.21 - * by Sun in the GPL Version 2 section of the License file that
556.22 - * accompanied this code. If applicable, add the following below the
556.23 - * License Header, with the fields enclosed by brackets [] replaced by
556.24 - * your own identifying information:
556.25 - * "Portions Copyrighted [year] [name of copyright owner]"
556.26 - *
556.27 - * If you wish your version of this file to be governed by only the CDDL
556.28 - * or only the GPL Version 2, indicate your decision by adding
556.29 - * "[Contributor] elects to include this software in this distribution
556.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
556.31 - * single choice of license, a recipient has the option to distribute
556.32 - * your version of this file under either the CDDL, the GPL Version 2 or
556.33 - * to extend the choice of license to its licensees as provided above.
556.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
556.35 - * Version 2 license, then the option applies only if the new code is
556.36 - * made subject to such option by the copyright holder.
556.37 - *
556.38 - * Contributor(s):
556.39 - *
556.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
556.41 - */
556.42 -
556.43 -package org.netbeans.modules.jackpot30.server.webapi;
556.44 -
556.45 -import freemarker.cache.TemplateLoader;
556.46 -import freemarker.template.Configuration;
556.47 -import freemarker.template.Template;
556.48 -import freemarker.template.TemplateException;
556.49 -import java.io.IOException;
556.50 -import java.io.InputStream;
556.51 -import java.io.InputStreamReader;
556.52 -import java.io.Reader;
556.53 -import java.io.StringWriter;
556.54 -import java.net.URI;
556.55 -import java.net.URISyntaxException;
556.56 -import java.util.ArrayList;
556.57 -import java.util.Collections;
556.58 -import java.util.HashMap;
556.59 -import java.util.LinkedList;
556.60 -import java.util.List;
556.61 -import java.util.Map;
556.62 -import javax.ws.rs.GET;
556.63 -import javax.ws.rs.Path;
556.64 -import javax.ws.rs.Produces;
556.65 -import javax.ws.rs.QueryParam;
556.66 -import org.codeviation.pojson.Pojson;
556.67 -import org.netbeans.modules.jackpot30.remoting.api.WebUtilities;
556.68 -import static org.netbeans.modules.jackpot30.remoting.api.WebUtilities.escapeForQuery;
556.69 -
556.70 -/**
556.71 - *
556.72 - * @author lahvac
556.73 - */
556.74 -@Path("/ui")
556.75 -public class UI {
556.76 -
556.77 - @GET
556.78 - @Path("/search")
556.79 - @Produces("text/html")
556.80 - public String search(@QueryParam("path") String path, @QueryParam("pattern") String pattern) throws URISyntaxException, IOException, TemplateException {
556.81 - Map<String, Object> configurationData = new HashMap<String, Object>();
556.82 -
556.83 - configurationData.put("paths", list());
556.84 - configurationData.put("selectedPath", path);
556.85 - configurationData.put("pattern", pattern);
556.86 - configurationData.put("patternEscaped", escapeForQuery(pattern));
556.87 - configurationData.put("examples", loadExamples());
556.88 -
556.89 - if (pattern != null && path != null) {
556.90 - URI u = new URI("http://localhost:9998/index/find?path=" + escapeForQuery(path) + "&pattern=" + escapeForQuery(pattern));
556.91 - List<Map<String, Object>> results = new LinkedList<Map<String, Object>>();
556.92 - long queryTime = System.currentTimeMillis();
556.93 - List<String> candidates = new ArrayList<String>(WebUtilities.requestStringArrayResponse(u));
556.94 -
556.95 - queryTime = System.currentTimeMillis() - queryTime;
556.96 -
556.97 - Collections.sort(candidates);
556.98 -
556.99 - for (String c : candidates) {
556.100 - Map<String, Object> found = new HashMap<String, Object>(3);
556.101 -
556.102 - found.put("relativePath", c);
556.103 -
556.104 - results.add(found);
556.105 - }
556.106 -
556.107 - configurationData.put("results", results);
556.108 -
556.109 - Map<String, Object> statistics = new HashMap<String, Object>();
556.110 -
556.111 - statistics.put("files", candidates.size());
556.112 - statistics.put("queryTime", queryTime);
556.113 -
556.114 - configurationData.put("statistics", statistics);
556.115 - }
556.116 -
556.117 - return processTemplate("/org/netbeans/modules/jackpot30/server/webapi/ui-search.html", configurationData);
556.118 - }
556.119 -
556.120 - @GET
556.121 - @Path("/show")
556.122 - @Produces("text/html")
556.123 - public String show(@QueryParam("path") String path, @QueryParam("relative") String relativePath, @QueryParam("pattern") String pattern) throws URISyntaxException, IOException, TemplateException {
556.124 - Map<String, Object> configurationData = new HashMap<String, Object>();
556.125 - List<Map<String, String>> occurrences = new LinkedList<Map<String, String>>();
556.126 -
556.127 - configurationData.put("occurrences", occurrences);
556.128 -
556.129 - URI codeURL = new URI("http://localhost:9998/index/cat?path=" + escapeForQuery(path) + "&relative=" + escapeForQuery(relativePath));
556.130 - String code = WebUtilities.requestStringResponse(codeURL);
556.131 - URI spansURL = new URI("http://localhost:9998/index/findSpans?path=" + escapeForQuery(path) + "&relativePath=" + escapeForQuery(relativePath) + "&pattern=" + escapeForQuery(pattern));
556.132 - int currentCodePos = 0;
556.133 - for (int[] span : parseSpans(WebUtilities.requestStringResponse(spansURL))) { //XXX: sorted!
556.134 - Map<String, String> occ = new HashMap<String, String>();
556.135 - occ.put("prefix", WebUtilities.escapeForHTMLElement(code.substring(currentCodePos, span[0])));
556.136 - occ.put("occurrence", WebUtilities.escapeForHTMLElement(code.substring(span[0], span[1])));
556.137 - occurrences.add(occ);
556.138 - currentCodePos = span[1];
556.139 - }
556.140 -
556.141 - configurationData.put("suffix", WebUtilities.escapeForHTMLElement(code.substring(currentCodePos, code.length())));
556.142 -
556.143 - return processTemplate("/org/netbeans/modules/jackpot30/server/webapi/ui-cat.html", configurationData);
556.144 - }
556.145 -
556.146 - @GET
556.147 - @Path("/snippet")
556.148 - @Produces("text/html")
556.149 - public String snippet(@QueryParam("path") String path, @QueryParam("relative") String relativePath, @QueryParam("pattern") String pattern) throws URISyntaxException, IOException, TemplateException {
556.150 - List<Map<String, String>> snippets = new LinkedList<Map<String, String>>();
556.151 -
556.152 - URI codeURL = new URI("http://localhost:9998/index/cat?path=" + escapeForQuery(path) + "&relative=" + escapeForQuery(relativePath));
556.153 - String code = WebUtilities.requestStringResponse(codeURL);
556.154 - URI spansURL = new URI("http://localhost:9998/index/findSpans?path=" + escapeForQuery(path) + "&relativePath=" + escapeForQuery(relativePath) + "&pattern=" + escapeForQuery(pattern));
556.155 -
556.156 - for (int[] span : parseSpans(WebUtilities.requestStringResponse(spansURL))) {
556.157 - snippets.add(prepareSnippet(code, span));
556.158 - }
556.159 -
556.160 - return processTemplate("/org/netbeans/modules/jackpot30/server/webapi/ui-snippet.html", Collections.<String, Object>singletonMap("snippets", snippets));
556.161 - }
556.162 -
556.163 - private static List<Map<String, String>> list() throws URISyntaxException {
556.164 - List<Map<String, String>> result = new LinkedList<Map<String, String>>();
556.165 -
556.166 - for (String enc : WebUtilities.requestStringArrayResponse(new URI("http://localhost:9998/index/list"))) {
556.167 - Map<String, String> rootDesc = new HashMap<String, String>();
556.168 - String[] col = enc.split(":", 2);
556.169 -
556.170 - rootDesc.put("segment", col[0]);
556.171 - rootDesc.put("displayName", col[1]);
556.172 - result.add(rootDesc);
556.173 - }
556.174 -
556.175 - return result;
556.176 - }
556.177 -
556.178 - private static Iterable<int[]> parseSpans(String from) {
556.179 - if (from.isEmpty()) {
556.180 - return Collections.emptyList();
556.181 - }
556.182 - String[] split = from.split(":");
556.183 - List<int[]> result = new LinkedList<int[]>();
556.184 -
556.185 - for (int i = 0; i < split.length; i += 2) {
556.186 - result.add(new int[] {
556.187 - Integer.parseInt(split[i + 0].trim()),
556.188 - Integer.parseInt(split[i + 1].trim())
556.189 - });
556.190 - }
556.191 -
556.192 - return result;
556.193 - }
556.194 -
556.195 - private static final int DESIRED_CONTEXT = 2;
556.196 -
556.197 - private static Map<String, String> prepareSnippet(String code, int[] span) {
556.198 - int grandStart = span[0];
556.199 - int firstLineStart = grandStart = lineStart(code, grandStart);
556.200 -
556.201 - while (grandStart > 0 && contextLength(code.substring(grandStart, firstLineStart)) < DESIRED_CONTEXT)
556.202 - grandStart = lineStart(code, grandStart - 1);
556.203 -
556.204 - int grandEnd = span[1];
556.205 - int firstLineEnd = grandEnd = lineEnd(code, grandEnd);
556.206 -
556.207 - while (grandEnd < code.length() - 1 && contextLength(code.substring(firstLineEnd, grandEnd)) < DESIRED_CONTEXT)
556.208 - grandEnd = lineEnd(code, grandEnd + 1);
556.209 -
556.210 - Map<String, String> result = new HashMap<String, String>();
556.211 -
556.212 - result.put("prefix", WebUtilities.escapeForHTMLElement(code.substring(grandStart, span[0])));
556.213 - result.put("occurrence", WebUtilities.escapeForHTMLElement(code.substring(span[0], span[1])));
556.214 - result.put("suffix", WebUtilities.escapeForHTMLElement(code.substring(span[1], grandEnd)));
556.215 -
556.216 - return result;
556.217 - }
556.218 -
556.219 - private static int lineStart(String code, int o) {
556.220 - while (o > 0 && code.charAt(o) != '\n') {
556.221 - o--;
556.222 - }
556.223 -
556.224 - return o;
556.225 - }
556.226 -
556.227 - private static int lineEnd(String code, int o) {
556.228 - while (o < code.length() - 1 && code.charAt(o) != '\n') {
556.229 - o++;
556.230 - }
556.231 -
556.232 - return o;
556.233 - }
556.234 -
556.235 - private static int contextLength(String in) {
556.236 - return in.replaceAll("\n[ \t]*\n", "\n").trim().split("\n").length;
556.237 - }
556.238 -
556.239 - @SuppressWarnings("unchecked")
556.240 - private List<Map<String, String>> loadExamples() throws IOException, URISyntaxException {
556.241 - return Pojson.load(LinkedList.class, new URI("http://localhost:9998/index/examples"));
556.242 - }
556.243 -
556.244 - private static String processTemplate(String template, Map<String, Object> configurationData) throws TemplateException, IOException {
556.245 - Configuration conf = new Configuration();
556.246 -
556.247 - conf.setTemplateLoader(new TemplateLoaderImpl());
556.248 -
556.249 - Template templ = conf.getTemplate(template);
556.250 - StringWriter out = new StringWriter();
556.251 -
556.252 - templ.process(configurationData, out);
556.253 -
556.254 - return out.toString();
556.255 - }
556.256 -
556.257 - private static final class TemplateLoaderImpl implements TemplateLoader {
556.258 -
556.259 - public Object findTemplateSource(String name) throws IOException {
556.260 - return TemplateLoaderImpl.class.getResourceAsStream("/" + name);
556.261 - }
556.262 -
556.263 - public long getLastModified(Object templateSource) {
556.264 - return 0L;
556.265 - }
556.266 -
556.267 - public Reader getReader(Object templateSource, String encoding) throws IOException {
556.268 - InputStream in = (InputStream) templateSource;
556.269 -
556.270 - return new InputStreamReader(in);
556.271 - }
556.272 -
556.273 - public void closeTemplateSource(Object templateSource) throws IOException {
556.274 - }
556.275 - }
556.276 -
556.277 -}
557.1 --- a/server/web.api/src/org/netbeans/modules/jackpot30/server/webapi/ui-cat.html Fri Jan 27 13:35:56 2012 +0100
557.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
557.3 @@ -1,10 +0,0 @@
557.4 -<html>
557.5 -<head>
557.6 - <style type="text/css">
557.7 - .occurrence {BACKGROUND: #DDDD00;}
557.8 - </style>
557.9 -</head>
557.10 -<body>
557.11 -<pre><#list occurrences as occurrence>${occurrence.prefix}<span class="occurrence">${occurrence.occurrence}</span></#list>${suffix}</pre>
557.12 -</body>
557.13 -</html>
558.1 --- a/server/web.api/src/org/netbeans/modules/jackpot30/server/webapi/ui-search.html Fri Jan 27 13:35:56 2012 +0100
558.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
558.3 @@ -1,70 +0,0 @@
558.4 -<html>
558.5 -<head>
558.6 - <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
558.7 -<#if results??>
558.8 - <script type="text/javascript">
558.9 - $(document).ready(function() {
558.10 - $('#list').find('dd').hide().end().find('dt').click(function() {
558.11 - current_dd=$(this).next();
558.12 - //XXX: will do the AJAX call for both show and hide!
558.13 - $.get("snippet?path=${selectedPath}&relative=" + current_dd.attr("id") + "&pattern=${patternEscaped}",function(data) {
558.14 - current_dd.html(data).slideToggle();
558.15 - })
558.16 - });
558.17 - });
558.18 - </script>
558.19 -</#if>
558.20 - <style type="text/css">
558.21 - .occurrence {BACKGROUND: #DDDD00;}
558.22 - </style>
558.23 -</head>
558.24 -<body>
558.25 -<form method="get">
558.26 -
558.27 -<label for="path">Project:</label>
558.28 -<select size="1" name="path">");
558.29 - <#list paths as path>
558.30 - <option <#if selectedPath?? && path.segment == selectedPath>selected</#if> value="${path.segment}">
558.31 - ${path.displayName}
558.32 - </option>
558.33 - </#list>
558.34 -</select>
558.35 -<br>
558.36 -<label for="pattern">Pattern:</label><br>
558.37 -<textarea rows="10" cols="40" name="pattern">
558.38 -<#if pattern??>
558.39 -${pattern}
558.40 -</#if>
558.41 -</textarea><br>
558.42 -<input type="submit" name="Find Candidates"/>
558.43 -</form>
558.44 -
558.45 -<div class="examples">
558.46 -<#if examples??>
558.47 - Examples:
558.48 - <dl id="examples-list">
558.49 - <#list examples as example>
558.50 - <dt>${example.displayName}</dt>
558.51 - <dd><pre>${example.pattern}</pre>
558.52 - </dd>
558.53 - </#list>
558.54 - </dl>
558.55 -</#if>
558.56 -</div>
558.57 -
558.58 -<#if results??>
558.59 - Found candidates for pattern: ${pattern}
558.60 - <dl id="list">
558.61 - <#list results as result>
558.62 - <dt>${result.relativePath}<a href="/index/ui/show?path=${selectedPath}&relative=${result.relativePath}&pattern=${patternEscaped}">show</a></dt>
558.63 - <dd id="${result.relativePath}">
558.64 - </dd>
558.65 - </#list>
558.66 - </dl>
558.67 -</#if>
558.68 -
558.69 -<#if statistics??>
558.70 - Query time: ${statistics.queryTime}ms, matching files: ${statistics.files}.
558.71 -</#if>
558.72 -</body>
558.73 -</html>
559.1 --- a/server/web.api/src/org/netbeans/modules/jackpot30/server/webapi/ui-snippet.html Fri Jan 27 13:35:56 2012 +0100
559.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
559.3 @@ -1,7 +0,0 @@
559.4 -<#if snippets??>
559.5 - <#list snippets as snippet>
559.6 - <pre>${snippet.prefix}<span class="occurrence">${snippet.occurrence}</span>${snippet.suffix}</pre><br>
559.7 - </#list>
559.8 -<#else>
559.9 - No occurrences.
559.10 -</#if>
560.1 --- a/server/web.api/test/org/netbeans/modules/jackpot30/server/webapi/APITest.java Fri Jan 27 13:35:56 2012 +0100
560.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
560.3 @@ -1,107 +0,0 @@
560.4 -/*
560.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
560.6 - *
560.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
560.8 - *
560.9 - * The contents of this file are subject to the terms of either the GNU
560.10 - * General Public License Version 2 only ("GPL") or the Common
560.11 - * Development and Distribution License("CDDL") (collectively, the
560.12 - * "License"). You may not use this file except in compliance with the
560.13 - * License. You can obtain a copy of the License at
560.14 - * http://www.netbeans.org/cddl-gplv2.html
560.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
560.16 - * specific language governing permissions and limitations under the
560.17 - * License. When distributing the software, include this License Header
560.18 - * Notice in each file and include the License file at
560.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
560.20 - * particular file as subject to the "Classpath" exception as provided
560.21 - * by Sun in the GPL Version 2 section of the License file that
560.22 - * accompanied this code. If applicable, add the following below the
560.23 - * License Header, with the fields enclosed by brackets [] replaced by
560.24 - * your own identifying information:
560.25 - * "Portions Copyrighted [year] [name of copyright owner]"
560.26 - *
560.27 - * If you wish your version of this file to be governed by only the CDDL
560.28 - * or only the GPL Version 2, indicate your decision by adding
560.29 - * "[Contributor] elects to include this software in this distribution
560.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
560.31 - * single choice of license, a recipient has the option to distribute
560.32 - * your version of this file under either the CDDL, the GPL Version 2 or
560.33 - * to extend the choice of license to its licensees as provided above.
560.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
560.35 - * Version 2 license, then the option applies only if the new code is
560.36 - * made subject to such option by the copyright holder.
560.37 - *
560.38 - * Contributor(s):
560.39 - *
560.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
560.41 - */
560.42 -
560.43 -package org.netbeans.modules.jackpot30.server.webapi;
560.44 -
560.45 -import java.io.ByteArrayInputStream;
560.46 -import java.io.File;
560.47 -import java.io.FileOutputStream;
560.48 -import java.io.InputStream;
560.49 -import org.junit.Assert;
560.50 -import org.junit.Before;
560.51 -import org.junit.Test;
560.52 -import org.netbeans.modules.jackpot30.impl.indexing.Cache;
560.53 -import org.netbeans.modules.jackpot30.server.indexer.StandaloneIndexer;
560.54 -
560.55 -/**
560.56 - *
560.57 - * @author lahvac
560.58 - */
560.59 -public class APITest {
560.60 -
560.61 - public APITest() {
560.62 - }
560.63 -
560.64 - private File src;
560.65 -
560.66 - @Before
560.67 - public void setUp() throws Exception {
560.68 - File source = new File(APITest.class.getProtectionDomain().getCodeSource().getLocation().getPath());
560.69 - File workingDirectory = new File(source.getParentFile(), "wd");
560.70 - File cache = new File(workingDirectory, "cache");
560.71 -
560.72 - src = new File(workingDirectory, "src");
560.73 -
560.74 - Cache.setStandaloneCacheRoot(cache);
560.75 -
560.76 - copyStringToFile(new File(src, "test/Test1.java"), "package test; public class Test {private void test() { new java.io.File(\"\").isDirectory(); } }");
560.77 -
560.78 - StandaloneIndexer.index(src, false, false, null, null);
560.79 - }
560.80 -
560.81 - public final static void copyStringToFile (File f, String content) throws Exception {
560.82 - f.getParentFile().mkdirs();
560.83 -
560.84 - FileOutputStream os = new FileOutputStream(f);
560.85 - InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
560.86 - int read;
560.87 - while ((read = is.read()) != (-1)) {
560.88 - os.write(read);
560.89 - }
560.90 - os.close ();
560.91 - is.close();
560.92 - }
560.93 -
560.94 - @Test
560.95 - public void testFind() throws Exception {
560.96 - String cacheKey = null;
560.97 -
560.98 - for (String key : Cache.knownSourceRoots()) {
560.99 - if (src.getAbsolutePath().equals(Cache.sourceRootForKey(key).getAbsolutePath())) {
560.100 - cacheKey = key;
560.101 - break;
560.102 - }
560.103 - }
560.104 -
560.105 - Assert.assertNotNull(cacheKey);
560.106 -
560.107 - Assert.assertEquals("test/Test1.java\n", new API().find(cacheKey, "$1.isDirectory()"));
560.108 - }
560.109 -
560.110 -}
560.111 \ No newline at end of file
561.1 --- a/transformer/build.xml Fri Jan 27 13:35:56 2012 +0100
561.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
561.3 @@ -1,9 +0,0 @@
561.4 -<?xml version="1.0" encoding="UTF-8"?>
561.5 -<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
561.6 -<!-- for some information on what you could do (e.g. targets to override). -->
561.7 -<!-- If you delete this file and reopen the project it will be recreated. -->
561.8 -<project name="org.netbeans.modules.jackpot30.transformers" default="netbeans" basedir=".">
561.9 - <description>Builds, tests, and runs the project org.netbeans.modules.jackpot30.transformers.</description>
561.10 - <import file="nbproject/build-impl.xml"/>
561.11 - <import file="${suite.dir}/findbugs-import.xml"/>
561.12 -</project>
562.1 --- a/transformer/manifest.mf Fri Jan 27 13:35:56 2012 +0100
562.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
562.3 @@ -1,7 +0,0 @@
562.4 -Manifest-Version: 1.0
562.5 -AutoUpdate-Show-In-Client: false
562.6 -OpenIDE-Module: org.netbeans.modules.jackpot30.transformers
562.7 -OpenIDE-Module-Layer: org/netbeans/modules/jackpot30/transformers/resources/layer.xml
562.8 -OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jackpot30/transformers/resources/Bundle.properties
562.9 -OpenIDE-Module-Specification-Version: 1.16
562.10 -
563.1 --- a/transformer/nbproject/build-impl.xml Fri Jan 27 13:35:56 2012 +0100
563.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
563.3 @@ -1,45 +0,0 @@
563.4 -<?xml version="1.0" encoding="UTF-8"?>
563.5 -<!--
563.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
563.7 -*** EDIT ../build.xml INSTEAD ***
563.8 --->
563.9 -<project name="org.netbeans.modules.jackpot30.transformers-impl" basedir="..">
563.10 - <fail message="Please build using Ant 1.7.1 or higher.">
563.11 - <condition>
563.12 - <not>
563.13 - <antversion atleast="1.7.1"/>
563.14 - </not>
563.15 - </condition>
563.16 - </fail>
563.17 - <property file="nbproject/private/suite-private.properties"/>
563.18 - <property file="nbproject/suite.properties"/>
563.19 - <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
563.20 - <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
563.21 - <property file="${suite.dir}/nbproject/platform.properties"/>
563.22 - <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
563.23 - <attribute name="name"/>
563.24 - <attribute name="value"/>
563.25 - <sequential>
563.26 - <property name="@{name}" value="${@{value}}"/>
563.27 - </sequential>
563.28 - </macrodef>
563.29 - <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
563.30 - <attribute name="property"/>
563.31 - <attribute name="value"/>
563.32 - <sequential>
563.33 - <property name="@{property}" value="@{value}"/>
563.34 - </sequential>
563.35 - </macrodef>
563.36 - <property file="${user.properties.file}"/>
563.37 - <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
563.38 - <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
563.39 - <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
563.40 - <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
563.41 - <condition>
563.42 - <not>
563.43 - <contains string="${cluster.path.evaluated}" substring="platform"/>
563.44 - </not>
563.45 - </condition>
563.46 - </fail>
563.47 - <import file="${harness.dir}/build.xml"/>
563.48 -</project>
564.1 --- a/transformer/nbproject/genfiles.properties Fri Jan 27 13:35:56 2012 +0100
564.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
564.3 @@ -1,8 +0,0 @@
564.4 -build.xml.data.CRC32=ec1a83f8
564.5 -build.xml.script.CRC32=14b2fe09
564.6 -build.xml.stylesheet.CRC32=79c3b980@1.28.0.7
564.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
564.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
564.9 -nbproject/build-impl.xml.data.CRC32=9e6fb388
564.10 -nbproject/build-impl.xml.script.CRC32=07a96417
564.11 -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.47
565.1 --- a/transformer/nbproject/project.properties Fri Jan 27 13:35:56 2012 +0100
565.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
565.3 @@ -1,2 +0,0 @@
565.4 -javac.source=1.5
565.5 -javac.compilerargs=-Xlint -Xlint:-serial
566.1 --- a/transformer/nbproject/project.xml Fri Jan 27 13:35:56 2012 +0100
566.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
566.3 @@ -1,157 +0,0 @@
566.4 -<?xml version="1.0" encoding="UTF-8"?>
566.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
566.6 - <type>org.netbeans.modules.apisupport.project</type>
566.7 - <configuration>
566.8 - <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
566.9 - <code-name-base>org.netbeans.modules.jackpot30.transformers</code-name-base>
566.10 - <suite-component/>
566.11 - <module-dependencies>
566.12 - <dependency>
566.13 - <code-name-base>org.netbeans.api.java.classpath</code-name-base>
566.14 - <build-prerequisite/>
566.15 - <compile-dependency/>
566.16 - <run-dependency>
566.17 - <release-version>1</release-version>
566.18 - <specification-version>1.19</specification-version>
566.19 - </run-dependency>
566.20 - </dependency>
566.21 - <dependency>
566.22 - <code-name-base>org.netbeans.libs.javacapi</code-name-base>
566.23 - <build-prerequisite/>
566.24 - <compile-dependency/>
566.25 - <run-dependency>
566.26 - <specification-version>0.8.0.1</specification-version>
566.27 - </run-dependency>
566.28 - </dependency>
566.29 - <dependency>
566.30 - <code-name-base>org.netbeans.modules.jackpot30.api</code-name-base>
566.31 - <build-prerequisite/>
566.32 - <compile-dependency/>
566.33 - <run-dependency>
566.34 - <specification-version>1.0</specification-version>
566.35 - </run-dependency>
566.36 - </dependency>
566.37 - <dependency>
566.38 - <code-name-base>org.netbeans.modules.java.hints</code-name-base>
566.39 - <build-prerequisite/>
566.40 - <compile-dependency/>
566.41 - <run-dependency>
566.42 - <release-version>1</release-version>
566.43 - <implementation-version/>
566.44 - </run-dependency>
566.45 - </dependency>
566.46 - <dependency>
566.47 - <code-name-base>org.netbeans.modules.java.source</code-name-base>
566.48 - <build-prerequisite/>
566.49 - <compile-dependency/>
566.50 - <run-dependency>
566.51 - <specification-version>0.43.0.7.7.1</specification-version>
566.52 - </run-dependency>
566.53 - </dependency>
566.54 - <dependency>
566.55 - <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
566.56 - <build-prerequisite/>
566.57 - <compile-dependency/>
566.58 - <run-dependency>
566.59 - <release-version>0-1</release-version>
566.60 - <specification-version>1.7.0.7.2</specification-version>
566.61 - </run-dependency>
566.62 - </dependency>
566.63 - <dependency>
566.64 - <code-name-base>org.openide.filesystems</code-name-base>
566.65 - <build-prerequisite/>
566.66 - <compile-dependency/>
566.67 - <run-dependency>
566.68 - <specification-version>7.21.0.1.1</specification-version>
566.69 - </run-dependency>
566.70 - </dependency>
566.71 - <dependency>
566.72 - <code-name-base>org.openide.modules</code-name-base>
566.73 - <build-prerequisite/>
566.74 - <compile-dependency/>
566.75 - <run-dependency>
566.76 - <specification-version>7.10</specification-version>
566.77 - </run-dependency>
566.78 - </dependency>
566.79 - <dependency>
566.80 - <code-name-base>org.openide.util</code-name-base>
566.81 - <build-prerequisite/>
566.82 - <compile-dependency/>
566.83 - <run-dependency>
566.84 - <specification-version>7.22.0.1</specification-version>
566.85 - </run-dependency>
566.86 - </dependency>
566.87 - <dependency>
566.88 - <code-name-base>org.openide.util.lookup</code-name-base>
566.89 - <build-prerequisite/>
566.90 - <compile-dependency/>
566.91 - <run-dependency>
566.92 - <specification-version>8.0.0.1</specification-version>
566.93 - </run-dependency>
566.94 - </dependency>
566.95 - </module-dependencies>
566.96 - <test-dependencies>
566.97 - <test-type>
566.98 - <name>unit</name>
566.99 - <test-dependency>
566.100 - <code-name-base>org.netbeans.bootstrap</code-name-base>
566.101 - </test-dependency>
566.102 - <test-dependency>
566.103 - <code-name-base>org.netbeans.core.startup</code-name-base>
566.104 - </test-dependency>
566.105 - <test-dependency>
566.106 - <code-name-base>org.netbeans.libs.junit4</code-name-base>
566.107 - <compile-dependency/>
566.108 - </test-dependency>
566.109 - <test-dependency>
566.110 - <code-name-base>org.netbeans.modules.classfile</code-name-base>
566.111 - </test-dependency>
566.112 - <test-dependency>
566.113 - <code-name-base>org.netbeans.modules.defaults</code-name-base>
566.114 - </test-dependency>
566.115 - <test-dependency>
566.116 - <code-name-base>org.netbeans.modules.editor</code-name-base>
566.117 - </test-dependency>
566.118 - <test-dependency>
566.119 - <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
566.120 - </test-dependency>
566.121 - <test-dependency>
566.122 - <code-name-base>org.netbeans.modules.editor.settings</code-name-base>
566.123 - </test-dependency>
566.124 - <test-dependency>
566.125 - <code-name-base>org.netbeans.modules.editor.settings.storage</code-name-base>
566.126 - </test-dependency>
566.127 - <test-dependency>
566.128 - <code-name-base>org.netbeans.modules.editor.util</code-name-base>
566.129 - </test-dependency>
566.130 - <test-dependency>
566.131 - <code-name-base>org.netbeans.modules.jackpot30.test.borrowed</code-name-base>
566.132 - <recursive/>
566.133 - <compile-dependency/>
566.134 - </test-dependency>
566.135 - <test-dependency>
566.136 - <code-name-base>org.netbeans.modules.java.lexer</code-name-base>
566.137 - </test-dependency>
566.138 - <test-dependency>
566.139 - <code-name-base>org.netbeans.modules.masterfs</code-name-base>
566.140 - </test-dependency>
566.141 - <test-dependency>
566.142 - <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
566.143 - <recursive/>
566.144 - <compile-dependency/>
566.145 - </test-dependency>
566.146 - <test-dependency>
566.147 - <code-name-base>org.netbeans.modules.progress.ui</code-name-base>
566.148 - </test-dependency>
566.149 - <test-dependency>
566.150 - <code-name-base>org.netbeans.modules.projectui</code-name-base>
566.151 - </test-dependency>
566.152 - <test-dependency>
566.153 - <code-name-base>org.openidex.util</code-name-base>
566.154 - </test-dependency>
566.155 - </test-type>
566.156 - </test-dependencies>
566.157 - <public-packages/>
566.158 - </data>
566.159 - </configuration>
566.160 -</project>
567.1 --- a/transformer/nbproject/suite.properties Fri Jan 27 13:35:56 2012 +0100
567.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
567.3 @@ -1,1 +0,0 @@
567.4 -suite.dir=${basedir}/..
568.1 Binary file transformer/release/libs/annotations.jar has changed
569.1 --- a/transformer/src/org/netbeans/modules/jackpot30/transformers/Annotations.java Fri Jan 27 13:35:56 2012 +0100
569.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
569.3 @@ -1,70 +0,0 @@
569.4 -/*
569.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
569.6 - *
569.7 - * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
569.8 - *
569.9 - * The contents of this file are subject to the terms of either the GNU
569.10 - * General Public License Version 2 only ("GPL") or the Common
569.11 - * Development and Distribution License("CDDL") (collectively, the
569.12 - * "License"). You may not use this file except in compliance with the
569.13 - * License. You can obtain a copy of the License at
569.14 - * http://www.netbeans.org/cddl-gplv2.html
569.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
569.16 - * specific language governing permissions and limitations under the
569.17 - * License. When distributing the software, include this License Header
569.18 - * Notice in each file and include the License file at
569.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
569.20 - * particular file as subject to the "Classpath" exception as provided
569.21 - * by Sun in the GPL Version 2 section of the License file that
569.22 - * accompanied this code. If applicable, add the following below the
569.23 - * License Header, with the fields enclosed by brackets [] replaced by
569.24 - * your own identifying information:
569.25 - * "Portions Copyrighted [year] [name of copyright owner]"
569.26 - *
569.27 - * If you wish your version of this file to be governed by only the CDDL
569.28 - * or only the GPL Version 2, indicate your decision by adding
569.29 - * "[Contributor] elects to include this software in this distribution
569.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
569.31 - * single choice of license, a recipient has the option to distribute
569.32 - * your version of this file under either the CDDL, the GPL Version 2 or
569.33 - * to extend the choice of license to its licensees as provided above.
569.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
569.35 - * Version 2 license, then the option applies only if the new code is
569.36 - * made subject to such option by the copyright holder.
569.37 - *
569.38 - * Contributor(s):
569.39 - *
569.40 - * Portions Copyrighted 2008-2009 Sun Microsystems, Inc.
569.41 - */
569.42 -
569.43 -package org.netbeans.modules.jackpot30.transformers;
569.44 -
569.45 -/**
569.46 - *
569.47 - * @author Jan Lahoda
569.48 - */
569.49 -public enum Annotations {
569.50 -
569.51 - TRANSFORMATION_SET("TransformationSet"),
569.52 - TRANSFORMATION,
569.53 - FIX,
569.54 - PATTERN,
569.55 - CONSTRAINT;
569.56 -
569.57 - private static final String PACKAGE_NAME = "net.java.lang.annotations.";
569.58 -
569.59 - private final String specialName;
569.60 -
569.61 - private Annotations() {
569.62 - this(null);
569.63 - }
569.64 -
569.65 - private Annotations(String specialName) {
569.66 - this.specialName = specialName;
569.67 - }
569.68 -
569.69 - public String toFQN() {
569.70 - return PACKAGE_NAME + (specialName != null ? specialName : name().charAt(0) + name().substring(1).toLowerCase());
569.71 - }
569.72 -
569.73 -}
570.1 --- a/transformer/src/org/netbeans/modules/jackpot30/transformers/TransformationHintProviderImpl.java Fri Jan 27 13:35:56 2012 +0100
570.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
570.3 @@ -1,508 +0,0 @@
570.4 -/*
570.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
570.6 - *
570.7 - * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
570.8 - *
570.9 - * The contents of this file are subject to the terms of either the GNU
570.10 - * General Public License Version 2 only ("GPL") or the Common
570.11 - * Development and Distribution License("CDDL") (collectively, the
570.12 - * "License"). You may not use this file except in compliance with the
570.13 - * License. You can obtain a copy of the License at
570.14 - * http://www.netbeans.org/cddl-gplv2.html
570.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
570.16 - * specific language governing permissions and limitations under the
570.17 - * License. When distributing the software, include this License Header
570.18 - * Notice in each file and include the License file at
570.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
570.20 - * particular file as subject to the "Classpath" exception as provided
570.21 - * by Sun in the GPL Version 2 section of the License file that
570.22 - * accompanied this code. If applicable, add the following below the
570.23 - * License Header, with the fields enclosed by brackets [] replaced bysanno
570.24 - * your own identifying information:
570.25 - * "Portions Copyrighted [year] [name of copyright owner]"
570.26 - *
570.27 - * If you wish your version of this file to be governed by only the CDDL
570.28 - * or only the GPL Version 2, indicate your decision by adding
570.29 - * "[Contributor] elects to include this software in this distribution
570.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
570.31 - * single choice of license, a recipient has the option to distribute
570.32 - * your version of this file under either the CDDL, the GPL Version 2 or
570.33 - * to extend the choice of license to its licensees as provided above.
570.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
570.35 - * Version 2 license, then the option applies only if the new code is
570.36 - * made subject to such option by the copyright holder.
570.37 - *
570.38 - * Contributor(s):
570.39 - *
570.40 - * Portions Copyrighted 2008-2009 Sun Microsystems, Inc.
570.41 - */
570.42 -
570.43 -package org.netbeans.modules.jackpot30.transformers;
570.44 -
570.45 -import org.netbeans.modules.java.hints.jackpot.spi.Trigger.PatternDescription;
570.46 -import org.netbeans.modules.java.hints.spi.AbstractHint.HintSeverity;
570.47 -import org.netbeans.modules.java.hints.jackpot.spi.support.ErrorDescriptionFactory;
570.48 -import org.netbeans.modules.java.hints.jackpot.spi.ElementBasedHintProvider;
570.49 -import org.netbeans.modules.java.hints.jackpot.spi.HintContext;
570.50 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
570.51 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription.Worker;
570.52 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescriptionFactory;
570.53 -import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata;
570.54 -import org.netbeans.modules.java.hints.jackpot.spi.JavaFix;
570.55 -import com.sun.source.tree.Tree;
570.56 -import com.sun.source.util.SourcePositions;
570.57 -import com.sun.source.util.TreePath;
570.58 -import java.io.File;
570.59 -import java.io.IOException;
570.60 -import java.net.URL;
570.61 -import java.util.Collection;
570.62 -import java.util.Collections;
570.63 -import java.util.EnumSet;
570.64 -import java.util.HashMap;
570.65 -import java.util.HashSet;
570.66 -import java.util.LinkedList;
570.67 -import java.util.List;
570.68 -import java.util.Map;
570.69 -import java.util.Map.Entry;
570.70 -import java.util.Set;
570.71 -import java.util.concurrent.atomic.AtomicBoolean;
570.72 -import java.util.regex.Matcher;
570.73 -import javax.lang.model.element.AnnotationMirror;
570.74 -import javax.lang.model.element.AnnotationValue;
570.75 -import javax.lang.model.element.Element;
570.76 -import javax.lang.model.element.ElementKind;
570.77 -import javax.lang.model.element.ExecutableElement;
570.78 -import javax.lang.model.element.Modifier;
570.79 -import javax.lang.model.element.PackageElement;
570.80 -import javax.lang.model.element.TypeElement;
570.81 -import javax.lang.model.type.DeclaredType;
570.82 -import javax.lang.model.type.TypeMirror;
570.83 -import javax.lang.model.util.ElementFilter;
570.84 -import org.netbeans.api.java.classpath.ClassPath;
570.85 -import org.netbeans.api.java.source.ClasspathInfo;
570.86 -import org.netbeans.api.java.source.ClasspathInfo.PathKind;
570.87 -import org.netbeans.api.java.source.CompilationController;
570.88 -import org.netbeans.api.java.source.CompilationInfo;
570.89 -import org.netbeans.api.java.source.ElementHandle;
570.90 -import org.netbeans.api.java.source.JavaSource;
570.91 -import org.netbeans.api.java.source.Task;
570.92 -import org.netbeans.api.java.source.TypeMirrorHandle;
570.93 -import org.netbeans.api.java.source.support.CancellableTreePathScanner;
570.94 -import org.netbeans.spi.editor.hints.ErrorDescription;
570.95 -import org.netbeans.spi.editor.hints.Fix;
570.96 -import org.netbeans.spi.java.classpath.support.ClassPathSupport;
570.97 -import org.openide.filesystems.FileUtil;
570.98 -import org.openide.modules.InstalledFileLocator;
570.99 -import org.openide.util.Exceptions;
570.100 -
570.101 -import org.openide.util.lookup.ServiceProvider;
570.102 -import static org.netbeans.modules.jackpot30.transformers.Annotations.*;
570.103 -
570.104 -/**
570.105 - *
570.106 - * @author Jan Lahoda
570.107 - */
570.108 -@ServiceProvider(service=ElementBasedHintProvider.class)
570.109 -public class TransformationHintProviderImpl implements ElementBasedHintProvider {
570.110 -
570.111 - private JavaSource prepareJavaSource(CompilationInfo info) {
570.112 - ClasspathInfo currentCP = info.getClasspathInfo();
570.113 - ClassPath overlayCompileCP = prepareOverlayCompileCP();
570.114 - ClassPath extendedCompileCP = ClassPathSupport.createProxyClassPath(overlayCompileCP, currentCP.getClassPath(PathKind.COMPILE));
570.115 - ClassPath overlayBootCP = prepareOverlayBootCP();
570.116 - ClassPath extendedBootCP = ClassPathSupport.createProxyClassPath(overlayBootCP, currentCP.getClassPath(PathKind.BOOT));
570.117 - ClasspathInfo extendedCPInfo = ClasspathInfo.create(extendedBootCP, extendedCompileCP, currentCP.getClassPath(PathKind.SOURCE));
570.118 -
570.119 - return JavaSource.create(extendedCPInfo);
570.120 - }
570.121 -
570.122 - public Collection<? extends HintDescription> computeHints(final CompilationInfo info) {
570.123 - final List<HintDescription> hints = new LinkedList<HintDescription>();
570.124 -
570.125 - if (ANNOTATIONS_JAR != null && (JDK_OVERLAY_JAR != null || NB_OVERLAY_JAR != null)) {
570.126 - try {
570.127 - prepareJavaSource(info).runUserActionTask(new Task<CompilationController>() {
570.128 - public void run(final CompilationController overlayInfo) throws Exception {
570.129 - List<HintDescription> w = doComputeHints(info, overlayInfo);
570.130 -
570.131 - if (w != null) {
570.132 - hints.addAll(w);
570.133 - }
570.134 - }
570.135 - }, true);
570.136 - } catch (IOException ex) {
570.137 - Exceptions.printStackTrace(ex);
570.138 - }
570.139 - } else {
570.140 - List<HintDescription> w = doComputeHints(info, null);
570.141 -
570.142 - if (w != null) {
570.143 - hints.addAll(w);
570.144 - }
570.145 - }
570.146 -
570.147 - return hints;
570.148 - }
570.149 -
570.150 - private static final Set<ElementKind> KINDS_FOR_ELEMENT_HANDLE = EnumSet.of(
570.151 - ElementKind.PACKAGE, ElementKind.CLASS, ElementKind.INTERFACE, ElementKind.ENUM,
570.152 - ElementKind.ANNOTATION_TYPE, ElementKind.METHOD, ElementKind.CONSTRUCTOR,
570.153 - ElementKind.INSTANCE_INIT, ElementKind.STATIC_INIT, ElementKind.FIELD,
570.154 - ElementKind.ENUM_CONSTANT);
570.155 -
570.156 - private List<HintDescription> doComputeHints(CompilationInfo info,
570.157 - CompilationInfo overlayInfo) {
570.158 -
570.159 - FindAnnotation ann = new FindAnnotation(info, overlayInfo, /*XXX*/new AtomicBoolean());
570.160 -
570.161 - ann.scan(info.getCompilationUnit(), null);
570.162 -
570.163 - return ann.hints;
570.164 - }
570.165 -
570.166 - private final class FindAnnotation extends CancellableTreePathScanner<Void, Void> {
570.167 -
570.168 - private final CompilationInfo info;
570.169 - private final CompilationInfo overlayInfo;
570.170 - private final List<HintDescription> hints = new LinkedList<HintDescription>();
570.171 -
570.172 - public FindAnnotation(CompilationInfo info, CompilationInfo overlayInfo, AtomicBoolean cancel) {
570.173 - super(cancel);
570.174 - this.info = info;
570.175 - this.overlayInfo = overlayInfo;
570.176 - }
570.177 -
570.178 - private final Set<Element> handledElements = new HashSet<Element>();
570.179 -
570.180 - private void handleElementImpl(Element el) {
570.181 - if (!handledElements.add(el)) return ;
570.182 -
570.183 - List<HintDescription> currentHints = processAnnotations(el, el.getEnclosingElement(), info, info);
570.184 -
570.185 - if (overlayInfo != null && currentHints.isEmpty() && KINDS_FOR_ELEMENT_HANDLE.contains(el.getKind())) {
570.186 - Element overlay = ElementHandle.create(el).resolve(overlayInfo);
570.187 -
570.188 - if (overlay != null) {
570.189 - currentHints = processAnnotations(overlay, overlay.getEnclosingElement(), info, overlayInfo);
570.190 - }
570.191 - }
570.192 -
570.193 - this.hints.addAll(currentHints);
570.194 - }
570.195 -
570.196 - private void handleElement(Element el) {
570.197 - PackageElement p = info.getElements().getPackageOf(el);
570.198 -
570.199 - while (p != el) {
570.200 - handleElementImpl(el);
570.201 - el = el.getEnclosingElement();
570.202 - }
570.203 -
570.204 - handleElementImpl(p);
570.205 - }
570.206 -
570.207 - @Override
570.208 - public Void scan(Tree tree, Void p) {
570.209 - if (tree == null) return null;
570.210 -
570.211 - TreePath tp = new TreePath(getCurrentPath(), tree);
570.212 - Element el = info.getTrees().getElement(tp);
570.213 -
570.214 - if (el != null) {
570.215 - handleElement(el);
570.216 - }
570.217 -
570.218 - return super.scan(tree, p);
570.219 - }
570.220 - }
570.221 -
570.222 - private static final class WorkerImpl implements Worker {
570.223 -
570.224 - private final String displayName;
570.225 - private final List<FixDescription> fixDescriptions;
570.226 -
570.227 - public WorkerImpl(String displayName, List<FixDescription> fixDescriptions) {
570.228 - this.displayName = displayName;
570.229 - this.fixDescriptions = fixDescriptions;
570.230 - }
570.231 -
570.232 - public Collection<? extends ErrorDescription> createErrors(HintContext ctx) {
570.233 - //XXX: antipatterns not supported by the current infrastructure
570.234 -// TreePath tp = treePath;
570.235 -//
570.236 -// while (tp != null) {
570.237 -// if (!pd.getPattern().checkAntipatterns(tp)) {
570.238 -// return null;
570.239 -// }
570.240 -//
570.241 -// tp = tp.getParentPath();
570.242 -// }
570.243 -
570.244 - List<Fix> fixes = new LinkedList<Fix>();
570.245 -
570.246 - for (FixDescription d : fixDescriptions) {
570.247 - String dn = d.getDisplayName();
570.248 -
570.249 - if (dn.length() == 0) {
570.250 - dn = defaultFixDisplayName(ctx.getInfo(), ctx.getVariables(), d);
570.251 - }
570.252 -
570.253 - fixes.add(JavaFix.rewriteFix(ctx.getInfo(), dn, ctx.getPath(), d.getPattern(), ctx.getVariables(), ctx.getMultiVariables(), ctx.getVariableNames(), Collections.<String, TypeMirror>emptyMap()/*XXX: pd.pattern.getConstraints()*/));
570.254 - }
570.255 -
570.256 - return Collections.singletonList(ErrorDescriptionFactory.forName(ctx, ctx.getPath(), displayName, fixes.toArray(new Fix[0])));
570.257 - }
570.258 - }
570.259 -
570.260 - private static <T> T findValue(AnnotationMirror m, String name, Class<T> clazz) {
570.261 - for (Entry<? extends ExecutableElement, ? extends AnnotationValue> e : m.getElementValues().entrySet()) {
570.262 - if (name.equals(e.getKey().getSimpleName().toString())) {
570.263 - return clazz.cast(e.getValue().getValue());
570.264 - }
570.265 - }
570.266 -
570.267 - TypeElement te = (TypeElement) m.getAnnotationType().asElement();
570.268 -
570.269 - for (ExecutableElement ee : ElementFilter.methodsIn(te.getEnclosedElements())) {
570.270 - if (name.equals(ee.getSimpleName().toString())) {
570.271 - if (ee.getDefaultValue() == null) {
570.272 - return null;
570.273 - }
570.274 - return clazz.cast(ee.getDefaultValue().getValue());
570.275 - }
570.276 - }
570.277 -
570.278 - return null;
570.279 - }
570.280 -
570.281 - private static HintDescription create(CompilationInfo info, Element el, AnnotationMirror transformation, String id, CompilationInfo fake) {
570.282 - Collection rawPatterns = findValue(transformation, "pattern", Collection.class);
570.283 -
570.284 - if (rawPatterns == null || rawPatterns.isEmpty()) {
570.285 - return null;
570.286 - }
570.287 -
570.288 - Iterable<AnnotationMirror> patterns = Utilities.checkedIterableByFilter(rawPatterns, AnnotationMirror.class, true);
570.289 -
570.290 - String patternString = findValue(patterns.iterator().next(), "value", String.class);
570.291 -
570.292 - if (patternString == null) {
570.293 - return null;
570.294 - }
570.295 -
570.296 - Collection rawConstraints = findValue(transformation, "constraint", Collection.class);
570.297 -
570.298 - if (rawConstraints == null) {
570.299 - return null;
570.300 - }
570.301 -
570.302 - Iterable<AnnotationMirror> constraints = Utilities.checkedIterableByFilter(rawConstraints, AnnotationMirror.class, true);
570.303 - Map<String, String> variableTypes = new HashMap<String, String>();
570.304 -
570.305 - for (AnnotationMirror m : constraints) {
570.306 - String var = findValue(m, "variable", String.class);
570.307 - TypeMirror tm = findValue(m, "type", TypeMirror.class);
570.308 -
570.309 - if (var == null || tm == null) {
570.310 - return null;
570.311 - }
570.312 -
570.313 - variableTypes.put(var, tm.toString()); //XXX: toString()
570.314 - }
570.315 -
570.316 - if (!el.getModifiers().contains(Modifier.STATIC) && !variableTypes.containsKey("$this")) {
570.317 - TypeMirror parent = el.getEnclosingElement().asType();
570.318 -
570.319 - variableTypes.put("$this", TypeMirrorHandle.create(fake.getTypes().erasure(parent)).resolve(info).toString()); //XXX: toString()
570.320 - }
570.321 -
570.322 - List<String> aps = new LinkedList<String>();
570.323 -
570.324 - for (AnnotationMirror ap : Utilities.checkedIterableByFilter(findValue(transformation, "antipattern", Collection.class), AnnotationMirror.class, true)) {
570.325 - aps.add(findValue(ap, "value", String.class));
570.326 - }
570.327 -
570.328 - List<FixDescription> fixes = new LinkedList<FixDescription>();
570.329 - Collection rawFixes = findValue(transformation, "fix", Collection.class);
570.330 -
570.331 - if (rawFixes == null) {
570.332 - return null;
570.333 - }
570.334 -
570.335 - for (AnnotationMirror f : Utilities.checkedIterableByFilter(rawFixes, AnnotationMirror.class, true)) {
570.336 - String dn = findValue(f, "displayName", String.class);
570.337 - String to = findValue(f, "value", String.class);
570.338 -
570.339 - if (dn == null || to == null) {
570.340 - return null;
570.341 - }
570.342 -
570.343 - fixes.add(new FixDescription(dn, to));
570.344 - }
570.345 -
570.346 - String displayName = findValue(transformation, "displayName", String.class);
570.347 -
570.348 - if (displayName == null) {
570.349 - return null;//XXX
570.350 - }
570.351 -
570.352 - HintMetadata hm = HintMetadata.Builder.create(id).setDescription(displayName, displayName).setCategory(CATEGORY).build();
570.353 -
570.354 - return HintDescriptionFactory.create()
570.355 - .setMetadata(hm)
570.356 - .setTrigger(PatternDescription.create(patternString, variableTypes))
570.357 - .setWorker(new WorkerImpl(displayName, fixes))
570.358 - .produce();
570.359 - }
570.360 -
570.361 - private static final String CATEGORY = "Transformations";
570.362 -
570.363 - private static final class FixDescription {
570.364 - private final String displayName;
570.365 - private final String pattern;
570.366 -
570.367 - public FixDescription(String displayName, String pattern) {
570.368 - this.displayName = displayName;
570.369 - this.pattern = pattern;
570.370 - }
570.371 -
570.372 - public String getDisplayName() {
570.373 - return displayName;
570.374 - }
570.375 -
570.376 - public String getPattern() {
570.377 - return pattern;
570.378 - }
570.379 -
570.380 - }
570.381 -
570.382 - private static final File ANNOTATIONS_JAR;
570.383 - private static final File NB_OVERLAY_JAR;
570.384 - private static final File JDK_OVERLAY_JAR;
570.385 -
570.386 - static {
570.387 - ANNOTATIONS_JAR = InstalledFileLocator.getDefault().locate("libs/annotations.jar", null, false);
570.388 - NB_OVERLAY_JAR = InstalledFileLocator.getDefault().locate("overlay/org-netbeans-nboverlay.jar", null, false);
570.389 - JDK_OVERLAY_JAR = InstalledFileLocator.getDefault().locate("overlay/jdk.jar", null, false);
570.390 - }
570.391 -
570.392 - private ClassPath prepareOverlayCompileCP() throws IllegalArgumentException {
570.393 - if (NB_OVERLAY_JAR ==null) {
570.394 - return ClassPathSupport.createClassPath(new URL[0]);
570.395 - }
570.396 -
570.397 - return ClassPathSupport.createClassPath(FileUtil.urlForArchiveOrDir(NB_OVERLAY_JAR));
570.398 - }
570.399 -
570.400 - private ClassPath prepareOverlayBootCP() throws IllegalArgumentException {
570.401 - if (ANNOTATIONS_JAR == null) {
570.402 - return ClassPathSupport.createClassPath(new URL[0]);
570.403 - }
570.404 -
570.405 - if (JDK_OVERLAY_JAR == null) {
570.406 - return ClassPathSupport.createClassPath(FileUtil.urlForArchiveOrDir(ANNOTATIONS_JAR));
570.407 - }
570.408 -
570.409 - return ClassPathSupport.createClassPath(FileUtil.urlForArchiveOrDir(ANNOTATIONS_JAR), FileUtil.urlForArchiveOrDir(JDK_OVERLAY_JAR));
570.410 - }
570.411 -
570.412 - private List<HintDescription> processAnnotations(Element e, Element enclosing, CompilationInfo info, CompilationInfo fake) {
570.413 - boolean foundTransformations = false;
570.414 - List<HintDescription> result = new LinkedList<HintDescription>();
570.415 - String id;
570.416 - switch (e.getKind()) {
570.417 - case ANNOTATION_TYPE:
570.418 - case CLASS:
570.419 - case ENUM:
570.420 - case INTERFACE:
570.421 - id = fake.getElements().getBinaryName((TypeElement) e).toString();
570.422 - break;
570.423 - case FIELD:
570.424 - case ENUM_CONSTANT:
570.425 - id = fake.getElements().getBinaryName((TypeElement) enclosing).toString() + e.getSimpleName().toString();
570.426 - break;
570.427 - case CONSTRUCTOR:
570.428 - case METHOD:
570.429 - //XXX: parameters!
570.430 - id = fake.getElements().getBinaryName((TypeElement) enclosing).toString() + e.getSimpleName().toString();
570.431 - break;
570.432 - default:
570.433 - id = "no-id";
570.434 - break;
570.435 - }
570.436 -
570.437 - int index = 0;
570.438 -
570.439 - for (AnnotationMirror am : e.getAnnotationMirrors()) {
570.440 - String fqn = ((TypeElement) am.getAnnotationType().asElement()).getQualifiedName().toString();
570.441 - List<AnnotationMirror> transformations = new LinkedList<AnnotationMirror>();
570.442 - if (TRANSFORMATION.toFQN().equals(fqn)) {
570.443 - transformations.add(am);
570.444 - foundTransformations = true;
570.445 - }
570.446 - if (TRANSFORMATION_SET.toFQN().equals(fqn)) {
570.447 - for (AnnotationMirror m : Utilities.checkedIterableByFilter(findValue(am, "value", Collection.class), AnnotationMirror.class, true)) {
570.448 - transformations.add(m);
570.449 - }
570.450 - foundTransformations = true;
570.451 - }
570.452 -
570.453 - for (AnnotationMirror t : transformations) {
570.454 - HintDescription pd = create(info, e, t, id + "-" + (index++), fake);
570.455 -
570.456 - if (pd != null) {
570.457 - result.add(pd);
570.458 - }
570.459 - }
570.460 - }
570.461 -
570.462 - if (!foundTransformations && e.getKind() == ElementKind.METHOD) {
570.463 - TypeElement owner = (TypeElement) e.getEnclosingElement();
570.464 -
570.465 - for (TypeMirror tm : fake.getTypes().directSupertypes(owner.asType())) {
570.466 - DeclaredType dt = (DeclaredType) tm;
570.467 - TypeElement parent = (TypeElement) dt.asElement();
570.468 -
570.469 - for (ExecutableElement ee : ElementFilter.methodsIn(parent.getEnclosedElements())) {
570.470 - if (!fake.getElements().overrides((ExecutableElement) e, ee, (TypeElement) enclosing)) {
570.471 - continue;
570.472 - }
570.473 - List<HintDescription> r = processAnnotations(ee, enclosing, info, fake);
570.474 -
570.475 - result.addAll(r);
570.476 - }
570.477 -
570.478 - }
570.479 - }
570.480 -
570.481 - return result;
570.482 - }
570.483 -
570.484 - private static String defaultFixDisplayName(CompilationInfo info, Map<String, TreePath> variables, FixDescription d) {
570.485 - Map<String, String> stringsForVariables = new HashMap<String, String>();
570.486 -
570.487 - for (Entry<String, TreePath> e : variables.entrySet()) {
570.488 - Tree t = e.getValue().getLeaf();
570.489 - SourcePositions sp = info.getTrees().getSourcePositions();
570.490 - int startPos = (int) sp.getStartPosition(info.getCompilationUnit(), t);
570.491 - int endPos = (int) sp.getEndPosition(info.getCompilationUnit(), t);
570.492 -
570.493 - stringsForVariables.put(e.getKey(), info.getText().substring(startPos, endPos));
570.494 - }
570.495 -
570.496 - if (!stringsForVariables.containsKey("$this")) {
570.497 - stringsForVariables.put("$this", "this");
570.498 - }
570.499 -
570.500 - String replaceTarget = d.getPattern();
570.501 -
570.502 - for (Entry<String, String> e : stringsForVariables.entrySet()) {
570.503 - String quotedVariable = java.util.regex.Pattern.quote(e.getKey());
570.504 - String quotedTarget = Matcher.quoteReplacement(e.getValue());
570.505 - replaceTarget = replaceTarget.replaceAll(quotedVariable, quotedTarget);
570.506 - }
570.507 -
570.508 - return "Rewrite to " + replaceTarget;
570.509 - }
570.510 -
570.511 -}
571.1 --- a/transformer/src/org/netbeans/modules/jackpot30/transformers/Utilities.java Fri Jan 27 13:35:56 2012 +0100
571.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
571.3 @@ -1,138 +0,0 @@
571.4 -/*
571.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
571.6 - *
571.7 - * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
571.8 - *
571.9 - * The contents of this file are subject to the terms of either the GNU
571.10 - * General Public License Version 2 only ("GPL") or the Common
571.11 - * Development and Distribution License("CDDL") (collectively, the
571.12 - * "License"). You may not use this file except in compliance with the
571.13 - * License. You can obtain a copy of the License at
571.14 - * http://www.netbeans.org/cddl-gplv2.html
571.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
571.16 - * specific language governing permissions and limitations under the
571.17 - * License. When distributing the software, include this License Header
571.18 - * Notice in each file and include the License file at
571.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
571.20 - * particular file as subject to the "Classpath" exception as provided
571.21 - * by Sun in the GPL Version 2 section of the License file that
571.22 - * accompanied this code. If applicable, add the following below the
571.23 - * License Header, with the fields enclosed by brackets [] replaced by
571.24 - * your own identifying information:
571.25 - * "Portions Copyrighted [year] [name of copyright owner]"
571.26 - *
571.27 - * If you wish your version of this file to be governed by only the CDDL
571.28 - * or only the GPL Version 2, indicate your decision by adding
571.29 - * "[Contributor] elects to include this software in this distribution
571.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
571.31 - * single choice of license, a recipient has the option to distribute
571.32 - * your version of this file under either the CDDL, the GPL Version 2 or
571.33 - * to extend the choice of license to its licensees as provided above.
571.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
571.35 - * Version 2 license, then the option applies only if the new code is
571.36 - * made subject to such option by the copyright holder.
571.37 - *
571.38 - * Contributor(s):
571.39 - *
571.40 - * Portions Copyrighted 2008-2009 Sun Microsystems, Inc.
571.41 - */
571.42 -
571.43 -package org.netbeans.modules.jackpot30.transformers;
571.44 -
571.45 -import com.sun.source.tree.AnnotationTree;
571.46 -import com.sun.source.tree.AssignmentTree;
571.47 -import com.sun.source.tree.ExpressionTree;
571.48 -import com.sun.source.tree.IdentifierTree;
571.49 -import com.sun.source.tree.LiteralTree;
571.50 -import com.sun.source.tree.MemberSelectTree;
571.51 -import com.sun.source.tree.NewArrayTree;
571.52 -import com.sun.source.tree.Tree;
571.53 -import com.sun.source.tree.Tree.Kind;
571.54 -import java.util.Arrays;
571.55 -import java.util.Iterator;
571.56 -import java.util.LinkedList;
571.57 -import java.util.List;
571.58 -import javax.lang.model.element.TypeElement;
571.59 -import javax.lang.model.type.TypeMirror;
571.60 -import org.netbeans.api.java.source.TreeMaker;
571.61 -import org.netbeans.api.java.source.WorkingCopy;
571.62 -import org.openide.util.NbCollections;
571.63 -
571.64 -/**
571.65 - *
571.66 - * @author Jan Lahoda
571.67 - */
571.68 -public class Utilities {
571.69 -
571.70 - private Utilities() {}
571.71 -
571.72 - public static <E> Iterable<E> checkedIterableByFilter(final Iterable raw, final Class<E> type, final boolean strict) {
571.73 - return new Iterable<E>() {
571.74 - public Iterator<E> iterator() {
571.75 - return NbCollections.checkedIteratorByFilter(raw.iterator(), type, strict);
571.76 - }
571.77 - };
571.78 - }
571.79 -
571.80 -// public static AnnotationTree constructConstraint(WorkingCopy wc, String name, TypeMirror tm) {
571.81 -// TreeMaker make = wc.getTreeMaker();
571.82 -// ExpressionTree variable = prepareAssignment(make, "variable", make.Literal(name));
571.83 -// ExpressionTree type = prepareAssignment(make, "type", make.MemberSelect((ExpressionTree) make.Type(wc.getTypes().erasure(tm)), "class"));
571.84 -// TypeElement constraint = wc.getElements().getTypeElement(Annotations.CONSTRAINT.toFQN());
571.85 -//
571.86 -// return make.Annotation(make.QualIdent(constraint), Arrays.asList(variable, type));
571.87 -// }
571.88 -
571.89 - public static ExpressionTree prepareAssignment(TreeMaker make, String name, ExpressionTree value) {
571.90 - return make.Assignment(make.Identifier(name), value);
571.91 - }
571.92 -
571.93 - public static ExpressionTree findValue(AnnotationTree m, String name) {
571.94 - for (ExpressionTree et : m.getArguments()) {
571.95 - if (et.getKind() == Kind.ASSIGNMENT) {
571.96 - AssignmentTree at = (AssignmentTree) et;
571.97 - String varName = ((IdentifierTree) at.getVariable()).getName().toString();
571.98 -
571.99 - if (varName.equals(name)) {
571.100 - return at.getExpression();
571.101 - }
571.102 - }
571.103 -
571.104 - if (et instanceof LiteralTree/*XXX*/ && "value".equals(name)) {
571.105 - return et;
571.106 - }
571.107 - }
571.108 -
571.109 - return null;
571.110 - }
571.111 -
571.112 - public static List<AnnotationTree> findArrayValue(AnnotationTree at, String name) {
571.113 - ExpressionTree fixesArray = findValue(at, name);
571.114 - List<AnnotationTree> fixes = new LinkedList<AnnotationTree>();
571.115 -
571.116 - if (fixesArray != null && fixesArray.getKind() == Kind.NEW_ARRAY) {
571.117 - NewArrayTree trees = (NewArrayTree) fixesArray;
571.118 -
571.119 - for (ExpressionTree fix : trees.getInitializers()) {
571.120 - if (fix.getKind() == Kind.ANNOTATION) {
571.121 - fixes.add((AnnotationTree) fix);
571.122 - }
571.123 - }
571.124 - }
571.125 -
571.126 - if (fixesArray != null && fixesArray.getKind() == Kind.ANNOTATION) {
571.127 - fixes.add((AnnotationTree) fixesArray);
571.128 - }
571.129 -
571.130 - return fixes;
571.131 - }
571.132 -
571.133 - public static boolean isPureMemberSelect(Tree mst, boolean allowVariables) {
571.134 - switch (mst.getKind()) {
571.135 - case IDENTIFIER: return allowVariables || ((IdentifierTree) mst).getName().charAt(0) != '$';
571.136 - case MEMBER_SELECT: return isPureMemberSelect(((MemberSelectTree) mst).getExpression(), allowVariables);
571.137 - default: return false;
571.138 - }
571.139 - }
571.140 -
571.141 -}
572.1 --- a/transformer/src/org/netbeans/modules/jackpot30/transformers/resources/Bundle.properties Fri Jan 27 13:35:56 2012 +0100
572.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
572.3 @@ -1,38 +0,0 @@
572.4 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
572.5 -#
572.6 -# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
572.7 -#
572.8 -# The contents of this file are subject to the terms of either the GNU
572.9 -# General Public License Version 2 only ("GPL") or the Common
572.10 -# Development and Distribution License("CDDL") (collectively, the
572.11 -# "License"). You may not use this file except in compliance with the
572.12 -# License. You can obtain a copy of the License at
572.13 -# http://www.netbeans.org/cddl-gplv2.html
572.14 -# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
572.15 -# specific language governing permissions and limitations under the
572.16 -# License. When distributing the software, include this License Header
572.17 -# Notice in each file and include the License file at
572.18 -# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
572.19 -# particular file as subject to the "Classpath" exception as provided
572.20 -# by Sun in the GPL Version 2 section of the License file that
572.21 -# accompanied this code. If applicable, add the following below the
572.22 -# License Header, with the fields enclosed by brackets [] replaced by
572.23 -# your own identifying information:
572.24 -# "Portions Copyrighted [year] [name of copyright owner]"
572.25 -#
572.26 -# If you wish your version of this file to be governed by only the CDDL
572.27 -# or only the GPL Version 2, indicate your decision by adding
572.28 -# "[Contributor] elects to include this software in this distribution
572.29 -# under the [CDDL or GPL Version 2] license." If you do not indicate a
572.30 -# single choice of license, a recipient has the option to distribute
572.31 -# your version of this file under either the CDDL, the GPL Version 2 or
572.32 -# to extend the choice of license to its licensees as provided above.
572.33 -# However, if you add GPL Version 2 code and therefore, elected the GPL
572.34 -# Version 2 license, then the option applies only if the new code is
572.35 -# made subject to such option by the copyright holder.
572.36 -#
572.37 -# Contributor(s):
572.38 -#
572.39 -# Portions Copyrighted 2009 Sun Microsystems, Inc.
572.40 -
572.41 -OpenIDE-Module-Name=Jackpot 3.0 Transformations
573.1 --- a/transformer/src/org/netbeans/modules/jackpot30/transformers/resources/layer.xml Fri Jan 27 13:35:56 2012 +0100
573.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
573.3 @@ -1,4 +0,0 @@
573.4 -<?xml version="1.0" encoding="UTF-8"?>
573.5 -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
573.6 -<filesystem>
573.7 -</filesystem>
574.1 --- a/transformer/test/unit/src/org/netbeans/modules/jackpot30/transformers/TransformationHintProviderImplTest.java Fri Jan 27 13:35:56 2012 +0100
574.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
574.3 @@ -1,555 +0,0 @@
574.4 -/*
574.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
574.6 - *
574.7 - * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
574.8 - *
574.9 - * The contents of this file are subject to the terms of either the GNU
574.10 - * General Public License Version 2 only ("GPL") or the Common
574.11 - * Development and Distribution License("CDDL") (collectively, the
574.12 - * "License"). You may not use this file except in compliance with the
574.13 - * License. You can obtain a copy of the License at
574.14 - * http://www.netbeans.org/cddl-gplv2.html
574.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
574.16 - * specific language governing permissions and limitations under the
574.17 - * License. When distributing the software, include this License Header
574.18 - * Notice in each file and include the License file at
574.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
574.20 - * particular file as subject to the "Classpath" exception as provided
574.21 - * by Sun in the GPL Version 2 section of the License file that
574.22 - * accompanied this code. If applicable, add the following below the
574.23 - * License Header, with the fields enclosed by brackets [] replaced by
574.24 - * your own identifying information:
574.25 - * "Portions Copyrighted [year] [name of copyright owner]"
574.26 - *
574.27 - * If you wish your version of this file to be governed by only the CDDL
574.28 - * or only the GPL Version 2, indicate your decision by adding
574.29 - * "[Contributor] elects to include this software in this distribution
574.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
574.31 - * single choice of license, a recipient has the option to distribute
574.32 - * your version of this file under either the CDDL, the GPL Version 2 or
574.33 - * to extend the choice of license to its licensees as provided above.
574.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
574.35 - * Version 2 license, then the option applies only if the new code is
574.36 - * made subject to such option by the copyright holder.
574.37 - *
574.38 - * Contributor(s):
574.39 - *
574.40 - * Portions Copyrighted 2008 Sun Microsystems, Inc.
574.41 - */
574.42 -
574.43 -package org.netbeans.modules.jackpot30.transformers;
574.44 -
574.45 -import com.sun.source.tree.Tree.Kind;
574.46 -import java.io.File;
574.47 -import java.io.IOException;
574.48 -import java.util.ArrayList;
574.49 -import java.util.Arrays;
574.50 -import java.util.Collections;
574.51 -import java.util.HashMap;
574.52 -import java.util.LinkedList;
574.53 -import java.util.List;
574.54 -import java.util.Map;
574.55 -import java.util.concurrent.atomic.AtomicBoolean;
574.56 -import javax.swing.text.Document;
574.57 -import org.netbeans.api.java.lexer.JavaTokenId;
574.58 -import org.netbeans.api.java.source.CompilationInfo;
574.59 -import org.netbeans.api.java.source.JavaSource;
574.60 -import org.netbeans.api.java.source.JavaSource.Phase;
574.61 -import org.netbeans.api.java.source.SourceUtilsTestUtil;
574.62 -import org.netbeans.api.java.source.TestUtilities;
574.63 -import org.netbeans.api.lexer.Language;
574.64 -import org.netbeans.junit.NbTestCase;
574.65 -import org.netbeans.modules.java.hints.jackpot.impl.RulesManager;
574.66 -import org.netbeans.modules.java.hints.jackpot.impl.hints.HintsInvoker;
574.67 -import org.netbeans.modules.java.hints.jackpot.spi.ClassPathBasedHintProvider;
574.68 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
574.69 -import org.netbeans.modules.java.hints.jackpot.spi.Trigger.PatternDescription;
574.70 -import org.netbeans.modules.java.source.TreeLoader;
574.71 -import org.netbeans.spi.editor.hints.ErrorDescription;
574.72 -import org.netbeans.spi.editor.hints.Fix;
574.73 -import org.openide.LifecycleManager;
574.74 -import org.openide.cookies.EditorCookie;
574.75 -import org.openide.filesystems.FileObject;
574.76 -import org.openide.filesystems.FileUtil;
574.77 -import org.openide.loaders.DataObject;
574.78 -import org.openide.modules.InstalledFileLocator;
574.79 -
574.80 -/**
574.81 - *
574.82 - * @author Jan Lahoda
574.83 - */
574.84 -public class TransformationHintProviderImplTest extends NbTestCase {
574.85 -
574.86 - public TransformationHintProviderImplTest(String name) {
574.87 - super(name);
574.88 - }
574.89 -
574.90 - public void testSimpleAnalysis() throws Exception {
574.91 - performAnalysisTest("package test;\n" +
574.92 - "import net.java.lang.annotations.Constraint;\n" +
574.93 - "import net.java.lang.annotations.Fix;\n" +
574.94 - "import net.java.lang.annotations.Pattern;\n" +
574.95 - "import net.java.lang.annotations.Transformation;\n" +
574.96 - "public class Test {\n" +
574.97 - " @Transformation(\n" +
574.98 - " displayName=\"O\",\n" +
574.99 - " pattern=@Pattern(\"$0.getCookie($1)\"),\n" +
574.100 - " constraint={\n" +
574.101 - " @Constraint(variable=\"$0\", type=Test.class),\n" +
574.102 - " @Constraint(variable=\"$1\", type=Class.class)\n" +
574.103 - " },\n" +
574.104 - " fix=@Fix(\"$0.lookup($1)\")\n" +
574.105 - " )\n" +
574.106 - " public void getCookie(Class c) {}\n" +
574.107 - " private void test() {\n" +
574.108 - " getCookie(null);\n" +
574.109 - " }\n" +
574.110 - "}\n",
574.111 - "17:9-17:18:verifier:O");
574.112 - }
574.113 -
574.114 - public void testCanGoUp() throws Exception {
574.115 - performAnalysisTest("package test;\n" +
574.116 - "import net.java.lang.annotations.Constraint;\n" +
574.117 - "import net.java.lang.annotations.Fix;\n" +
574.118 - "import net.java.lang.annotations.Pattern;\n" +
574.119 - "import net.java.lang.annotations.Transformation;\n" +
574.120 - "public abstract class Test {\n" +
574.121 - " @Transformation(\n" +
574.122 - " displayName=\"O\",\n" +
574.123 - " pattern=@Pattern(\"$0.getCookie().toString()\"),\n" +
574.124 - " constraint={\n" +
574.125 - " @Constraint(variable=\"$0\", type=Test.class)\n" +
574.126 - " },\n" +
574.127 - " fix=@Fix(\"$0.lookup($1)\")\n" +
574.128 - " )\n" +
574.129 - " public abstract String getCookie();\n" +
574.130 - " private void test() {\n" +
574.131 - " getCookie().toString();\n" +
574.132 - " }\n" +
574.133 - "}\n",
574.134 - "16:21-16:29:verifier:O");
574.135 - }
574.136 -
574.137 - public void testForConstructor() throws Exception {
574.138 - performAnalysisTest("package test;\n" +
574.139 - "import net.java.lang.annotations.Constraint;\n" +
574.140 - "import net.java.lang.annotations.Fix;\n" +
574.141 - "import net.java.lang.annotations.Pattern;\n" +
574.142 - "import net.java.lang.annotations.Transformation;\n" +
574.143 - "public class Test {\n" +
574.144 - " @Transformation(\n" +
574.145 - " displayName=\"O\",\n" +
574.146 - " pattern=@Pattern(\"new test.Test()\"),\n" +
574.147 - " fix={}\n" +
574.148 - " )\n" +
574.149 - " public Test() {}\n" +
574.150 - " private void test() {\n" +
574.151 - " new Test();\n" +
574.152 - " }\n" +
574.153 - "}\n",
574.154 - "13:9-13:19:verifier:O");
574.155 - }
574.156 -
574.157 - public void testMoreWarnings() throws Exception {
574.158 - performAnalysisTest("package test;\n" +
574.159 - "import net.java.lang.annotations.Constraint;\n" +
574.160 - "import net.java.lang.annotations.Fix;\n" +
574.161 - "import net.java.lang.annotations.Pattern;\n" +
574.162 - "import net.java.lang.annotations.Transformation;\n" +
574.163 - "public class Test {\n" +
574.164 - " @Transformation(\n" +
574.165 - " displayName=\"O\",\n" +
574.166 - " pattern=@Pattern(\"new test.Test()\"),\n" +
574.167 - " fix={}\n" +
574.168 - " )\n" +
574.169 - " public Test() {}\n" +
574.170 - " private void test() {\n" +
574.171 - " new Test();\n" +
574.172 - " new Test();\n" +
574.173 - " }\n" +
574.174 - "}\n",
574.175 - "13:9-13:19:verifier:O",
574.176 - "14:9-14:19:verifier:O");
574.177 - }
574.178 -
574.179 - public void testCorrectImports() throws Exception {
574.180 - performFixTest("test/Test.java",
574.181 - "package test;\n" +
574.182 - "import net.java.lang.annotations.Constraint;\n" +
574.183 - "import net.java.lang.annotations.Fix;\n" +
574.184 - "import net.java.lang.annotations.Pattern;\n" +
574.185 - "import net.java.lang.annotations.Transformation;\n" +
574.186 - "public abstract class Test {\n" +
574.187 - " @Transformation(\n" +
574.188 - " displayName=\"O\",\n" +
574.189 - " pattern=@Pattern(\"$this.test()\"),\n" +
574.190 - " fix=@Fix(\"test.Test.test1().toString()\")\n" +
574.191 - " )\n" +
574.192 - " private void test() {\n" +
574.193 - " test();\n" +
574.194 - " }" +
574.195 - " static String test1() {return null;}\n" +
574.196 - "}\n",
574.197 - "12:9-12:13:verifier:O",
574.198 - "FixImpl",
574.199 - "package test;\n" +
574.200 - "import net.java.lang.annotations.Constraint;\n" +
574.201 - "import net.java.lang.annotations.Fix;\n" +
574.202 - "import net.java.lang.annotations.Pattern;\n" +
574.203 - "import net.java.lang.annotations.Transformation;\n" +
574.204 - "public abstract class Test {\n" +
574.205 - " @Transformation(\n" +
574.206 - " displayName=\"O\",\n" +
574.207 - " pattern=@Pattern(\"$this.test()\"),\n" +
574.208 - " fix=@Fix(\"test.Test.test1().toString()\")\n" +
574.209 - " )\n" +
574.210 - " private void test() {\n" +
574.211 - " Test.test1().toString();\n" +
574.212 - " }" +
574.213 - " static String test1() {return null;}\n" +
574.214 - "}\n");
574.215 - }
574.216 -
574.217 - public void testNoExceptions1() throws Exception {
574.218 - performNoExceptionsTest("package test;\n" +
574.219 - "import net.java.lang.annotations.Constraint;\n" +
574.220 - "import net.java.lang.annotations.Fix;\n" +
574.221 - "import net.java.lang.annotations.Pattern;\n" +
574.222 - "import net.java.lang.annotations.Transformation;\n" +
574.223 - "public abstract class Test {\n" +
574.224 - " |public abstract String getCookie();\n" +
574.225 - " private void test() {\n" +
574.226 - " getCookie().toString();\n" +
574.227 - " }\n" +
574.228 - "}\n",
574.229 - " @Transformation(\n" +
574.230 - " displayName=\"O\",\n" +
574.231 - " pattern=@Pattern(\"$0.getCookie().toString()\"),\n" +
574.232 - " constraint={\n" +
574.233 - " @Constraint(variable=\"$0\", type=Test.class)\n" +
574.234 - " },\n" +
574.235 - " fix={@Fix(\"$0.lookup($1)\")}\n" +
574.236 - " )\n".replaceAll("[ \n]+", " "));
574.237 - }
574.238 -
574.239 - public void testNoExceptions2() throws Exception {
574.240 - performNoExceptionsTest("package test;\n" +
574.241 - "import net.java.lang.annotations.Constraint;\n" +
574.242 - "import net.java.lang.annotations.Fix;\n" +
574.243 - "import net.java.lang.annotations.Pattern;\n" +
574.244 - "import net.java.lang.annotations.Transformation;\n" +
574.245 - "public abstract class Test {\n" +
574.246 - " |public abstract String getCookie();\n" +
574.247 - " private void test() {\n" +
574.248 - " getCookie().toString();\n" +
574.249 - " }\n" +
574.250 - "}\n",
574.251 - " @Transformation(\n" +
574.252 - " displayName=\"O\",\n" +
574.253 - " pattern=@Pattern(\"$0.getCookie().toString()\"),\n" +
574.254 - " constraint=\n" +
574.255 - " @Constraint(variable=\"$0\", type=Test.class)\n" +
574.256 - " ,\n" +
574.257 - " fix=@Fix(\"$0.lookup($1)\")\n" +
574.258 - " )\n".replaceAll("[ \n]+", " "));
574.259 - }
574.260 -
574.261 - public void testType1() throws Exception {
574.262 - performFixTest("test/Test.java",
574.263 - "package test;\n" +
574.264 - "import net.java.lang.annotations.Constraint;\n" +
574.265 - "import net.java.lang.annotations.Fix;\n" +
574.266 - "import net.java.lang.annotations.Pattern;\n" +
574.267 - "import net.java.lang.annotations.Transformation;\n" +
574.268 - "public abstract class Test {\n" +
574.269 - " @Transformation(\n" +
574.270 - " displayName=\"O\",\n" +
574.271 - " pattern=@Pattern(\"test.Test.Bad\"),\n" +
574.272 - " fix=@Fix(\"test.Test.Good\")\n" +
574.273 - " )\n" +
574.274 - " public static class Bad {}\n" +
574.275 - " public static class Good {}\n" +
574.276 - " static void test1() { Bad b; }\n" +
574.277 - "}\n",
574.278 - "13:26-13:29:verifier:O",
574.279 - "FixImpl",
574.280 - "package test;\n" +
574.281 - "import net.java.lang.annotations.Constraint;\n" +
574.282 - "import net.java.lang.annotations.Fix;\n" +
574.283 - "import net.java.lang.annotations.Pattern;\n" +
574.284 - "import net.java.lang.annotations.Transformation;\n" +
574.285 - "public abstract class Test {\n" +
574.286 - " @Transformation(\n" +
574.287 - " displayName=\"O\",\n" +
574.288 - " pattern=@Pattern(\"test.Test.Bad\"),\n" +
574.289 - " fix=@Fix(\"test.Test.Good\")\n" +
574.290 - " )\n" +
574.291 - " public static class Bad {}\n" +
574.292 - " public static class Good {}\n" +
574.293 - " static void test1() { Good b; }\n" +
574.294 - "}\n".replaceAll("[ \n]+", " "));
574.295 - }
574.296 -
574.297 - public void testCorrectReplace() throws Exception {
574.298 - performFixTest("test/Test.java",
574.299 - "package test;\n" +
574.300 - "import net.java.lang.annotations.Constraint;\n" +
574.301 - "import net.java.lang.annotations.Fix;\n" +
574.302 - "import net.java.lang.annotations.Pattern;\n" +
574.303 - "import net.java.lang.annotations.Transformation;\n" +
574.304 - "public class Test {\n" +
574.305 - " @Transformation(\n" +
574.306 - " displayName=\"O\",\n" +
574.307 - " pattern=@Pattern(\"$this.test()\"),\n" +
574.308 - " fix=@Fix(\"$this.test()\")\n" +
574.309 - " )\n" +
574.310 - " private void test() {\n" +
574.311 - " new Test().test();\n" +
574.312 - " }\n" +
574.313 - "}\n",
574.314 - "12:20-12:24:verifier:O",
574.315 - "FixImpl",
574.316 - "package test;\n" +
574.317 - "import net.java.lang.annotations.Constraint;\n" +
574.318 - "import net.java.lang.annotations.Fix;\n" +
574.319 - "import net.java.lang.annotations.Pattern;\n" +
574.320 - "import net.java.lang.annotations.Transformation;\n" +
574.321 - "public class Test {\n" +
574.322 - " @Transformation(\n" +
574.323 - " displayName=\"O\",\n" +
574.324 - " pattern=@Pattern(\"$this.test()\"),\n" +
574.325 - " fix=@Fix(\"$this.test()\")\n" +
574.326 - " )\n" +
574.327 - " private void test() {\n" +
574.328 - " new Test().test();\n" +
574.329 - " }\n" +
574.330 - "}\n");
574.331 - }
574.332 -
574.333 - @Override
574.334 - protected void setUp() throws Exception {
574.335 - super.setUp();
574.336 -
574.337 - File jar = FileUtil.archiveOrDirForURL(TransformationHintProviderImpl.class.getProtectionDomain().getCodeSource().getLocation());
574.338 -
574.339 - assertNotNull(jar);
574.340 -
574.341 - String nbHome = jar.getParentFile().getParentFile().getAbsolutePath();
574.342 -
574.343 - System.setProperty("netbeans.home",nbHome);
574.344 -
574.345 - SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml"}, new Object[0]);
574.346 - TreeLoader.DISABLE_CONFINEMENT_TEST = true;
574.347 - }
574.348 -
574.349 - private List<ErrorDescription> computeWarnings() {
574.350 - List<HintDescription> hints = new ArrayList<HintDescription>();
574.351 -
574.352 - RulesManager.computeElementBasedHintsXXX(info, new AtomicBoolean(), Collections.singletonList(new TransformationHintProviderImpl()), Collections.<ClassPathBasedHintProvider>emptyList(), hints);
574.353 -
574.354 - List<ErrorDescription> warnings = new HintsInvoker(info, new AtomicBoolean()).computeHints(info, hints);
574.355 -
574.356 - return warnings;
574.357 - }
574.358 -
574.359 - private void prepareTest(String fileName, String code) throws Exception {
574.360 - prepareTest(fileName, code, false);
574.361 - }
574.362 -
574.363 - private void prepareTest(String fileName, String code, boolean ignoreErrors) throws Exception {
574.364 - clearWorkDir();
574.365 -
574.366 - FileUtil.refreshFor(File.listRoots());
574.367 -
574.368 - FileObject workFO = FileUtil.toFileObject(getWorkDir());
574.369 -
574.370 - assertNotNull(workFO);
574.371 -
574.372 - workFO.refresh();
574.373 -
574.374 - sourceRoot = workFO.createFolder("src");
574.375 - FileObject buildRoot = workFO.createFolder("build");
574.376 - FileObject cache = workFO.createFolder("cache");
574.377 -
574.378 - FileObject data = FileUtil.createData(sourceRoot, fileName);
574.379 - File dataFile = FileUtil.toFile(data);
574.380 -
574.381 - assertNotNull(dataFile);
574.382 -
574.383 - TestUtilities.copyStringToFile(dataFile, code);
574.384 -
574.385 - File ann = InstalledFileLocator.getDefault().locate("libs/annotations.jar", null, false);
574.386 -
574.387 - if (ann == null) {
574.388 - ann = InstalledFileLocator.getDefault().locate("release/libs/annotations.jar", null, false);
574.389 - }
574.390 -
574.391 - assertNotNull(System.getProperty("netbeans.home"), ann);
574.392 -
574.393 - FileObject annFO = FileUtil.toFileObject(ann);
574.394 -
574.395 - assertNotNull(annFO);
574.396 -
574.397 - SourceUtilsTestUtil.prepareTest(sourceRoot, buildRoot, cache, new FileObject[] {FileUtil.getArchiveRoot(annFO)});
574.398 -
574.399 - DataObject od = DataObject.find(data);
574.400 - EditorCookie ec = od.getLookup().lookup(EditorCookie.class);
574.401 -
574.402 - assertNotNull(ec);
574.403 -
574.404 - doc = ec.openDocument();
574.405 - doc.putProperty(Language.class, JavaTokenId.language());
574.406 -
574.407 - JavaSource js = JavaSource.forFileObject(data);
574.408 -
574.409 - assertNotNull(js);
574.410 -
574.411 - info = SourceUtilsTestUtil.getCompilationInfo(js, Phase.RESOLVED);
574.412 -
574.413 - assertNotNull(info);
574.414 -
574.415 - if (!ignoreErrors) {
574.416 - assertEquals(info.getDiagnostics().toString(), 0, info.getDiagnostics().size());
574.417 - }
574.418 - }
574.419 -
574.420 - private FileObject sourceRoot;
574.421 - private CompilationInfo info;
574.422 - private Document doc;
574.423 - private String wordDirPath;
574.424 -
574.425 - protected void performNoExceptionsTest(String code, String type) throws Exception {
574.426 - String wDP = getWorkDirPath();
574.427 -
574.428 - int offset = code.indexOf('|');
574.429 -
574.430 - code = code.replace("|", "");
574.431 -
574.432 - File prev = null;
574.433 -
574.434 - for (int i = 0; i < type.length(); i++) {
574.435 - StringBuilder nueCode = new StringBuilder();
574.436 -
574.437 - nueCode.append(code);
574.438 - nueCode.insert(offset, type.substring(0, i + 1));
574.439 -
574.440 - this.wordDirPath = wDP + File.separatorChar + i;
574.441 -
574.442 - performAnalysisTest(nueCode.toString(), null, true);
574.443 -
574.444 - if (prev != null) {
574.445 - deleteFile(prev);
574.446 - FileUtil.refreshFor(File.listRoots());
574.447 - }
574.448 -
574.449 - prev = getWorkDir();
574.450 - }
574.451 - }
574.452 -
574.453 - protected void performAnalysisTest(String code, String... golden) throws Exception {
574.454 - performAnalysisTest(code, golden, false);
574.455 - }
574.456 -
574.457 - protected void performAnalysisTest(String code, String[] golden, boolean ignoreErrors) throws Exception {
574.458 - prepareTest("test/Test.java", code, ignoreErrors);
574.459 -
574.460 - List<ErrorDescription> warnings = computeWarnings();
574.461 - List<String> dns = new LinkedList<String>();
574.462 -
574.463 - for (ErrorDescription ed : warnings) {
574.464 - dns.add(ed.toString());
574.465 - }
574.466 -
574.467 - if (golden != null) {
574.468 - assertEquals(Arrays.asList(golden), dns);
574.469 - }
574.470 - }
574.471 -
574.472 - protected String performFixTest(String fileName, String code, String errorDescriptionToString, String fixDebugString, String golden) throws Exception {
574.473 - prepareTest(fileName, code);
574.474 -
574.475 - List<ErrorDescription> errors = computeWarnings();
574.476 -
574.477 - ErrorDescription toFix = null;
574.478 -
574.479 - for (ErrorDescription d : errors) {
574.480 - if (errorDescriptionToString.equals(d.toString())) {
574.481 - toFix = d;
574.482 - break;
574.483 - }
574.484 - }
574.485 -
574.486 - assertNotNull("Error: \"" + errorDescriptionToString + "\" not found. All ErrorDescriptions: " + errors.toString(), toFix);
574.487 -
574.488 - assertTrue("Must be computed", toFix.getFixes().isComputed());
574.489 -
574.490 - List<Fix> fixes = toFix.getFixes().getFixes();
574.491 - List<String> fixNames = new LinkedList<String>();
574.492 - Fix toApply = null;
574.493 -
574.494 - for (Fix f : fixes) {
574.495 - if (fixDebugString.equals(toDebugString(info, f))) {
574.496 - toApply = f;
574.497 - }
574.498 -
574.499 - fixNames.add(toDebugString(info, f));
574.500 - }
574.501 -
574.502 - assertNotNull("Cannot find fix to invoke: " + fixNames.toString(), toApply);
574.503 -
574.504 - toApply.implement();
574.505 -
574.506 - FileObject toCheck = sourceRoot.getFileObject(fileName);
574.507 -
574.508 - assertNotNull(toCheck);
574.509 -
574.510 - DataObject toCheckDO = DataObject.find(toCheck);
574.511 - EditorCookie ec = toCheckDO.getCookie(EditorCookie.class);
574.512 - Document toCheckDocument = ec.openDocument();
574.513 -
574.514 - String realCode = toCheckDocument.getText(0, toCheckDocument.getLength());
574.515 -
574.516 - //ignore whitespaces:
574.517 - realCode = realCode.replaceAll("[ \t\n]+", " ");
574.518 -
574.519 - if (golden != null) {
574.520 - golden = golden.replaceAll("[ \t\n]+", " ");
574.521 - assertEquals("The output code does not match the expected code.", golden, realCode);
574.522 - }
574.523 -
574.524 - LifecycleManager.getDefault().saveAll();
574.525 -
574.526 - return realCode;
574.527 - }
574.528 -
574.529 - private String toDebugString(CompilationInfo info, Fix f) {
574.530 - return "FixImpl";
574.531 - }
574.532 -
574.533 - @Override
574.534 - public String getWorkDirPath() {
574.535 - if (this.wordDirPath != null) {
574.536 - return this.wordDirPath;
574.537 - }
574.538 -
574.539 - return super.getWorkDirPath();
574.540 - }
574.541 -
574.542 - private static void deleteFile(File file) throws IOException {
574.543 - if (file.isDirectory()) {
574.544 - // file is a directory - delete sub files first
574.545 - File files[] = file.listFiles();
574.546 - for (int i = 0; i < files.length; i++) {
574.547 - deleteFile(files[i]);
574.548 - }
574.549 -
574.550 - }
574.551 - // file is a File :-)
574.552 - boolean result = file.delete();
574.553 - if (result == false ) {
574.554 - // a problem has appeared
574.555 - throw new IOException("Cannot delete file, file = "+file.getPath());
574.556 - }
574.557 - }
574.558 -}