Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Trofimov
2015-02-10 18:09:51 +01:00
243 changed files with 3895 additions and 2635 deletions
+3 -38
View File
@@ -1,46 +1,11 @@
<component name="libraryTable">
<library name="Groovy">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/groovy-all-2.2.1.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/groovy-all-2.3.7.jar!/"/>
</CLASSES>
<JAVADOC />
<JAVADOC/>
<SOURCES>
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/src/tck/src" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/src/main" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/src/test" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/src/examples" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/src/test-resources" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/buildSrc/src/main/java" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/benchmark/bench" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-ant/src/main/java" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-ant/src/test/groovy" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-ant/src/test-resources" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-bsf/src/main/java" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-bsf/src/test/java" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-jmx/src/main/java" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-jmx/src/test/java" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-jmx/src/test/groovy" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-sql/src/main/java" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-xml/src/main/java" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-xml/src/test/groovy" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-json/src/main/java" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-json/src/main/groovy" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-test/src/main/java" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-test/src/test/groovy" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-swing/src/main/java" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-swing/src/main/groovy" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-swing/src/test/groovy" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-jsr223/src/main/java" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-jsr223/src/test/java" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-testng/src/main/java" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-console/src/main/groovy" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-servlet/src/main/java" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-servlet/src/test/java" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-groovysh/src/main/groovy" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-groovydoc/src/main/java" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-groovydoc/src/test/groovy" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-templates/src/main/java" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.2.1.zip!/groovy-2.2.1/subprojects/groovy-templates/src/test/java" />
<root url="jar://$PROJECT_DIR$/lib/src/groovy-all-2.3.7-sources.jar!/"/>
</SOURCES>
</library>
</component>
+1 -1
View File
@@ -1,4 +1,4 @@
# Use ${idea.home} macro to specify location relative to IDE installation home.
# Use ${idea.home.path} macro to specify location relative to IDE installation home.
# Use ${xxx} where xxx is any Java property (including defined in previous lines of this file) to refer to its value.
# Note for Windows users: please make sure you're using forward slashes (e.g. c:/idea/system).
+3
View File
@@ -36,6 +36,9 @@
1.5 => plugins/Groovy/lib/groovy_rt.jar
1.5 => lib/annotations.jar
1.7 => lib/groovy-all-2.3.7.jar!org/codehaus/groovy/runtime/WritablePath.class
1.7 => lib/groovy-all-2.3.7.jar!org/codehaus/groovy/runtime/NioGroovyMethods.class
1.6 => plugins/gradle/lib/gradle-jps-plugin.jar
1.3 => plugins/junit/lib/junit-rt.jar
+1 -1
View File
@@ -4,5 +4,5 @@ IDS_APP_TITLE=__IDE-NAME__ Launcher
IDS_VM_OPTIONS_PATH=%USERPROFILE%\\.__PRODUCT_PATHS_SELECTOR__
IDC_WINLAUNCHER=__IDE-NAME___LAUNCHER
IDS_PROPS_ENV_VAR=__IDE-NAME___PROPERTIES
IDS_VM_OPTIONS_ENV_VAR=__IDE-NAME___VM_OPTIONS
IDS_VM_OPTIONS_ENV_VAR=__IDE-NAME__64_VM_OPTIONS
IDS_ERROR_LAUNCHING_APP=Error launching __IDE-NAME__
+50 -26
View File
@@ -1,27 +1,30 @@
Gant -- A Groovy way of scripting Ant tasks.
This is Gant, a Groovy way of working with Ant tasks -- no more XML :-)
The method of installation depends on whether you have downloaded a tarball or
zipfile distribution, or you have a Bazaar branch -- or a Subversion checkout,
or even a Git clone -- of the source.
zipfile distribution, or you have a Git clone -- or even a Bazaar branch -- of
the source.
Distribution
------------
The Gant distributions contain a ready-made install directory hierarchy.
Untar the tarball or unzip the zipfile to the location where you want the Gant
installation to reside. A directory with the name structured
installation to reside. A directory with the name structured
gant-<gant-version-number> will be created in the location specified for the
untar or unzip.
There are a number of distinct distributions:
1. Requires a separate Groovy installation. There are builds:
a. compiled against Groovy 1.6.7; and
b. compiled against Groovy 1.7-rc-2.
1. Requires a separate Groovy installation. There are builds:
a. compiled against Groovy 1.7.10; and
b. compiled against Groovy 1.8.6; and
c. compiled against Groovy 2.0.0-beta-2
2. Self-contained, includes all dependent jars.
2. Self-contained, includes all dependent jars.
You might like to set up an environment variable GANT_HOME set to the
directory created by the untar or unzip, though this is not essential, it is
@@ -30,33 +33,31 @@ just an efficiency.
The script $GANT_HOME/bin/gant for systems with a Posix shell, or
$GANT_HOME/bin/gant.bat on Windows is the mechanism for launching a Gant run.
Distributions 1a and 1b only include the direct Gant materials. The Maven
Distributions 1a, 1b and 1c only include the direct Gant materials. The Maven
target set depends on use of the Maven Ant tasks, and the Ivy tool depends on
the Ivy jar, these will have to be downloaded and installed into
$GANT_HOME/lib unless they are already available on on your CLASSPATH.
Using a Bazaar Branch
---------------------
You first need to get a source tree. Bazaar is the version control system
used for developing Gant. For reasons that are unlikely to become apparent
quickly, the master branch is actually held in the Subversion repository at
Codehaus. However the effective mainline is a branch on Launchpad. So to get
a branch:
Using a Git Clone
-----------------
bzr branch lp:gant Gant_Trunk
Gant's mainline is a Git repository on GitHub, see
or
https://github.com/Gant/Gant
bzr branch http://svn.codehaus.org/gant/gant/trunk Gant_Trunk
you should fork this on GitHub and then clone to give you a local repository.
(If you are going to actively develop Gant, you almost certainly want to have
a shared repository in which this mirror branch is kept so that you can then
make feature branches from it.)
The repository on Codehaus at:
git://git.codehaus.org/gant.git
is an administrative clone of the GitHub mainline and should not be used in
normal circumstances.
Gradle is used as the build system for Gant, so you will need to set the
gant_installPath property in ~/.gradle/gradle.properties so you can install
Gant. So for example:
Gant. So for example:
gant_installPath = ${System.properties.'user.home'}/lib/JavaPackages/gant-trunk
@@ -64,22 +65,45 @@ Then you type:
./gradlew :gant:install
and all the necessary magic happens. The first time you use the Gradle
and all the necessary magic happens. The first time you use the Gradle
Wrapper, it will connect to the Internet to download the various jars that
comprise Gradle. This takes a while. However this is only needed the first
comprise Gradle. This takes a while. However this is only needed the first
time, thereafter it uses the version you downloaded.
You probably want to set the GROOVY_HOME environment variable to point at the
Groovy installation that the Gant installation is to work with.
Using a Bazaar Branch
---------------------
For anyone prefering to use Bazaar rather than Git, there is an automated
bridge of the master branch of the Git clone on Launchpad.
To get a branch:
bzr branch lp:gant Gant
or if you want to use bzr-git directly:
bzr branch git://github.com/Gant/Gant.git Gant
(If you are going to actively develop Gant, you almost certainly want to have
a shared repository in which this mirror branch is kept so that you can then
make feature branches from it.)
All the information in the previous section about Gradle and building Gant
apply when using Bazaar.
Contact
-------
If you have any problems using Gant, or have any ideas for improvements,
please make use of the Gant users mailing list: user@gant.codehaus.org
Russel Winder <russel.winder@concertant.com>
Russel Winder <russel@winder.org.uk>
;;; Local Variables: ***
;;; fill-column: 78 ***
+20 -12
View File
@@ -2,7 +2,7 @@
# Gant -- A Groovy way of scripting Ant tasks.
#
# Copyright © 2006-9 Russel Winder
# Copyright © 2006–2010, 2013 Russel Winder
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
@@ -14,12 +14,9 @@
# implied. See the License for the specific language governing permissions and limitations under the
# License.
#
# Author : Russel Winder <russel.winder@concertant.com>
# Author : Russel Winder <russel@winder.org.uk>
# Gant initiation script for Linux and UNIX -- stand alone version.
# This version does not require a GROOVY_HOME to be set since it has all the necessary jars in the
# $GANT_HOME/lib directory.
# Gant initiation script for Linux and UNIX -- requires Groovy version.
# Solaris 10 does not have readlink as standard -- though some people will have the version from
# Sunfreeware which is the same as the version on Ubuntu, Cygwin, MSYS, etc. Mac OS X has a version of
@@ -27,9 +24,9 @@
#
# This function attempts to just do the right thing.
doReadLink ( ) {
doReadLink() {
case `uname` in
Darwin )
Darwin)
gantLocation=`dirname $1`
gantPath=`readlink "$1"`
if [ "$gantPath" = "" ]
@@ -46,7 +43,7 @@ doReadLink ( ) {
cd $currentDirectory
fi
;;
SunOS )
SunOS)
readlinkPath=`which readlink`
if [ `expr "$readlinkPath" : '\([^ ]*\)'` = "no" ]
then
@@ -56,7 +53,7 @@ doReadLink ( ) {
readlinkValue=`readlink -f $1`
fi
;;
* )
*)
readlinkValue=`readlink -f $1`
;;
esac
@@ -77,9 +74,20 @@ then
GANT_HOME=`dirname $GANT_HOME`
fi
# Force GROOVY_HOME to be GANT_HOME so that the startGroovy code does the right thing.
# If GROOVY_HOME is not set, deduce a path -- this is needed in order to discover the location of the
# startGroovy script. Assume the executable is in $GROOVY_HOME/bin.
GROOVY_HOME="$GANT_HOME"
if [ -z "$GROOVY_HOME" ]
then
GROOVY_HOME=`which groovy`
if [ -h $GROOVY_HOME ]
then
doReadLink $GROOVY_HOME GROOVY_HOME
GROOVY_HOME=$readlinkValue
fi
GROOVY_HOME=`dirname "$GROOVY_HOME"`
GROOVY_HOME=`dirname "$GROOVY_HOME"`
fi
# If ANT_HOME is not set, deduce a path -- this is needed in order to discover the location of the jars
# associated with the Ant installation. Assume the executable is in $ANT_HOME/bin.
+15 -7
View File
@@ -14,7 +14,7 @@
@rem implied. See the License for the specific language governing permissions and limitations under the
@rem License.
@rem
@rem Author : Russel Winder <russel.winder@concertant.com>
@rem Author : Russel Winder <russel@winder.org.uk>
@rem Gant initiation script for Windows.
@@ -27,12 +27,20 @@ if "%DIRNAME%" == "" set DIRNAME=.\
@rem If GANT_HOME is not set, deduce a path.
if not "%GANT_HOME%" == "" goto endSetGantHome
set GANT_HOME=%DIRNAME%..
set GANT_HOME="%DIRNAME%.."
:endSetGantHome
@rem Force GROOVY_HOME to be GANT_HOME so that the startGroovy code does the right thing.
@rem If GROOVY_HOME is not set, deduce a path -- this is needed in order to discover the location of the
@rem startGroovy script.
set GROOVY_HOME=%GANT_HOME%
if not "%GROOVY_HOME%" == "" goto endSetGroovyHome
for %%P in ( %PATH% ) do if exist %%P\groovy.exe set GROOVY_HOME=%%P\..
if not "%GROOVY_HOME%" == "" goto endSetGroovyHome
for %%P in ( %PATH% ) do if exist %%P\groovy.bat set GROOVY_HOME=%%P\..
if not "%GROOVY_HOME%" == "" goto endSetGroovyHome
call :environmentVariableError GROOVY_HOME
goto :EOF
:endSetGroovyHome
@rem If ANT_HOME is not set, deduce a path -- this is needed in order to discover the location of the jars
@rem asscoiated with the Ant installation.
@@ -46,15 +54,15 @@ if not "%ANT_HOME%" == "" goto endSetAntHome
set PROGNAME=gant.bat
set GROOVY_SCRIPT_NAME=gant.bat
set STARTER_CONF=%GANT_HOME%\conf\gant-starter.conf
set STARTER_CONF="%GANT_HOME%\conf\gant-starter.conf"
set JAVA_OPTS=%JAVA_OPTS% -Dgant.home="%GANT_HOME%" -Dant.home="%ANT_HOME%"
%GANT_HOME%\bin\startGroovy.bat %DIRNAME% gant.Gant lib %*
"%GANT_HOME%\bin\startGroovy.bat" "%DIRNAME%" gant.Gant %*
@rem End local scope for the variables with windows NT shell
if "%OS%" == "Windows_NT" endlocal
exit /B %ERRORLEVEL%
%COMSPEC% /C exit /B %ERRORLEVEL%
:environmentVariableError
echo.
-272
View File
@@ -1,272 +0,0 @@
# -*- mode:sh -*-
##############################################################################
## ##
## Groovy JVM Bootstrap for UN*X ##
## ##
##############################################################################
##
## $Revision$
## $Date$
##
PROGNAME=`basename "$0"`
#DIRNAME=`dirname "$0"`
SCRIPT_PATH="$0"
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "${PROGNAME}: $*"
}
die ( ) {
warn "$*"
exit 1
}
earlyInit ( ) {
return
}
lateInit ( ) {
return
}
GROOVY_STARTUP="$HOME/.groovy/startup"
if [ -r "$GROOVY_STARTUP" ] ; then
. "$GROOVY_STARTUP"
fi
earlyInit
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
if [ "$1" = "-cp" -o "$1" = "-classpath" ] ; then
CP=$2
shift 2
fi
# Attempt to set JAVA_HOME if it's not already set.
if [ -z "$JAVA_HOME" ] ; then
if $darwin ; then
[ -z "$JAVA_HOME" -a -d "/Library/Java/Home" ] && export JAVA_HOME="/Library/Java/Home"
[ -z "$JAVA_HOME" -a -d "/System/Library/Frameworks/JavaVM.framework/Home" ] && export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home"
else
javaExecutable="`which javac`"
[ -z "$javaExecutable" -o "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ] && die "JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME."
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
[ `expr "$readLink" : '\([^ ]*\)'` = "no" ] && die "JAVA_HOME not set and readlink not available, please set JAVA_HOME."
javaExecutable="`readlink -f \"$javaExecutable\"`"
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$GROOVY_HOME" ] && GROOVY_HOME=`cygpath --unix "$GROOVY_HOME"`
[ -n "$JAVACMD" ] && JAVACMD=`cygpath --unix "$JAVACMD"`
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CP" ] && CP=`cygpath --path --unix "$CP"`
else
if [ -n "$GROOVY_HOME" -a `expr "$GROOVY_HOME":'\/$'` ] ; then
GROOVY_HOME=`echo $GROOVY_HOME | sed -e 's/\/$//'`
fi
fi
# For MSYS, ensure paths are in appropriate format.
if $msys
then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`( cd "$JAVA_HOME" ; pwd )`
fi
# Attempt to set GROOVY_HOME if it is not already set.
if [ -z "$GROOVY_HOME" -o ! -d "$GROOVY_HOME" ] ; then
# Resolve links: $0 may be a link to groovy's home.
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/.."
GROOVY_HOME="`pwd -P`"
cd "$SAVED"
fi
# Set the default Groovy config if no specific one is mentioned.
if [ -z "$GROOVY_CONF" ] ; then
GROOVY_CONF="$GROOVY_HOME/conf/groovy-starter.conf"
fi
STARTER_CLASSPATH="$GROOVY_HOME/lib/groovy-all-2.2.1.jar"
# Create the final classpath. Setting a classpath using the -cp or -classpath option means not to use the
# global classpath. Groovy behaves then the same as the java interpreter
if [ -n "$CP" ] ; then
CP="$CP":.
elif [ -n "$CLASSPATH" ] ; then
CP="$CLASSPATH":.
else
CP=.
fi
# Determine the Java command to use to start the JVM.
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="java"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
die "JAVA_HOME is not defined correctly, can not execute: $JAVACMD"
fi
if [ -z "$JAVA_HOME" ] ; then
warn "JAVA_HOME environment variable is not set"
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query businessSystem maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# Setup Profiler
useprofiler=false
if [ "$PROFILER" != "" ] ; then
if [ -r "$PROFILER" ] ; then
. $PROFILER
useprofiler=true
else
die "Profiler file not found: $PROFILER"
fi
fi
# For Darwin, use classes.jar for TOOLS_JAR
TOOLS_JAR="$JAVA_HOME/lib/tools.jar"
#if $darwin; then
# TOOLS_JAR="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Classes/classes.jar"
#fi
# For Darwin, add GROOVY_APP_NAME to the JAVA_OPTS as -Xdock:name
if $darwin; then
JAVA_OPTS="$JAVA_OPTS -Xdock:name=$GROOVY_APP_NAME"
# we may also want to set -Xdock:image
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
GROOVY_HOME=`cygpath --mixed "$GROOVY_HOME"`
JAVA_HOME=`cygpath --mixed "$JAVA_HOME"`
GROOVY_CONF=`cygpath --mixed "$GROOVY_CONF"`
CP=`cygpath --path --mixed "$CP"`
TOOLS_JAR=`cygpath --mixed "$TOOLS_JAR"`
STARTER_CLASSPATH=`cygpath --path --mixed "$STARTER_CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GROOVY_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GROOVY_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
if [ $CHECK -ne 0 ] ; then
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
startGroovy ( ) {
CLASS=$1
shift
# Start the Profiler or the JVM
if $useprofiler ; then
runProfiler
else
exec "$JAVACMD" $JAVA_OPTS \
-classpath "$STARTER_CLASSPATH" \
-Dscript.name="$SCRIPT_PATH" \
-Dprogram.name="$PROGNAME" \
-Dgroovy.starter.conf="$GROOVY_CONF" \
-Dgroovy.home="$GROOVY_HOME" \
-Dtools.jar="$TOOLS_JAR" \
$STARTER_MAIN_CLASS \
--main $CLASS \
--conf "$GROOVY_CONF" \
--classpath "$CP" \
"$@"
fi
}
STARTER_MAIN_CLASS=org.codehaus.groovy.tools.GroovyStarter
lateInit
+30 -17
View File
@@ -10,7 +10,7 @@
@rem
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
if "%OS%"=="Windows_NT" setlocal enabledelayedexpansion
set DIRNAME=%~1
shift
@@ -18,9 +18,6 @@ shift
set CLASS=%~1
shift
set JARSPATH=%~1
shift
if exist "%USERPROFILE%/.groovy/preinit.bat" call "%USERPROFILE%/.groovy/preinit.bat"
@rem Determine the command interpreter to execute the "CD" later
@@ -36,7 +33,24 @@ if exist "%SystemRoot%\command\find.exe" set FIND_EXE="%SystemRoot%\command\find
:check_JAVA_HOME
@rem Make sure we have a valid JAVA_HOME
if not "%JAVA_HOME%" == "" goto have_JAVA_HOME
for %%P in (%PATH%) do if exist %%P\..\bin\java.exe set JAVA_HOME=%%P\..
set PATHTMP=%PATH%
:loop
for /f "delims=; tokens=1*" %%i in ("!PATHTMP!") do (
if exist "%%i\..\bin\java.exe" (
set "JAVA_HOME=%%i\.."
goto found_JAVA_HOME
)
set PATHTMP=%%j
goto loop
)
goto check_default_JAVA_EXE
:found_JAVA_HOME
@rem Remove trailing \bin\.. from JAVA_HOME
if "%JAVA_HOME:~-7%"=="\bin\.." SET "JAVA_HOME=%JAVA_HOME:~0,-7%"
set JAVA_EXE=%JAVA_HOME%\bin\java.exe
:check_default_JAVA_EXE
if not "%JAVA_HOME%" == "" goto valid_JAVA_HOME
java -version 2>NUL
if not ERRORLEVEL 1 goto default_JAVA_EXE
@@ -170,8 +184,8 @@ if "x1" == "x%_SKIP%" goto skip_1
rem now unescape -q, -s, -d
set _ARG=%_ARG:-s=*%
set _ARG=%_ARG:-d=-%
set _ARG=%_ARG:-q="%
set _ARG=%_ARG:-d=-%
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %_ARG%
set _ARG=
@@ -203,7 +217,7 @@ set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set STARTER_CLASSPATH=%GROOVY_HOME%\%JARSPATH%\groovy-all-2.2.1.jar;%STARTER_CLASSPATH%
set STARTER_CLASSPATH=%GROOVY_HOME%\lib\groovy-all-2.3.0.jar
if exist "%USERPROFILE%/.groovy/init.bat" call "%USERPROFILE%/.groovy/init.bat"
@@ -221,19 +235,19 @@ set CP=%CLASSPATH%;%CP%
:after_cp
set STARTER_MAIN_CLASS=org.codehaus.groovy.tools.GroovyStarter
if "%STARTER_CONF%" == "" set STARTER_CONF=%GROOVY_HOME%\conf\groovy-starter.conf
set STARTER_CONF=%GROOVY_HOME%\conf\groovy-starter.conf
if "%JAVA_OPTS%" == "" set JAVA_OPTS="-Xmx128m"
set JAVA_OPTS=%JAVA_OPTS% -Dprogram.name="%PROGNAME%"
set JAVA_OPTS=%JAVA_OPTS% -Dgroovy.home="%GROOVY_HOME%"
if not "%TOOLS_JAR%" == "" set JAVA_OPTS=%JAVA_OPTS% -Dtools.jar="%TOOLS_JAR%"
set JAVA_OPTS=%JAVA_OPTS% -Dgroovy.starter.conf="%STARTER_CONF%"
set JAVA_OPTS=%JAVA_OPTS% -Dscript.name="%GROOVY_SCRIPT_NAME%"
set GROOVY_OPTS="-Xmx128m"
set GROOVY_OPTS=%GROOVY_OPTS% -Dprogram.name="%PROGNAME%"
set GROOVY_OPTS=%GROOVY_OPTS% -Dgroovy.home="%GROOVY_HOME%"
if not "%TOOLS_JAR%" == "" set GROOVY_OPTS=%GROOVY_OPTS% -Dtools.jar="%TOOLS_JAR%"
set GROOVY_OPTS=%GROOVY_OPTS% -Dgroovy.starter.conf="%STARTER_CONF%"
set GROOVY_OPTS=%GROOVY_OPTS% -Dscript.name="%GROOVY_SCRIPT_NAME%"
if exist "%USERPROFILE%/.groovy/postinit.bat" call "%USERPROFILE%/.groovy/postinit.bat"
@rem Execute Groovy
"%JAVA_EXE%" %JAVA_OPTS% -classpath "%STARTER_CLASSPATH%" %STARTER_MAIN_CLASS% --main %CLASS% --conf "%STARTER_CONF%" --classpath "%CP%" %CMD_LINE_ARGS%
"%JAVA_EXE%" %GROOVY_OPTS% %JAVA_OPTS% -classpath "%STARTER_CLASSPATH%" %STARTER_MAIN_CLASS% --main %CLASS% --conf "%STARTER_CONF%" --classpath "%CP%" %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
@@ -241,5 +255,4 @@ if "%OS%"=="Windows_NT" endlocal
@rem Optional pause the batch file
if "%GROOVY_BATCH_PAUSE%" == "on" pause
exit /B %ERRORLEVEL%
%COMSPEC% /C exit /B %ERRORLEVEL%
+5 -5
View File
@@ -1,6 +1,6 @@
# Gant -- A Groovy way of scripting Ant tasks.
#
# Copyright © 2008 Russel Winder
# Copyright © 2008, 2010, 2013 Russel Winder
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
@@ -12,17 +12,17 @@
# implied. See the License for the specific language governing permissions and limitations under the
# License.
#
# Author : Russel Winder <russel.winder@concertant.com>
# Author : Russel Winder <russel@winder.org.uk>
# Load user specific libraries that are Gant specific.
load !{user.home}/.gant/lib/*.jar
# Load user specific libraries that are Ant specific.
load !{user.home}/.ant/lib/*.jar
# Load user specific libraries that are for Groovy.
load !{user.home}/.groovy/lib/*.jar
# Load required libraries
load !{gant.home}/lib/*.jar
Binary file not shown.
+4 -1
View File
@@ -85,6 +85,8 @@ target('default': 'The default target') {
system_selector: "IdeaIC${p("component.version.major")}",
tools_jar: true],
home, null, paths, true)
String macZip = "$paths.artifacts/ideaIC-${snapshot}.mac.zip"
notifyArtifactBuilt(macZip)
}
target('build-dist-jars' : 'Target to build jars from locally compiled classes') {
@@ -99,6 +101,8 @@ target('build-dist-jars' : 'Target to build jars from locally compiled classes')
system_selector: "IdeaIC${p("component.version.major")}",
tools_jar: true],
home, null, paths)
String macZip = "$paths.artifacts/ideaIC-${snapshot}.mac.zip"
notifyArtifactBuilt(macZip)
}
private void indexSearchableOptions() {
@@ -152,7 +156,6 @@ def layoutAll(Map args, String home, String out, Paths _paths = null, buildJps =
String macZip = "$paths.artifacts/idea${args.buildNumber}.mac.zip"
buildMacZip(macAppRoot, macZip, [paths.distAll], paths.distMac)
notifyArtifactBuilt(macZip)
buildTarGz("idea-${args.buildNumber}", "$paths.artifacts/idea${args.buildNumber}.tar", [paths.distAll, paths.distUnix])
}
+4 -5
View File
@@ -133,7 +133,7 @@ binding.setVariable("generateLicensesTable", {String filePath, Set<String> usedM
// projectBuilder.info(" $lib.name")
//}
lines.sort(String.CASE_INSENSITIVE_ORDER)
lines.sort(true, String.CASE_INSENSITIVE_ORDER)
File file = new File(filePath)
file.parentFile.mkdirs()
FileWriter out = new FileWriter(file)
@@ -175,13 +175,13 @@ libraryLicense(name: "Apache Lucene", libraryName: "lucene-core-2.4.1.jar", vers
libraryLicense(name: "Apache Sanselan", libraryName: "Sanselan", version: "0.98", license: "Apache 2.0", url: "http://commons.apache.org/sanselan/")
libraryLicense(name: "Automaton", libraryName: "automaton.jar", version: "1.11", license: "BSD", url: "http://www.brics.dk/automaton/", licenseUrl: "http://www.opensource.org/licenses/bsd-license.php")
libraryLicense(name: "DTDParser", version: "1.13", license: "LGPL", url: "http://sourceforge.net/projects/dtdparser/", licenseUrl: "http://www.opensource.org/licenses/lgpl-2.1")
libraryLicense(name: "Gant", version: "1.9.8", libraryName: "gant_groovy2.0-1.9.8.jar", license: "Apache 2.0", url: "http://gant.codehaus.org/", licenseUrl: "http://gant.codehaus.org/Licence")
libraryLicense(name: "Gant", version: "1.9.8", libraryName: "gant-1.9.11_groovy-2.3.0.jar", license: "Apache 2.0", url: "http://gant.codehaus.org/", licenseUrl: "http://gant.codehaus.org/Licence")
libraryLicense(name: "sqljet", version: "bundled with SVNKit", libraryName: "sqljet.jar", license: "link (commercial license)", url: "http://sqljet.com", licenseUrl: "http://svnkit.com/license.html")
libraryLicense(name: "svnkit-javahl", version: "bundled with SVNKit", libraryName: "svnkit-javahl.jar", license: "link (commercial license)", url: "http://www.svnkit.com/", licenseUrl: "http://svnkit.com/license.html")
libraryLicense(name: "Antlr", libraryName: "antlr.jar", version: "3.4", license: "BSD", url: "http://www.antlr.org", licenseUrl: "http://www.antlr.org/license.html")
libraryLicense(name: "Guava", version: "17.0", license: "Apache 2.0", url: "http://code.google.com/p/guava-libraries/", licenseUrl: "http://ant.apache.org/license.html")
libraryLicense(name: "Guava", libraryName: "guava-tools", version: "14.0.1", license: "Apache 2.0", url: "http://code.google.com/p/guava-libraries/", licenseUrl: "http://ant.apache.org/license.html")
libraryLicense(name: "Groovy", version: "2.2.1", license: "Apache 2.0", url: "http://groovy.codehaus.org/")
libraryLicense(name: "Groovy", version: "2.3.7", license: "Apache 2.0", url: "http://groovy.codehaus.org/")
libraryLicense(name: "Gson", version: "2.2.4", libraryName: "gson", license: "Apache 2.0", url: "http://code.google.com/p/google-gson/")
libraryLicense(name: "ini4j", libraryName: "ini4j-0.5.2-patched", version: "0.5.2 (with a patch by JetBrains)", license: "Apache 2.0", url: "http://ini4j.sourceforge.net/", attachedTo: "git4idea")
libraryLicense(name: "ISO RELAX", libraryName: "isorelax.jar", license: "MIT License", url: "http://sourceforge.net/projects/iso-relax/", licenseUrl: "http://www.opensource.org/licenses/mit-license.html")
@@ -278,7 +278,6 @@ libraryLicense(name: "json-smart", libraryName: "json-smart-1.1.1.jar", version:
libraryLicense(name: "fxg-utils", libraryName: "fxg-utils", version: "4.9.1", license: "Apache 2.0", url: "http://flex.apache.org", licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0")
libraryLicense(name: "jayatana", libraryName: "jayatana", version: "1.2.4", license: "MIT License", url: "https://code.google.com/p/java-swing-ayatana/", licenseUrl: "http://opensource.org/licenses/mit-license.php")
libraryLicense(name: "ForkJoin", version: "", license: "Creative Commons Public Domain Dedication", url: "http://gee.cs.oswego.edu/dl/concurrency-interest/index.html", licenseUrl: "http://creativecommons.org/publicdomain/zero/1.0/")
libraryLicense(name: "ANTLR 4 Runtime", libraryName: "antlr-runtime-4.1.jar", version: "4.1", license: "BSD", url: "http://www.antlr.org", licenseUrl: "http://www.antlr.org/license.html")
libraryLicense(name: "minlog", libraryName: "minlog-1.2.jar", version: "1.2", license: "BSD", url: "https://github.com/EsotericSoftware/minlog", licenseUrl: "http://opensource.org/licenses/BSD-3-Clause")
libraryLicense(name: "ReflectASM", libraryName: "reflectasm-1.0.7.jar", version: "1.0.7", license: "BSD", url: "https://github.com/EsotericSoftware/reflectasm", licenseUrl: "http://opensource.org/licenses/BSD-3-Clause")
libraryLicense(name: "Objenesis", libraryName: "objenesis-1.2.jar", version: "1.2", license: "Apache 2.0", url: "http://objenesis.org/", licenseUrl: "http://apache.org/licenses/LICENSE-2.0")
@@ -290,4 +289,4 @@ jetbrainsLibrary("CoverageReport")
jetbrainsLibrary("JPS")
jetbrainsLibrary("Maven Embedder")
jetbrainsLibrary("tcServiceMessages")
jetbrainsLibrary("optimizedFileManager.jar")
jetbrainsLibrary("optimizedFileManager.jar")
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,7 +53,7 @@ public class AdjustArrayRangeAction extends DebuggerAction {
return;
}
XValue container = node.getValueContainer();
final XValue container = node.getValueContainer();
if (!(container instanceof JavaValue)) {
return;
}
@@ -79,17 +79,14 @@ public class AdjustArrayRangeAction extends DebuggerAction {
public void contextAction() throws Exception {
final Renderer lastRenderer = descriptor.getLastRenderer();
if (lastRenderer instanceof ArrayRenderer) {
descriptor.setRenderer(clonedRenderer);
refreshViews(node);
//selectedNode.setRenderer(clonedRenderer);
((JavaValue)container).setRenderer(clonedRenderer, node);
}
else if (lastRenderer instanceof CompoundNodeRenderer) {
final CompoundNodeRenderer compoundRenderer = (CompoundNodeRenderer)lastRenderer;
final ChildrenRenderer childrenRenderer = compoundRenderer.getChildrenRenderer();
if (childrenRenderer instanceof ExpressionChildrenRenderer) {
ExpressionChildrenRenderer.setPreferableChildrenRenderer(descriptor, clonedRenderer);
refreshViews(node);
//selectedNode.calcRepresentation();
((JavaValue)container).reBuild(node);
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -249,13 +249,13 @@ public class JVMNameUtil {
}
public static JVMName getJVMQualifiedName(PsiClass psiClass) {
if (!PsiUtil.isLocalOrAnonymousClass(psiClass)) {
final String name = getNonAnonymousClassName(psiClass);
if (name != null) {
return getJVMRawText(name);
}
final String name = getNonAnonymousClassName(psiClass);
if (name != null) {
return getJVMRawText(name);
}
else {
return new JVMClassAt(SourcePosition.createFromElement(psiClass));
}
return new JVMClassAt(SourcePosition.createFromElement(psiClass));
}
@Nullable
@@ -264,17 +264,18 @@ public class JVMNameUtil {
if (psiClass == null) {
return null;
}
if (!PsiUtil.isLocalOrAnonymousClass(psiClass)) {
final String name = getNonAnonymousClassName(psiClass);
if (name != null) {
return getJVMRawText(name);
}
final String name = getNonAnonymousClassName(psiClass);
if (name != null) {
return getJVMRawText(name);
}
return new JVMClassAt(pos);
}
@Nullable
public static String getNonAnonymousClassName(PsiClass aClass) {
if (PsiUtil.isLocalOrAnonymousClass(aClass)) {
return null;
}
String name = aClass.getName();
if (name == null) {
return null;
@@ -540,6 +540,11 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV
public void setRenderer(NodeRenderer nodeRenderer, final XValueNodeImpl node) {
DebuggerManagerThreadImpl.assertIsManagerThread();
myValueDescriptor.setRenderer(nodeRenderer);
reBuild(node);
}
public void reBuild(final XValueNodeImpl node) {
DebuggerManagerThreadImpl.assertIsManagerThread();
myCurrentChildrenStart = 0;
node.getTree().getLaterInvocator().offer(new Runnable() {
@Override
@@ -84,7 +84,8 @@ public class PositionManagerImpl implements PositionManager {
return;
}
if (!classHasName(psiClass)) {
String className = JVMNameUtil.getNonAnonymousClassName(psiClass);
if (className == null) {
final PsiClass parent = JVMNameUtil.getTopLevelParentClass(psiClass);
if (parent == null) {
@@ -107,7 +108,7 @@ public class PositionManagerImpl implements PositionManager {
});
}
else {
waitPrepareFor.set(JVMNameUtil.getNonAnonymousClassName(psiClass));
waitPrepareFor.set(className);
waitRequestor.set(requestor);
}
}
@@ -118,10 +119,6 @@ public class PositionManagerImpl implements PositionManager {
return myDebugProcess.getRequestsManager().createClassPrepareRequest(waitRequestor.get(), waitPrepareFor.get());
}
private static boolean classHasName(PsiClass psiClass) {
return !PsiUtil.isLocalOrAnonymousClass(psiClass) && JVMNameUtil.getNonAnonymousClassName(psiClass) != null;
}
public SourcePosition getSourcePosition(final Location location) throws NoDataException {
DebuggerManagerThreadImpl.assertIsManagerThread();
if(location == null) {
@@ -244,7 +241,8 @@ public class PositionManagerImpl implements PositionManager {
final PsiClass psiClass = JVMNameUtil.getClassAt(position);
if (psiClass != null) {
classAtPositionRef.set(psiClass);
if (!classHasName(psiClass)) {
String className = JVMNameUtil.getNonAnonymousClassName(psiClass);
if (className == null) {
isLocalOrAnonymous.set(Boolean.TRUE);
final PsiClass topLevelClass = JVMNameUtil.getTopLevelParentClass(psiClass);
if (topLevelClass != null) {
@@ -259,10 +257,7 @@ public class PositionManagerImpl implements PositionManager {
}
}
else {
final String className = JVMNameUtil.getNonAnonymousClassName(psiClass);
if (className != null) {
baseClassNameRef.set(className);
}
baseClassNameRef.set(className);
}
}
}
@@ -671,7 +671,7 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
@NotNull
@Override
public Navigatable createNavigatable(@NotNull Project project) {
return XSourcePositionImpl.createOpenFileDescriptor(project, this);
return XSourcePositionImpl.doCreateOpenFileDescriptor(project, this);
}
}
+2 -2
View File
@@ -13,6 +13,6 @@
<orderEntry type="module" module-name="java-impl" />
<orderEntry type="library" name="XmlRPC" level="project" />
<orderEntry type="library" name="OroMatcher" level="project" />
<orderEntry type="module" module-name="vcs-impl" />
</component>
</module>
</module>
@@ -0,0 +1,54 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.vcs.checkout;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.CheckoutProvider;
import com.intellij.openapi.vcs.VcsKey;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.platform.PlatformProjectOpenProcessor;
import org.jetbrains.annotations.NotNull;
import java.io.File;
public class NewProjectFromVCSGroup extends CheckoutActionGroup {
@NotNull
@Override
protected AnAction createAction(CheckoutProvider provider) {
return new CheckoutAction(provider) {
@Override
protected CheckoutProvider.Listener getListener(Project project) {
return new CheckoutProvider.Listener() {
@Override
public void directoryCheckedOut(File directory, VcsKey vcs) {
final VirtualFile dir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(directory);
if (dir != null) {
PlatformProjectOpenProcessor.getInstance().doOpenProject(dir, null, false);
}
}
@Override
public void checkoutCompleted() {
}
};
}
};
}
}
@@ -32,6 +32,10 @@ import java.io.FilenameFilter;
* @author yole
*/
public class ProjectCheckoutListener implements CheckoutListener {
public ProjectCheckoutListener() {
}
@Override
public boolean processCheckedOutDirectory(Project project, File directory) {
File[] files = directory.listFiles((FilenameFilter) new GlobFilenameFilter("*" + ProjectFileType.DOT_DEFAULT_EXTENSION));
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -137,11 +137,13 @@ public class AnnotationsHighlightUtil {
formatReference(nameRef), JavaHighlightUtil.formatType(expectedType));
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(value).descriptionAndTooltip(description).create();
}
if (value instanceof PsiArrayInitializerMemberValue) {
if (expectedType instanceof PsiArrayType) return null;
String description = JavaErrorMessages.message("annotation.illegal.array.initializer", JavaHighlightUtil.formatType(expectedType));
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(value).descriptionAndTooltip(description).create();
}
if (value instanceof PsiExpression) {
PsiExpression expr = (PsiExpression)value;
PsiType type = expr.getType();
@@ -160,8 +162,7 @@ public class AnnotationsHighlightUtil {
String description = JavaErrorMessages.message("annotation.incompatible.types",
JavaHighlightUtil.formatType(type), JavaHighlightUtil.formatType(expectedType));
final HighlightInfo info =
HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(value).descriptionAndTooltip(description).create();
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(value).descriptionAndTooltip(description).create();
QuickFixAction.registerQuickFixAction(info, QuickFixFactory.getInstance().createSurroundWithQuotesAnnotationParameterValueFix(value, expectedType));
return info;
}
@@ -185,8 +186,7 @@ public class AnnotationsHighlightUtil {
String containedElementFQN = contained == null ? null : contained.getQualifiedName();
if (containedElementFQN != null) {
PsiClass container = annotationType;
String containerName = container.getQualifiedName();
String containerName = annotationType.getQualifiedName();
if (isAnnotationRepeatedTwice(owner, containedElementFQN)) {
String description = JavaErrorMessages.message("annotation.container.wrong.place", containerName);
return annotationError(annotationToCheck, description);
@@ -197,8 +197,8 @@ public class AnnotationsHighlightUtil {
String description = JavaErrorMessages.message("annotation.duplicate.annotation");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create();
}
PsiAnnotation metaAnno = PsiImplUtil.findAnnotation(annotationType.getModifierList(), CommonClassNames.JAVA_LANG_ANNOTATION_REPEATABLE);
PsiAnnotation metaAnno = PsiImplUtil.findAnnotation(annotationType.getModifierList(), CommonClassNames.JAVA_LANG_ANNOTATION_REPEATABLE);
if (metaAnno == null) {
String explanation = JavaErrorMessages.message("annotation.non.repeatable", annotationType.getQualifiedName());
String description = JavaErrorMessages.message("annotation.duplicate.explained", explanation);
@@ -223,15 +223,6 @@ public class AnnotationsHighlightUtil {
}
}
for (PsiAnnotation annotation : owner.getAnnotations()) {
if (annotation == annotationToCheck) continue;
PsiJavaCodeReferenceElement nameRef = annotation.getNameReferenceElement();
if (nameRef == null) continue;
PsiElement aClass = nameRef.resolve();
if (!resolved.equals(aClass)) continue;
}
return null;
}
@@ -252,15 +243,14 @@ public class AnnotationsHighlightUtil {
return contained;
}
private static boolean isAnnotationRepeatedTwice(@NotNull PsiAnnotationOwner owner, @NotNull String qualifiedName) {
private static boolean isAnnotationRepeatedTwice(@NotNull PsiAnnotationOwner owner, @Nullable String qualifiedName) {
int count = 0;
for (PsiAnnotation annotation : owner.getAnnotations()) {
PsiJavaCodeReferenceElement nameRef = annotation.getNameReferenceElement();
if (nameRef == null) continue;
PsiElement resolved = nameRef.resolve();
if (!(resolved instanceof PsiClass) || !qualifiedName.equals(((PsiClass)resolved).getQualifiedName())) continue;
count++;
if (count == 2) return true;
if (!(resolved instanceof PsiClass) || !Comparing.equal(qualifiedName, ((PsiClass)resolved).getQualifiedName())) continue;
if (++count == 2) return true;
}
return false;
}
@@ -721,7 +711,7 @@ public class AnnotationsHighlightUtil {
if (field instanceof PsiEnumConstant) {
String name = ((PsiEnumConstant)field).getName();
try {
return RetentionPolicy.valueOf(RetentionPolicy.class, name);
return Enum.valueOf(RetentionPolicy.class, name);
}
catch (Exception e) {
LOG.warn("Unknown policy: " + name);
@@ -32,6 +32,7 @@ import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiClassImplUtil;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiShortNamesCache;
import com.intellij.psi.search.searches.ReferencesSearch;
@@ -346,17 +347,21 @@ public class GenericsHighlightUtil {
Map<PsiClass, PsiSubstitutor> inheritedClasses = new HashMap<PsiClass, PsiSubstitutor>();
final TextRange textRange = HighlightNamesUtil.getClassDeclarationTextRange(aClass);
return checkInterfaceMultipleInheritance(aClass,
aClass,
PsiSubstitutor.EMPTY, inheritedClasses,
new HashSet<PsiClass>(), textRange);
}
private static HighlightInfo checkInterfaceMultipleInheritance(PsiClass aClass,
PsiElement place,
PsiSubstitutor derivedSubstitutor,
Map<PsiClass, PsiSubstitutor> inheritedClasses,
Set<PsiClass> visited,
TextRange textRange) {
final PsiClassType[] superTypes = aClass.getSuperTypes();
for (PsiClassType superType : superTypes) {
superType = PsiClassImplUtil.correctType(superType, place.getResolveScope());
if (superType == null) continue;
final PsiClassType.ClassResolveResult result = superType.resolveGenerics();
final PsiClass superClass = result.getElement();
if (superClass == null || visited.contains(superClass)) continue;
@@ -381,7 +386,7 @@ public class GenericsHighlightUtil {
}
inheritedClasses.put(superClass, superTypeSubstitutor);
visited.add(superClass);
final HighlightInfo highlightInfo = checkInterfaceMultipleInheritance(superClass, superTypeSubstitutor, inheritedClasses, visited, textRange);
final HighlightInfo highlightInfo = checkInterfaceMultipleInheritance(superClass, place, superTypeSubstitutor, inheritedClasses, visited, textRange);
visited.remove(superClass);
if (highlightInfo != null) return highlightInfo;
@@ -1185,6 +1190,23 @@ public class GenericsHighlightUtil {
return null;
}
public static HighlightInfo checkEnumWithoutConstantsCantHaveAbstractMethods(final PsiClass aClass) {
if (!aClass.isEnum()) return null;
for (PsiField field : aClass.getFields()) {
if (field instanceof PsiEnumConstant) {
return null;
}
}
for (PsiMethod method : aClass.getMethods()) {
if (method.hasModifierProperty(PsiModifier.ABSTRACT)) {
final String description = "Enum declaration without enum constants cannot have abstract methods";
final TextRange textRange = HighlightNamesUtil.getClassDeclarationTextRange(aClass);
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create();
}
}
return null;
}
public static HighlightInfo checkSelectStaticClassFromParameterizedType(final PsiElement resolved, final PsiJavaCodeReferenceElement ref) {
if (resolved instanceof PsiClass && ((PsiClass)resolved).hasModifierProperty(PsiModifier.STATIC)) {
final PsiElement qualifier = ref.getQualifier();
@@ -1329,5 +1351,60 @@ public class GenericsHighlightUtil {
}
return null;
}
public static HighlightInfo areSupersAccessible(@NotNull PsiClass aClass) {
return areSupersAccessible(aClass, aClass.getResolveScope(), HighlightNamesUtil.getClassDeclarationTextRange(aClass));
}
public static HighlightInfo areSupersAccessible(@NotNull PsiClass aClass, PsiElement ref) {
return areSupersAccessible(aClass, ref.getResolveScope(), ref.getTextRange());
}
private static HighlightInfo areSupersAccessible(@NotNull PsiClass aClass,
GlobalSearchScope resolveScope,
TextRange range) {
final JavaPsiFacade factory = JavaPsiFacade.getInstance(aClass.getProject());
for (PsiClassType superType : aClass.getSuperTypes()) {
final String notAccessibleErrorMessage = isSuperTypeAccessible(superType, new HashSet<PsiClass>(), resolveScope, factory);
if (notAccessibleErrorMessage != null) {
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
.descriptionAndTooltip(notAccessibleErrorMessage)
.range(range)
.create();
}
}
return null;
}
@Nullable
private static String isSuperTypeAccessible(PsiType superType,
HashSet<PsiClass> classes,
GlobalSearchScope resolveScope,
JavaPsiFacade factory) {
final PsiClass aClass = PsiUtil.resolveClassInType(superType);
if (aClass != null && classes.add(aClass)) {
final String qualifiedName = aClass.getQualifiedName();
if (qualifiedName != null && factory.findClass(qualifiedName, resolveScope) == null) {
return "Cannot access " + HighlightUtil.formatClass(aClass);
}
if (superType instanceof PsiClassType) {
for (PsiType psiType : ((PsiClassType)superType).getParameters()) {
final String notAccessibleMessage = isSuperTypeAccessible(psiType, classes, resolveScope, factory);
if (notAccessibleMessage != null) {
return notAccessibleMessage;
}
}
}
for (PsiClassType type : aClass.getSuperTypes()) {
final String notAccessibleMessage = isSuperTypeAccessible(type, classes, resolveScope, factory);
if (notAccessibleMessage != null) {
return notAccessibleMessage;
}
}
}
return null;
}
}
@@ -34,6 +34,7 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiSuperMethodImplUtil;
import com.intellij.psi.infos.CandidateInfo;
import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.util.*;
@@ -1147,25 +1148,22 @@ public class HighlightMethodUtil {
PsiClass aClass = method.getContainingClass();
if (aClass == null) return null;
PsiClass superClass = aClass.getSuperClass();
PsiMethod superMethod = superClass == null
? null
: MethodSignatureUtil.findMethodBySignature(superClass, method, true);
boolean isStatic = method.hasModifierProperty(PsiModifier.STATIC);
HighlightInfo highlightInfo = checkStaticMethodOverride(aClass, method, isStatic,superClass, superMethod,containingFile);
if (highlightInfo != null) return highlightInfo;
if (!isStatic) {
// all methods in interface are instance, so no possible errors in this case
final HierarchicalMethodSignature methodSignature = PsiSuperMethodImplUtil.getHierarchicalMethodSignature(method);
final List<HierarchicalMethodSignature> superSignatures = methodSignature.getSuperSignatures();
if (superSignatures.isEmpty()) {
return null;
}
PsiClass[] interfaces = aClass.getInterfaces();
for (PsiClass aInterfaces : interfaces) {
superClass = aInterfaces;
superMethod = MethodSignatureUtil.findMethodInSuperClassBySignatureInDerived(aClass, superClass, method.getSignature(PsiSubstitutor.EMPTY), true);
highlightInfo = checkStaticMethodOverride(aClass, method, true, superClass, superMethod,containingFile);
if (highlightInfo != null) return highlightInfo;
boolean isStatic = method.hasModifierProperty(PsiModifier.STATIC);
for (HierarchicalMethodSignature signature : superSignatures) {
final PsiMethod superMethod = signature.getMethod();
final PsiClass superClass = superMethod.getContainingClass();
if (superClass == null) continue;
final HighlightInfo highlightInfo = checkStaticMethodOverride(aClass, method, isStatic, superClass, superMethod,containingFile);
if (highlightInfo != null) {
return highlightInfo;
}
}
return null;
}
@@ -381,8 +381,10 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
super.visitClass(aClass);
if (aClass instanceof PsiSyntheticClass) return;
if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkInterfaceMultipleInheritance(aClass));
if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.areSupersAccessible(aClass));
if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkDuplicateTopLevelClass(aClass));
if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkEnumMustNotBeLocal(aClass));
if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkEnumWithoutConstantsCantHaveAbstractMethods(aClass));
if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkImplicitThisReferenceBeforeSuper(aClass, myJavaSdkVersion));
if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkClassAndPackageConflict(aClass));
if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkPublicClassInRightFile(aClass));
@@ -1220,7 +1222,14 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
}
if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkAccessStaticFieldFromEnumConstructor(expression, result));
if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkClassReferenceAfterQualifier(expression, resolved));
myHolder.add(HighlightUtil.checkUnqualifiedSuperInDefaultMethod(myLanguageLevel, expression, expression.getQualifierExpression()));
final PsiExpression qualifierExpression = expression.getQualifierExpression();
myHolder.add(HighlightUtil.checkUnqualifiedSuperInDefaultMethod(myLanguageLevel, expression, qualifierExpression));
if (!myHolder.hasErrorResults() && qualifierExpression != null) {
final PsiClass psiClass = PsiUtil.resolveClassInType(qualifierExpression.getType());
if (psiClass != null) {
myHolder.add(GenericsHighlightUtil.areSupersAccessible(psiClass, qualifierExpression));
}
}
}
@Override
@@ -25,6 +25,7 @@ import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.ui.JavaVisibilityPanel;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.ToolbarDecorator;
@@ -67,7 +68,7 @@ public class CodeStyleGenerationConfigurable implements Configurable {
mySettings = settings;
myMembersOrderList = new MembersOrderList();
myPanel.setBorder(IdeBorderFactory.createEmptyBorder(2, 2, 2, 2));
myJavaVisibilityPanel = new JavaVisibilityPanel(false, true);
myJavaVisibilityPanel = new JavaVisibilityPanel(false, true, RefactoringBundle.message("default.visibility.border.title"));
}
public JComponent createComponent() {
@@ -128,6 +128,11 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer
return "IntroduceVariable";
}
@Override
protected String getRefactoringId() {
return "refactoring.extractVariable";
}
@Override
protected void restoreState(@NotNull PsiVariable psiField) {
if (myDeleteSelf) return;
@@ -159,6 +164,15 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer
}
}
@Override
protected PsiExpression getBeforeExpr() {
final PsiVariable variable = getVariable();
if (variable != null) {
return variable.getInitializer();
}
return super.getBeforeExpr();
}
@Override
protected void performIntroduce() {
final PsiVariable psiVariable = getVariable();
@@ -105,7 +105,7 @@ abstract class SafeDeleteJavaCallerChooser extends JavaCallerChooser {
/**
* @return parameter if it is used inside method only as argument in nodeMethod call at parameterIndex
*/
static PsiParameter isTheOnlyOneParameterUsage(PsiElement call, int parameterIndex, final PsiMethod nodeMethod) {
static PsiParameter isTheOnlyOneParameterUsage(PsiElement call, final int parameterIndex, final PsiMethod nodeMethod) {
if (call instanceof PsiCallExpression) {
final PsiExpressionList argumentList = ((PsiCallExpression)call).getArgumentList();
if (argumentList != null) {
@@ -129,6 +129,7 @@ abstract class SafeDeleteJavaCallerChooser extends JavaCallerChooser {
if (parameter != null && !parameter.isVarArgs()) {
final PsiElement scope = parameter.getDeclarationScope();
if (scope instanceof PsiMethod && ((PsiMethod)scope).findDeepestSuperMethods().length == 0) {
final int scopeParamIdx = ((PsiMethod)scope).getParameterList().getParameterIndex(parameter);
final Ref<Boolean> ref = new Ref<Boolean>(false);
if (ReferencesSearch.search(parameter, new LocalSearchScope(scope)).forEach(new Processor<PsiReference>() {
@Override
@@ -139,11 +140,11 @@ abstract class SafeDeleteJavaCallerChooser extends JavaCallerChooser {
while (parent != null) {
final PsiMethod resolved = parent.resolveMethod();
if (scope.equals(resolved)) {
if (usedInQualifier(element, parent)) return false;
if (usedInQualifier(element, parent, scopeParamIdx)) return false;
return true;
}
if (nodeMethod.equals(resolved)) {
if (usedInQualifier(element, parent)) return false;
if (usedInQualifier(element, parent, parameterIndex)) return false;
ref.set(true);
return true;
}
@@ -154,7 +155,7 @@ abstract class SafeDeleteJavaCallerChooser extends JavaCallerChooser {
return true;
}
private boolean usedInQualifier(PsiElement element, PsiCallExpression parent) {
private boolean usedInQualifier(PsiElement element, PsiCallExpression parent, int parameterIndex) {
PsiExpression qualifier = null;
if (parent instanceof PsiMethodCallExpression) {
qualifier = ((PsiMethodCallExpression)parent).getMethodExpression();
@@ -162,7 +163,13 @@ abstract class SafeDeleteJavaCallerChooser extends JavaCallerChooser {
else if (parent instanceof PsiNewExpression) {
qualifier = ((PsiNewExpression)parent).getQualifier();
}
return PsiTreeUtil.isAncestor(qualifier, element, true);
if (PsiTreeUtil.isAncestor(qualifier, element, true)) {
return true;
}
final PsiExpressionList list = parent.getArgumentList();
return list != null && !PsiTreeUtil.isAncestor(list.getExpressions()[parameterIndex], element, false);
}
}) && ref.get()) {
return parameter;
@@ -46,7 +46,13 @@ public class JavaVisibilityPanel extends VisibilityPanelBase<String> {
private final JRadioButton myRbPublic;
public JavaVisibilityPanel(boolean hasAsIs, final boolean hasEscalate) {
setBorder(IdeBorderFactory.createTitledBorder(RefactoringBundle.message("visibility.border.title"), true,
this(hasAsIs, hasEscalate, RefactoringBundle.message("visibility.border.title"));
}
public JavaVisibilityPanel(boolean hasAsIs,
final boolean hasEscalate,
String visibilityTitle) {
setBorder(IdeBorderFactory.createTitledBorder(visibilityTitle, true,
new Insets(IdeBorderFactory.TITLED_BORDER_TOP_INSET,
UIUtil.DEFAULT_HGAP,
IdeBorderFactory.TITLED_BORDER_BOTTOM_INSET,
@@ -823,8 +823,9 @@ public final class PsiUtil extends PsiUtilCore {
@Nullable
public static PsiMember findEnclosingConstructorOrInitializer(PsiElement expression) {
PsiMember parent = PsiTreeUtil.getParentOfType(expression, PsiClassInitializer.class, PsiEnumConstantInitializer.class, PsiMethod.class);
PsiMember parent = PsiTreeUtil.getParentOfType(expression, PsiClassInitializer.class, PsiEnumConstantInitializer.class, PsiMethod.class, PsiField.class);
if (parent instanceof PsiMethod && !((PsiMethod)parent).isConstructor()) return null;
if (parent instanceof PsiField && parent.hasModifierProperty(PsiModifier.STATIC)) return null;
return parent;
}
@@ -33,10 +33,7 @@ import com.intellij.psi.scope.NameHint;
import com.intellij.psi.scope.PsiScopeProcessor;
import com.intellij.psi.scope.processor.FilterScopeProcessor;
import com.intellij.psi.scope.processor.MethodResolverProcessor;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.LocalSearchScope;
import com.intellij.psi.search.PackageScope;
import com.intellij.psi.search.SearchScope;
import com.intellij.psi.search.*;
import com.intellij.psi.util.*;
import com.intellij.ui.IconDeferrer;
import com.intellij.ui.RowIcon;
@@ -61,7 +58,7 @@ import java.util.*;
*/
public class PsiClassImplUtil {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.PsiClassImplUtil");
private static final Key<ParameterizedCachedValue<MembersMap, PsiClass>> MAP_IN_CLASS_KEY = Key.create("MAP_KEY");
private static final Key<ParameterizedCachedValue<Map<GlobalSearchScope, MembersMap>, PsiClass>> MAP_IN_CLASS_KEY = Key.create("MAP_KEY");
private static final String VALUES_METHOD = "values";
private static final String VALUE_OF_METHOD = "valueOf";
@@ -215,13 +212,13 @@ public class PsiClassImplUtil {
public enum MemberType {CLASS, FIELD, METHOD}
private static Map<String, List<Pair<PsiMember, PsiSubstitutor>>> getMap(@NotNull PsiClass aClass, @NotNull MemberType type) {
ParameterizedCachedValue<MembersMap, PsiClass> value = getValues(aClass);
return value.getValue(aClass).get(type);
ParameterizedCachedValue<Map<GlobalSearchScope, MembersMap>, PsiClass> value = getValues(aClass);
return value.getValue(aClass).get(aClass.getResolveScope()).get(type);
}
@NotNull
private static ParameterizedCachedValue<MembersMap, PsiClass> getValues(@NotNull PsiClass aClass) {
ParameterizedCachedValue<MembersMap, PsiClass> value = aClass.getUserData(MAP_IN_CLASS_KEY);
private static ParameterizedCachedValue<Map<GlobalSearchScope, MembersMap>, PsiClass> getValues(@NotNull PsiClass aClass) {
ParameterizedCachedValue<Map<GlobalSearchScope, MembersMap>, PsiClass> value = aClass.getUserData(MAP_IN_CLASS_KEY);
if (value == null) {
value = CachedValuesManager.getManager(aClass.getProject()).createParameterizedCachedValue(ByNameCachedValueProvider.INSTANCE, false);
//Do not cache for nonphysical elements
@@ -361,9 +358,11 @@ public class PsiClassImplUtil {
private static class MembersMap extends ConcurrentFactoryMap<MemberType, Map<String, List<Pair<PsiMember, PsiSubstitutor>>>> {
private final PsiClass myPsiClass;
private final GlobalSearchScope myResolveScope;
public MembersMap(PsiClass psiClass) {
public MembersMap(PsiClass psiClass, GlobalSearchScope scope) {
myPsiClass = psiClass;
myResolveScope = scope;
}
@Nullable
@@ -397,17 +396,24 @@ public class PsiClassImplUtil {
};
processDeclarationsInClassNotCached(myPsiClass, processor, ResolveState.initial(), null, null, myPsiClass, false,
PsiUtil.getLanguageLevel(myPsiClass));
PsiUtil.getLanguageLevel(myPsiClass), myResolveScope);
return map;
}
}
private static class ByNameCachedValueProvider implements ParameterizedCachedValueProvider<MembersMap, PsiClass> {
private static class ByNameCachedValueProvider implements ParameterizedCachedValueProvider<Map<GlobalSearchScope, MembersMap>, PsiClass> {
private static final ByNameCachedValueProvider INSTANCE = new ByNameCachedValueProvider();
@Override
public CachedValueProvider.Result<MembersMap> compute(@NotNull PsiClass myClass) {
return new CachedValueProvider.Result<MembersMap>(new MembersMap(myClass), PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
public CachedValueProvider.Result<Map<GlobalSearchScope, MembersMap>> compute(@NotNull final PsiClass myClass) {
final Map<GlobalSearchScope, MembersMap> map = new ConcurrentFactoryMap<GlobalSearchScope, MembersMap>() {
@Nullable
@Override
protected MembersMap create(GlobalSearchScope resolveScope) {
return new MembersMap(myClass, resolveScope);
}
};
return CachedValueProvider.Result.create(map, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
}
}
@@ -438,6 +444,18 @@ public class PsiClassImplUtil {
@NotNull PsiElement place,
@NotNull LanguageLevel languageLevel,
boolean isRaw) {
return processDeclarationsInClass(aClass, processor, state, visited, last, place, languageLevel, isRaw, place.getResolveScope());
}
private static boolean processDeclarationsInClass(@NotNull PsiClass aClass,
@NotNull final PsiScopeProcessor processor,
@NotNull ResolveState state,
@Nullable Set<PsiClass> visited,
PsiElement last,
@NotNull PsiElement place,
@NotNull LanguageLevel languageLevel,
boolean isRaw,
@NotNull GlobalSearchScope resolveScope) {
if (last instanceof PsiTypeParameterList || last instanceof PsiModifierList) {
return true; //TypeParameterList and ModifierList do not see our declarations
}
@@ -446,16 +464,17 @@ public class PsiClassImplUtil {
PsiSubstitutor substitutor = state.get(PsiSubstitutor.KEY);
isRaw = isRaw || PsiUtil.isRawSubstitutor(aClass, substitutor);
ParameterizedCachedValue<MembersMap, PsiClass> cache = getValues(aClass); //aClass.getUserData(MAP_IN_CLASS_KEY);
ParameterizedCachedValue<Map<GlobalSearchScope, MembersMap>, PsiClass> cache = getValues(aClass); //aClass.getUserData(MAP_IN_CLASS_KEY);
boolean upToDate = cache.hasUpToDateValue();
if (/*true || */upToDate) {
final NameHint nameHint = processor.getHint(NameHint.KEY);
if (nameHint != null) {
String name = nameHint.getName(state);
return processCachedMembersByName(aClass, processor, state, visited, last, place, isRaw, substitutor, cache.getValue(aClass), name,languageLevel);
return processCachedMembersByName(aClass, processor, state, visited, last, place, isRaw, substitutor,
cache.getValue(aClass).get(resolveScope), name,languageLevel);
}
}
return processDeclarationsInClassNotCached(aClass, processor, state, visited, last, place, isRaw, languageLevel);
return processDeclarationsInClassNotCached(aClass, processor, state, visited, last, place, isRaw, languageLevel, resolveScope);
}
private static boolean processCachedMembersByName(@NotNull PsiClass aClass,
@@ -628,7 +647,8 @@ public class PsiClassImplUtil {
PsiElement last,
@NotNull PsiElement place,
boolean isRaw,
@NotNull LanguageLevel languageLevel) {
@NotNull LanguageLevel languageLevel,
@NotNull GlobalSearchScope resolveScope) {
if (visited == null) visited = new THashSet<PsiClass>();
if (!visited.add(aClass)) return true;
processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, aClass);
@@ -686,7 +706,50 @@ public class PsiClassImplUtil {
}
return last instanceof PsiReferenceList || processSuperTypes(aClass, processor, visited, last, place, state, isRaw, factory,
languageLevel);
languageLevel, resolveScope);
}
@Nullable
public static PsiClassType correctType(PsiClassType originalType, final GlobalSearchScope resolveScope) {
final PsiClassType.ClassResolveResult originalResolveResult = originalType.resolveGenerics();
PsiClass superClass = originalResolveResult.getElement();
if (superClass == null) {
return originalType;
}
String qualifiedName = superClass.getQualifiedName();
if (qualifiedName != null && !PsiSearchScopeUtil.isInScope(resolveScope, superClass)) {
PsiClass originalSuperClass = superClass;
PsiSubstitutor originalSubstitutor = originalResolveResult.getSubstitutor();
superClass = JavaPsiFacade.getInstance(superClass.getProject()).findClass(qualifiedName, resolveScope);
if (superClass == null) {
return null;
}
PsiTypeParameter[] typeParameters = superClass.getTypeParameters();
PsiTypeParameter[] originalTypeParameters = originalSuperClass.getTypeParameters();
if (typeParameters.length != originalTypeParameters.length) return null;
PsiSubstitutor substitutor = PsiSubstitutor.EMPTY;
for (int i = 0; i < originalTypeParameters.length; i++) {
PsiType originalSubstitute = originalSubstitutor.substitute(originalTypeParameters[i]);
if (originalSubstitute != null) {
PsiType substitute = originalSubstitute.accept(new PsiTypeVisitor<PsiType>() {
@Nullable
@Override
public PsiType visitClassType(PsiClassType classType) {
return correctType(classType, resolveScope);
}
});
if (substitute == null) return null;
substitutor = substitutor.put(typeParameters[i], substitute);
}
}
return JavaPsiFacade.getElementFactory(superClass.getProject()).createType(superClass, substitutor);
}
return originalType;
}
private static boolean processSuperTypes(@NotNull PsiClass aClass,
@@ -697,15 +760,19 @@ public class PsiClassImplUtil {
@NotNull ResolveState state,
boolean isRaw,
@NotNull PsiElementFactory factory,
@NotNull LanguageLevel languageLevel) {
@NotNull LanguageLevel languageLevel, GlobalSearchScope resolveScope) {
boolean resolved = false;
for (final PsiClassType superType : aClass.getSuperTypes()) {
for (PsiClassType superType : aClass.getSuperTypes()) {
superType = correctType(superType, resolveScope);
if (superType == null) continue;
final PsiClassType.ClassResolveResult superTypeResolveResult = superType.resolveGenerics();
PsiClass superClass = superTypeResolveResult.getElement();
if (superClass == null) continue;
PsiSubstitutor finalSubstitutor = obtainFinalSubstitutor(superClass, superTypeResolveResult.getSubstitutor(), aClass,
state.get(PsiSubstitutor.KEY), factory, languageLevel);
if (!processDeclarationsInClass(superClass, processor, state.put(PsiSubstitutor.KEY, finalSubstitutor), visited, last, place, languageLevel, isRaw)) {
if (!processDeclarationsInClass(superClass, processor, state.put(PsiSubstitutor.KEY, finalSubstitutor), visited, last, place,
languageLevel, isRaw, resolveScope)) {
resolved = true;
}
}
@@ -24,6 +24,7 @@ import com.intellij.openapi.util.Pair;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.HierarchicalMethodSignatureImpl;
import com.intellij.psi.impl.source.PsiClassImpl;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.searches.DeepestSuperMethodsSearch;
import com.intellij.psi.search.searches.SuperMethodsSearch;
import com.intellij.psi.util.*;
@@ -45,7 +46,7 @@ public class PsiSuperMethodImplUtil {
@NotNull
@Override
public Map<MethodSignature, HierarchicalMethodSignature> fun(PsiClass dom) {
return buildMethodHierarchy(dom, null, PsiSubstitutor.EMPTY, true, new THashSet<PsiClass>(), false);
return buildMethodHierarchy(dom, null, PsiSubstitutor.EMPTY, true, new THashSet<PsiClass>(), false, dom.getResolveScope());
}
});
private static final PsiCacheKey<FactoryMap<String, Map<MethodSignature, HierarchicalMethodSignature>>, PsiClass> SIGNATURES_BY_NAME_KEY = PsiCacheKey
@@ -56,7 +57,7 @@ public class PsiSuperMethodImplUtil {
@Nullable
@Override
protected Map<MethodSignature, HierarchicalMethodSignature> create(String methodName) {
return buildMethodHierarchy(psiClass, methodName, PsiSubstitutor.EMPTY, true, new THashSet<PsiClass>(), false);
return buildMethodHierarchy(psiClass, methodName, PsiSubstitutor.EMPTY, true, new THashSet<PsiClass>(), false, psiClass.getResolveScope());
}
};
}
@@ -131,7 +132,8 @@ public class PsiSuperMethodImplUtil {
@NotNull PsiSubstitutor substitutor,
final boolean includePrivates,
@NotNull final Set<PsiClass> visited,
boolean isInRawContext) {
boolean isInRawContext,
GlobalSearchScope resolveScope) {
ProgressManager.checkCanceled();
Map<MethodSignature, HierarchicalMethodSignature> result = new LinkedHashMap<MethodSignature, HierarchicalMethodSignature>();
final Map<MethodSignature, List<PsiMethod>> sameParameterErasureMethods = new THashMap<MethodSignature, List<PsiMethod>>(MethodSignatureUtil.METHOD_PARAMETERS_ERASURE_EQUALITY);
@@ -189,6 +191,8 @@ public class PsiSuperMethodImplUtil {
}
for (PsiClassType superType : aClass.getSuperTypes()) {
superType = PsiClassImplUtil.correctType(superType, resolveScope);
if (superType == null) continue; //super class doesn't belong to resolve scope
PsiClassType.ClassResolveResult superTypeResolveResult = superType.resolveGenerics();
PsiClass superClass = superTypeResolveResult.getElement();
if (superClass == null) continue;
@@ -197,7 +201,7 @@ public class PsiSuperMethodImplUtil {
PsiSubstitutor finalSubstitutor = obtainFinalSubstitutor(superClass, superSubstitutor, substitutor, isInRawContext);
final boolean isInRawContextSuper = (isInRawContext || PsiUtil.isRawSubstitutor(superClass, superSubstitutor)) && superClass.getTypeParameters().length != 0;
Map<MethodSignature, HierarchicalMethodSignature> superResult = buildMethodHierarchy(superClass, nameHint, finalSubstitutor, false, visited, isInRawContextSuper);
Map<MethodSignature, HierarchicalMethodSignature> superResult = buildMethodHierarchy(superClass, nameHint, finalSubstitutor, false, visited, isInRawContextSuper, resolveScope);
visited.remove(superClass);
List<Pair<MethodSignature, HierarchicalMethodSignature>> flattened = new ArrayList<Pair<MethodSignature, HierarchicalMethodSignature>>();
@@ -303,9 +307,11 @@ public class PsiSuperMethodImplUtil {
if (superClass != null) {
if (superClass.isInterface() ||
CommonClassNames.JAVA_LANG_OBJECT.equals(superClass.getQualifiedName())) {
if (superMethod.hasModifierProperty(PsiModifier.STATIC)) {
if (superMethod.hasModifierProperty(PsiModifier.STATIC) ||
superMethod.hasModifierProperty(PsiModifier.DEFAULT) && hierarchicalMethodSignature.getMethod().hasModifierProperty(PsiModifier.STATIC)) {
return false;
}
if (superMethod.hasModifierProperty(PsiModifier.DEFAULT) ||
hierarchicalMethodSignature.getMethod().hasModifierProperty(PsiModifier.DEFAULT)) {
return !InheritanceUtil.isInheritorOrSelf(superClass, containingClass, true);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -132,7 +132,10 @@ public class PsiAnnotationImpl extends JavaStubPsiElement<PsiAnnotationStub> imp
}
else if (parent instanceof PsiJavaCodeReferenceElement) {
PsiElement ctx = PsiTreeUtil.skipParentsOfType(parent, PsiJavaCodeReferenceElement.class);
if (ctx instanceof PsiReferenceList || ctx instanceof PsiNewExpression || ctx instanceof PsiTypeElement) {
if (ctx instanceof PsiReferenceList ||
ctx instanceof PsiNewExpression ||
ctx instanceof PsiTypeElement ||
ctx instanceof PsiAnonymousClass) {
return new PsiClassReferenceType((PsiJavaCodeReferenceElement)parent, null);
}
}
@@ -534,6 +534,13 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return Specifics.FIRST;
}
if (method1.hasModifierProperty(PsiModifier.DEFAULT) && method2.hasModifierProperty(PsiModifier.STATIC)) {
return Specifics.FIRST;
}
if (method2.hasModifierProperty(PsiModifier.DEFAULT) && method1.hasModifierProperty(PsiModifier.STATIC)) {
return Specifics.SECOND;
}
}
if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && myArgumentsList instanceof PsiExpressionList && (typeParameters1.length == 0 || typeParameters2.length == 0)) {
@@ -0,0 +1,13 @@
enum MyEnumTest {
FOO;
MyEnumTest Foo = <error descr="It is illegal to access static member 'FOO' from enum constructor or instance initializer">FOO</error>;
{
MyEnumTest foo = <error descr="It is illegal to access static member 'FOO' from enum constructor or instance initializer">FOO</error>;
}
static MyEnumTest Bar = FOO;
MyEnumTest() {
System.out.println(<error descr="It is illegal to access static member 'Bar' from enum constructor or instance initializer">Bar</error>);
}
}
@@ -0,0 +1,4 @@
<error descr="Enum declaration without enum constants cannot have abstract methods">enum MyEnumTest</error> {
;
public abstract void m();
}
@@ -59,6 +59,7 @@ class Outer {
{
new @TA Object();
new @TA ArrayList<String>();
new @TA Runnable() { public void run() { } }.run();
ArrayList<String> var = new <String> @TA ArrayList();
new @TA Outer().new @TA Middle();
@@ -0,0 +1,18 @@
class Test {
interface I {
default void f() {}
}
interface J {
static void f() {}
}
static class IJ implements I, J {}
static class JI implements J, I {}
public static void main(String[] args) {
new IJ(). f();
new JI(). f();
J.f();
}
}
@@ -0,0 +1,7 @@
package p;
class Sample {
public static void main(String[] args) {
ChildClass.<error descr="Cannot resolve method 'foo()'">foo</error>();
}
}
@@ -0,0 +1,10 @@
package p;
abstract class B {
void f(A a) {
<error descr="Cannot access java.util.stream.Stream">a</error>.foo();
}
void f(java.util.List<? extends A> a) {
<error descr="Cannot access java.util.stream.Stream">a.get(0)</error>.foo();
}
}
@@ -0,0 +1,14 @@
package p;
abstract class B extends A {
public static String getOrDefault(Object key, String defaultValue) {
return null;
}
}
abstract class C extends A {
<error descr="Method does not override method from its superclass">@Override</error>
public String getOrDefault(Object key, String defaultValue) {
return null;
}
}
@@ -0,0 +1,3 @@
package p;
public class ChildClass extends BaseClass {}
@@ -1,2 +1,3 @@
package p;
<error descr="Cannot access java.util.stream.Stream">abstract class B extends A</error>{}
<error descr="Cannot access java.util.stream.Stream">abstract class B extends A</error>{}
<error descr="Cannot access java.util.stream.Stream">abstract class C extends A1</error>{}
@@ -0,0 +1,7 @@
package p;
import java.util.stream.Stream;
import java.util.List;
public abstract class A implements List<Stream<String>> {
public void foo() {}
}
@@ -0,0 +1,5 @@
package p;
import java.util.Map;
public abstract class A implements Map<String, String> {}
@@ -0,0 +1,6 @@
package p;
public class BaseClass {
public static void foo() {
}
}
@@ -3,4 +3,5 @@ import java.util.stream.Stream;
import java.util.List;
public abstract class A implements List<Stream<String>> {
}
}
abstract class A1 extends A {}
@@ -0,0 +1,7 @@
class Test {
void foo(String <caret>s, String p) {}
void bar(String s, String p) {
foo(s, s.substring(0));
}
}
@@ -0,0 +1,7 @@
class Test {
void foo(String p) {}
void bar(String s, String p) {
foo(s.substring(0));
}
}
@@ -34,6 +34,7 @@ import java.util.Calendar;
public class MultipleJdksHighlightingTest extends UsefulTestCase {
private CodeInsightTestFixture myFixture;
private Module myJava6Module;
private Module myJava7Module;
private Module myJava8Module;
@@ -47,6 +48,7 @@ public class MultipleJdksHighlightingTest extends UsefulTestCase {
super.tearDown();
myFixture.tearDown();
myFixture = null;
myJava6Module = null;
myJava7Module = null;
myJava8Module = null;
}
@@ -57,12 +59,24 @@ public class MultipleJdksHighlightingTest extends UsefulTestCase {
TestFixtureBuilder<IdeaProjectTestFixture> projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName());
myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(projectBuilder.getFixture());
myFixture.setTestDataPath(PathManagerEx.getTestDataPath() + "/codeInsight/multipleJdks");
final JavaModuleFixtureBuilder[] builders = new JavaModuleFixtureBuilder[2];
final JavaModuleFixtureBuilder[] builders = new JavaModuleFixtureBuilder[3];
builders[0] = projectBuilder.addModule(JavaModuleFixtureBuilder.class);
builders[1] = projectBuilder.addModule(JavaModuleFixtureBuilder.class);
builders[2] = projectBuilder.addModule(JavaModuleFixtureBuilder.class);
myFixture.setUp();
myJava7Module = builders[0].getFixture().getModule();
myJava8Module = builders[1].getFixture().getModule();
myJava6Module = builders[0].getFixture().getModule();
myJava7Module = builders[1].getFixture().getModule();
myJava8Module = builders[2].getFixture().getModule();
ModuleRootModificationUtil.updateModel(myJava6Module, new Consumer<ModifiableRootModel>() {
@Override
public void consume(ModifiableRootModel model) {
model.addModuleOrderEntry(myJava7Module);
model.setSdk(IdeaTestUtil.getMockJdk17());
String contentUrl = VfsUtilCore.pathToUrl(myFixture.getTempDirPath()) + "/java6";
model.addContentEntry(contentUrl).addSourceFolder(contentUrl, false);
}
});
ModuleRootModificationUtil.updateModel(myJava7Module, new Consumer<ModifiableRootModel>() {
@Override
public void consume(ModifiableRootModel model) {
@@ -87,7 +101,6 @@ public class MultipleJdksHighlightingTest extends UsefulTestCase {
doTest();
}
@Bombed(month = Calendar.FEBRUARY, day = 20)
public void testWrongSuperInLibrary() throws Exception {
final String name = getTestName(false);
for (Module module : new Module[] {myJava7Module, myJava8Module}) {
@@ -102,43 +115,55 @@ public class MultipleJdksHighlightingTest extends UsefulTestCase {
myFixture.configureByFile("java8/p/" + name + ".java");
myFixture.checkHighlighting();
}
@Bombed(month = Calendar.FEBRUARY, day = 20)
public void testWrongComparator() throws Exception {
doTestWithoutLibrary();
}
@Bombed(month = Calendar.FEBRUARY, day = 20)
public void testGenericComparator() throws Exception {
doTestWithoutLibrary();
}
@Bombed(month = Calendar.FEBRUARY, day = 20)
public void testGenericCallableWithDifferentTypeArgs() throws Exception {
doTestWithoutLibrary();
}
@Bombed(month = Calendar.FEBRUARY, day = 20)
public void testSuperclassImplementsUnknownType() throws Exception {
doTestWithoutLibrary();
}
public void testDeclaredTypeOfVariableImplementsUnknownType() throws Exception {
doTestWithoutLibrary();
}
@Bombed(month = Calendar.FEBRUARY, day = 20)
public void testSuperclassImplementsGenericsOfUnknownType() throws Exception {
doTestWithoutLibrary();
}
@Bombed(month = Calendar.FEBRUARY, day = 20)
public void testSuperMethodNotExist() throws Exception {
doTestWithoutLibrary();
}
public void testNoOverriding() throws Exception {
doTestWithoutLibrary();
}
public void testStaticCallOnChildWithNotAccessibleParent() throws Exception {
doTest3Modules();
}
private void doTestWithoutLibrary() {
final String name = getTestName(false);
myFixture.configureByFiles("java7/p/" + name + ".java", "java8/p/" + name + ".java");
myFixture.checkHighlighting();
}
private void doTest3Modules() {
final String name = getTestName(false);
myFixture.configureByFiles("java6/p/" + name + ".java", "java7/p/" + name + ".java", "java8/p/" + name + ".java");
myFixture.checkHighlighting();
}
private void doTest() {
final String name = getTestName(false);
@@ -68,6 +68,8 @@ public class LightAdvHighlightingJdk6Test extends LightDaemonAnalyzerTestCase {
public void testUnsupportedFeatures7() { doTest(false, false); }
public void testEnumInitializers() { doTest(false, false); }
public void testEnumSynthetics() { doTest(false, false); }
public void testEnumWithoutConstants() { doTest(false, false); }
public void testEnumInstanceFieldInitializer() { doTest(false, false); }
public void testIDEA79251() { doTest(false, false); }
public void testIDEA65473() { doTest(false, false); }
public void testIDEA61415() { doTest(false, false); }
@@ -79,6 +79,10 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testPreferDefaultMethodsOverStatic() throws Exception {
doTest();
}
private void doTest() {
doTest(true);
}
@@ -92,6 +92,10 @@ public class SafeDeleteTest extends MultiFileTestCase {
doSingleFileTest();
}
public void testNoDeepDeleteParameterUsedInNextArgumentExpression() throws Exception {
doSingleFileTest();
}
public void testToDeepDeleteParameterOverriders() throws Exception {
doSingleFileTest();
}
@@ -740,18 +740,19 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
PsiElement[] typeparams = null;
if (el2 instanceof PsiJavaCodeReferenceElement) {
typeparams = ((PsiJavaCodeReferenceElement)el2).getParameterList().getTypeParameterElements();
final PsiReferenceParameterList parameterList = ((PsiJavaCodeReferenceElement)el2).getParameterList();
if (parameterList != null) {
typeparams = parameterList.getTypeParameterElements();
}
}
else if (el2 instanceof PsiTypeParameter) {
el2 = ((PsiTypeParameter)el2).getNameIdentifier();
}
else if (el2 instanceof PsiClass && ((PsiClass)el2).hasTypeParameters()
) {
else if (el2 instanceof PsiClass && ((PsiClass)el2).hasTypeParameters()) {
typeparams = ((PsiClass)el2).getTypeParameters();
el2 = ((PsiClass)el2).getNameIdentifier();
}
else if (el2 instanceof PsiMethod && ((PsiMethod)el2).hasTypeParameters()
) {
else if (el2 instanceof PsiMethod && ((PsiMethod)el2).hasTypeParameters()) {
typeparams = ((PsiMethod)_type2).getTypeParameters();
el2 = ((PsiMethod)_type2).getNameIdentifier();
}
@@ -10,19 +10,21 @@ import com.intellij.structuralsearch.impl.matcher.MatchUtils;
*/
public final class ReadPredicate extends MatchPredicate {
public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) {
PsiElement parent = matchedNode.getParent();
if (matchedNode instanceof PsiIdentifier) {
matchedNode = matchedNode.getParent();
matchedNode = parent;
parent = matchedNode.getParent();
}
if (matchedNode instanceof PsiReferenceExpression &&
( !(matchedNode.getParent() instanceof PsiMethodCallExpression) &&
( !(matchedNode.getParent() instanceof PsiAssignmentExpression) ||
((PsiAssignmentExpression)matchedNode.getParent()).getLExpression() != matchedNode
)
) &&
MatchUtils.getReferencedElement(matchedNode) instanceof PsiVariable
) {
return true;
if (!(matchedNode instanceof PsiReferenceExpression) || parent instanceof PsiMethodCallExpression) {
return false;
}
return false;
if (parent instanceof PsiAssignmentExpression) {
final PsiAssignmentExpression assignmentExpression = (PsiAssignmentExpression)parent;
if (assignmentExpression.getLExpression() == matchedNode &&
assignmentExpression.getOperationTokenType() == JavaTokenType.EQ) {
return false;
}
}
return MatchUtils.getReferencedElement(matchedNode) instanceof PsiVariable;
}
}
@@ -30,6 +30,13 @@ public abstract class JdkVersionDetector {
return JpsServiceManager.getInstance().getService(JdkVersionDetector.class);
}
/**
* Returns java version for JDK located at {@code homePath} in format like<br>
* <tt>java version "1.8.0_40"</tt><br>
* by running '<tt>java -version</tt>' command
* @param homePath path to JDK home directory
* @return version string of {@code null} if version cannot be determined
*/
@Nullable
public abstract String detectJdkVersion(String homePath);
@@ -16,7 +16,7 @@
<orderEntry type="module-library" scope="PROVIDED">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../build/lib/gant/lib/gant_groovy2.1-1.9.10.jar!/" />
<root url="jar://$MODULE_DIR$/../../build/lib/gant/lib/gant-1.9.11_groovy-2.3.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -15,7 +15,7 @@ fluent-hc-4.3.6.jar
freemarker.jar
httpmime-4.3.6.jar
ecj-4.4.jar
groovy-all-2.2.1.jar
groovy-all-2.3.7.jar
gson-2.3.jar
guava-17.0.jar
hamcrest-core-1.3.jar
Binary file not shown.
Binary file not shown.
@@ -20,6 +20,7 @@ import com.intellij.util.Consumer;
import com.intellij.util.net.NetUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.concurrency.AsyncPromise;
import org.jetbrains.io.NettyUtil;
import javax.swing.*;
@@ -84,8 +85,10 @@ public abstract class NetService implements Disposable {
@Override
public void run() {
if (!result.isRejected()) {
AsyncPromise<OSProcessHandler> promise = new AsyncPromise<OSProcessHandler>();
try {
connectToProcess(result, port, processHandler, processListener);
connectToProcess(promise, port, processHandler, processListener);
promise.notify(result);
}
catch (Throwable e) {
result.setRejected();
@@ -121,11 +124,11 @@ public abstract class NetService implements Disposable {
@Nullable
protected abstract OSProcessHandler createProcessHandler(@NotNull Project project, int port) throws ExecutionException;
protected void connectToProcess(@NotNull AsyncResult<OSProcessHandler> asyncResult,
protected void connectToProcess(@NotNull AsyncPromise<OSProcessHandler> promise,
int port,
@NotNull OSProcessHandler processHandler,
@NotNull Consumer<String> errorOutputConsumer) {
asyncResult.setDone(processHandler);
promise.setResult(processHandler);
}
protected abstract void closeProcessConnections();
@@ -2,12 +2,12 @@ package org.jetbrains.builtInWebServer;
import com.intellij.execution.process.OSProcessHandler;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.AsyncResult;
import com.intellij.util.Consumer;
import com.intellij.util.net.NetUtils;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.concurrency.AsyncPromise;
import org.jetbrains.io.NettyUtil;
import java.net.InetSocketAddress;
@@ -22,12 +22,12 @@ public abstract class SingleConnectionNetService extends NetService {
protected abstract void configureBootstrap(@NotNull Bootstrap bootstrap, @NotNull Consumer<String> errorOutputConsumer);
@Override
protected void connectToProcess(@NotNull AsyncResult<OSProcessHandler> asyncResult, int port, @NotNull OSProcessHandler processHandler, @NotNull Consumer<String> errorOutputConsumer) {
protected void connectToProcess(@NotNull AsyncPromise<OSProcessHandler> promise, int port, @NotNull OSProcessHandler processHandler, @NotNull Consumer<String> errorOutputConsumer) {
Bootstrap bootstrap = NettyUtil.oioClientBootstrap();
configureBootstrap(bootstrap, errorOutputConsumer);
processChannel = NettyUtil.connectClient(bootstrap, new InetSocketAddress(NetUtils.getLoopbackAddress(), port), asyncResult);
processChannel = NettyUtil.connect(bootstrap, new InetSocketAddress(NetUtils.getLoopbackAddress(), port), promise);
if (processChannel != null) {
asyncResult.setDone(processHandler);
promise.setResult(processHandler);
}
}
@@ -1,4 +1,4 @@
package org.jetbrains.fastCgi;
package org.jetbrains.io.fastCgi;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.util.text.StringUtilRt;
@@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.io.Responses;
import org.jetbrains.io.SimpleChannelInboundHandlerAdapter;
import static org.jetbrains.fastCgi.FastCgiService.LOG;
import static org.jetbrains.io.fastCgi.FastCgiService.LOG;
@ChannelHandler.Sharable
public class FastCgiChannelHandler extends SimpleChannelInboundHandlerAdapter<FastCgiResponse> {
@@ -1,4 +1,4 @@
package org.jetbrains.fastCgi;
package org.jetbrains.io.fastCgi;
public final class FastCgiConstants {
public static final int HEADER_LENGTH = 8;
@@ -1,4 +1,4 @@
package org.jetbrains.fastCgi;
package org.jetbrains.io.fastCgi;
import com.intellij.util.Consumer;
import gnu.trove.TIntObjectHashMap;
@@ -10,7 +10,7 @@ import io.netty.util.CharsetUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.io.Decoder;
import static org.jetbrains.fastCgi.FastCgiService.LOG;
import static org.jetbrains.io.fastCgi.FastCgiService.LOG;
public class FastCgiDecoder extends Decoder {
private enum State {
@@ -1,4 +1,4 @@
package org.jetbrains.fastCgi;
package org.jetbrains.io.fastCgi;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
@@ -1,4 +1,4 @@
package org.jetbrains.fastCgi;
package org.jetbrains.io.fastCgi;
import io.netty.buffer.ByteBuf;
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.fastCgi;
package org.jetbrains.io.fastCgi;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
@@ -32,20 +32,26 @@ import com.intellij.psi.impl.PsiManagerEx;
import com.intellij.psi.impl.source.tree.MarkersHolderFileViewProvider;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.reference.SoftReference;
import com.intellij.util.containers.UnsafeWeakList;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
public class SmartPointerManagerImpl extends SmartPointerManager {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl");
private final Project myProject;
private final Object lock = new Object();
private final Key<List<SmartPointerEx>> POINTERS_KEY;
private static final Object lock = new Object();
private static final ReferenceQueue<SmartPointerEx> ourQueue = new ReferenceQueue<SmartPointerEx>();
private final Key<Set<PointerReference>> POINTERS_KEY;
private final Key<Boolean> POINTERS_ARE_FASTENED_KEY;
public SmartPointerManagerImpl(Project project) {
@@ -54,23 +60,33 @@ public class SmartPointerManagerImpl extends SmartPointerManager {
POINTERS_ARE_FASTENED_KEY = Key.create("SMART_POINTERS_ARE_FASTENED for "+project);
}
private static void processQueue() {
while (true) {
PointerReference reference = (PointerReference)ourQueue.poll();
if (reference == null) break;
synchronized (lock) {
Set<PointerReference> pointers = reference.file.getUserData(reference.key);
if (pointers != null) {
pointers.remove(reference);
if (pointers.isEmpty()) {
reference.file.putUserData(reference.key, null);
}
}
}
}
}
public void fastenBelts(@NotNull VirtualFile file, int offset, @Nullable RangeMarker[] cachedRangeMarkers) {
ApplicationManager.getApplication().assertIsDispatchThread();
processQueue();
synchronized (lock) {
List<SmartPointerEx> pointers = getPointers(file);
if (pointers == null) return;
List<SmartPointerEx> pointers = getStrongPointers(file);
if (pointers.isEmpty()) return;
if (getAndFasten(file)) return;
if (pointers.isEmpty()) {
file.putUserData(POINTERS_KEY, null);
}
else {
// pointers might change in fastenBelt()
List<SmartPointerEx> strongPointers = ((UnsafeWeakList<SmartPointerEx>)pointers).toStrongList();
for (SmartPointerEx pointer : strongPointers) {
pointer.fastenBelt(offset, cachedRangeMarkers);
}
for (SmartPointerEx pointer : pointers) {
pointer.fastenBelt(offset, cachedRangeMarkers);
}
PsiFile psiFile = ((PsiManagerEx)PsiManager.getInstance(myProject)).getFileManager().getCachedPsiFile(file);
@@ -103,21 +119,15 @@ public class SmartPointerManagerImpl extends SmartPointerManager {
public void unfastenBelts(@NotNull VirtualFile file, int offset) {
ApplicationManager.getApplication().assertIsDispatchThread();
processQueue();
synchronized (lock) {
List<SmartPointerEx> pointers = getPointers(file);
if (pointers == null) return;
List<SmartPointerEx> pointers = getStrongPointers(file);
if (pointers.isEmpty()) return;
if (!getAndUnfasten(file)) return;
if (pointers.isEmpty()) {
file.putUserData(POINTERS_KEY, null);
}
else {
// pointers might change in unfastenBelt()
List<SmartPointerEx> strongPointers = ((UnsafeWeakList<SmartPointerEx>)pointers).toStrongList();
for (SmartPointerEx pointer : strongPointers) {
pointer.unfastenBelt(offset);
}
for (SmartPointerEx pointer : pointers) {
pointer.unfastenBelt(offset);
}
PsiFile psiFile = ((PsiManagerEx)PsiManager.getInstance(myProject)).getFileManager().getCachedPsiFile(file);
@@ -147,6 +157,7 @@ public class SmartPointerManagerImpl extends SmartPointerManager {
PsiUtilCore.ensureValid(element);
LOG.error("Invalid element:" + element);
}
processQueue();
SmartPointerEx<E> pointer = getCachedPointer(element);
if (pointer != null) {
containingFile = containingFile == null ? element.getContainingFile() : containingFile;
@@ -197,12 +208,12 @@ public class SmartPointerManagerImpl extends SmartPointerManager {
private <E extends PsiElement> void initPointer(@NotNull SmartPointerEx<E> pointer, @NotNull VirtualFile containingFile) {
synchronized (lock) {
List<SmartPointerEx> pointers = getPointers(containingFile);
Set<PointerReference> pointers = getPointers(containingFile);
if (pointers == null) {
pointers = new UnsafeWeakList<SmartPointerEx>(); // we synchronise access anyway
pointers = ContainerUtil.newTroveSet(); // we synchronise access anyway
containingFile.putUserData(POINTERS_KEY, pointers);
}
pointers.add(pointer);
pointers.add(new PointerReference(pointer, containingFile, ourQueue, POINTERS_KEY));
if (areBeltsFastened(containingFile)) {
pointer.fastenBelt(0, null);
@@ -222,26 +233,45 @@ public class SmartPointerManagerImpl extends SmartPointerManager {
}
PsiFile containingFile = pointer.getContainingFile();
if (containingFile == null) return false;
List<SmartPointerEx> pointers = getPointers(containingFile.getViewProvider().getVirtualFile());
Set<PointerReference> pointers = getPointers(containingFile.getViewProvider().getVirtualFile());
if (pointers == null) return false;
SmartPointerElementInfo info = ((SmartPsiElementPointerImpl)pointer).getElementInfo();
info.cleanup();
return pointers.remove(pointer);
for (Iterator<PointerReference> iterator = pointers.iterator(); iterator.hasNext(); ) {
if (pointer == iterator.next().get()) {
iterator.remove();
return true;
}
}
return false;
}
}
}
return false;
}
private List<SmartPointerEx> getPointers(@NotNull VirtualFile containingFile) {
@Nullable
private Set<PointerReference> getPointers(@NotNull VirtualFile containingFile) {
return containingFile.getUserData(POINTERS_KEY);
}
@NotNull
private List<SmartPointerEx> getStrongPointers(@NotNull VirtualFile containingFile) {
Set<PointerReference> refs = getPointers(containingFile);
if (refs == null) return Collections.emptyList();
List<SmartPointerEx> result = ContainerUtil.newArrayList();
for (PointerReference reference : refs) {
ContainerUtil.addIfNotNull(result, reference.get());
}
return result;
}
@TestOnly
public int getPointersNumber(@NotNull PsiFile containingFile) {
synchronized (lock) {
List<SmartPointerEx> pointers = getPointers(containingFile.getViewProvider().getVirtualFile());
return pointers == null ? 0 : ((UnsafeWeakList)pointers).toStrongList().size();
return getStrongPointers(containingFile.getViewProvider().getVirtualFile()).size();
}
}
@@ -263,4 +293,19 @@ public class SmartPointerManagerImpl extends SmartPointerManager {
public boolean pointToTheSameElement(@NotNull SmartPsiElementPointer pointer1, @NotNull SmartPsiElementPointer pointer2) {
return SmartPsiElementPointerImpl.pointsToTheSameElementAs(pointer1, pointer2);
}
private static class PointerReference extends WeakReference<SmartPointerEx> {
private final VirtualFile file;
private final Key<Set<PointerReference>> key;
public PointerReference(SmartPointerEx<?> pointer,
VirtualFile containingFile,
ReferenceQueue<SmartPointerEx> queue,
Key<Set<PointerReference>> key) {
super(pointer, queue);
file = containingFile;
this.key = key;
}
}
}
@@ -70,7 +70,7 @@ public enum Side {
}
@NotNull
public <T> T selectN(@NotNull T left, @NotNull T right) {
public <T> T selectNotNull(@NotNull T left, @NotNull T right) {
return isLeft() ? left : right;
}
@@ -86,7 +86,7 @@ public enum Side {
}
@NotNull
public <T> T selectN(@NotNull T[] array) {
public <T> T selectNotNull(@NotNull T[] array) {
assert array.length == 2;
return array[myIndex];
}
@@ -98,7 +98,7 @@ public enum Side {
}
@NotNull
public <T> T selectN(@NotNull List<T> list) {
public <T> T selectNotNull(@NotNull List<T> list) {
assert list.size() == 2;
return list.get(myIndex);
}
@@ -109,7 +109,7 @@ public enum Side {
}
@NotNull
public <T> T selectN(@NotNull Couple<T> region) {
public <T> T selectNotNull(@NotNull Couple<T> region) {
return isLeft() ? region.first : region.second;
}
@@ -48,7 +48,7 @@ public enum ThreeSide {
}
@NotNull
public <T> T selectN(@NotNull T left, @NotNull T base, @NotNull T right) {
public <T> T selectNotNull(@NotNull T left, @NotNull T base, @NotNull T right) {
if (myIndex == 0) return left;
if (myIndex == 1) return base;
if (myIndex == 2) return right;
@@ -67,7 +67,7 @@ public enum ThreeSide {
}
@NotNull
public <T> T selectN(@NotNull T[] array) {
public <T> T selectNotNull(@NotNull T[] array) {
assert array.length == 3;
return array[myIndex];
}
@@ -79,7 +79,7 @@ public enum ThreeSide {
}
@NotNull
public <T> T selectN(@NotNull List<T> list) {
public <T> T selectNotNull(@NotNull List<T> list) {
assert list.size() == 3;
return list.get(myIndex);
}
@@ -241,7 +241,7 @@ public class MergeUtil {
@NotNull
private Interval getRange(@NotNull ThreeSide side) {
return side.selectN(myLeft, myBase, myRight);
return side.selectNotNull(myLeft, myBase, myRight);
}
public int getStartLine(@NotNull ThreeSide side) {
@@ -583,6 +583,11 @@ public abstract class DiffRequestProcessor implements Disposable {
protected class MyNextDifferenceAction extends NextDifferenceAction {
@Override
public void update(@NotNull AnActionEvent e) {
if (!ActionPlaces.DIFF_TOOLBAR.equals(e.getPlace())) {
e.getPresentation().setEnabledAndVisible(true);
return;
}
PrevNextDifferenceIterable iterable = DiffDataKeys.PREV_NEXT_DIFFERENCE_ITERABLE.getData(e.getDataContext());
if (iterable != null && iterable.canGoNext()) {
e.getPresentation().setEnabled(true);
@@ -606,6 +611,8 @@ public abstract class DiffRequestProcessor implements Disposable {
return;
}
if (!isNavigationEnabled() || !hasNextChange()) return;
if (myIterationState != IterationState.NEXT) {
// TODO: provide "change" word in chain UserData - for tests/etc
if (iterable != null) iterable.notify("Press again to go to the next file");
@@ -620,6 +627,11 @@ public abstract class DiffRequestProcessor implements Disposable {
protected class MyPrevDifferenceAction extends PrevDifferenceAction {
@Override
public void update(@NotNull AnActionEvent e) {
if (!ActionPlaces.DIFF_TOOLBAR.equals(e.getPlace())) {
e.getPresentation().setEnabledAndVisible(true);
return;
}
PrevNextDifferenceIterable iterable = DiffDataKeys.PREV_NEXT_DIFFERENCE_ITERABLE.getData(e.getDataContext());
if (iterable != null && iterable.canGoPrev()) {
e.getPresentation().setEnabled(true);
@@ -643,6 +655,8 @@ public abstract class DiffRequestProcessor implements Disposable {
return;
}
if (!isNavigationEnabled() || !hasNextChange()) return;
if (myIterationState != IterationState.PREV) {
if (iterable != null) iterable.notify("Press again to go to the previous file");
myIterationState = IterationState.PREV;
@@ -388,7 +388,7 @@ public class BinaryDiffViewer extends ListenerDiffViewerBase {
FileEditor editor = getCurrentEditor();
if (editor == null) return null;
DiffContent content = getCurrentSide().selectN(request.getContents());
DiffContent content = getCurrentSide().selectNotNull(request.getContents());
return content.getOpenFileDescriptor();
}
@@ -1009,7 +1009,7 @@ public class OnesideDiffViewer extends TextDiffViewerBase {
myShouldScroll = !doScrollToContext(myNavigationContext);
}
if (myShouldScroll && myCaretPosition != null && myCaretPosition.length == 2) {
LogicalPosition twosidePosition = myMasterSide.selectN(myCaretPosition);
LogicalPosition twosidePosition = myMasterSide.selectNotNull(myCaretPosition);
int onesideLine = transferLineToOneside(myMasterSide, twosidePosition.line);
LogicalPosition position = new LogicalPosition(onesideLine, twosidePosition.column);
@@ -69,7 +69,7 @@ public class OnesideEditorHighlighter implements EditorHighlighter {
offset = base.getStartOffset();
}
HighlighterIterator it = range.getSide().selectN(it1, it2);
HighlighterIterator it = range.getSide().selectNotNull(it1, it2);
while (!it.atEnd() && changed.getStartOffset() >= it.getEnd()) {
it.advance();
}
@@ -145,7 +145,7 @@ public class OnesideFragmentBuilder {
}
private void appendText(@NotNull Side side, int offset1, int offset2, int lines, int startLine1, int startLine2) {
Document document = side.selectN(myDocument1, myDocument2);
Document document = side.selectNotNull(myDocument1, myDocument2);
int newline = document.getTextLength() > offset2 + 1 ? 1 : 0;
TextRange base = new TextRange(myBuilder.length(), myBuilder.length() + offset2 - offset1 + newline);
@@ -18,6 +18,7 @@ package com.intellij.diff.tools.simple;
import com.intellij.diff.fragments.DiffFragment;
import com.intellij.diff.fragments.LineFragment;
import com.intellij.diff.util.*;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.editor.Document;
@@ -227,9 +228,9 @@ public class SimpleDiffChange {
final Document document1 = myEditor1.getDocument();
final Document document2 = myEditor2.getDocument();
DiffUtil.applyModification(sourceSide.other().selectN(document1, document2),
DiffUtil.applyModification(sourceSide.other().selectNotNull(document1, document2),
getStartLine(sourceSide.other()), getEndLine(sourceSide.other()),
sourceSide.selectN(document1, document2),
sourceSide.selectNotNull(document1, document2),
getStartLine(sourceSide), getEndLine(sourceSide));
destroyHighlighter();
@@ -245,9 +246,9 @@ public class SimpleDiffChange {
final Document document1 = myEditor1.getDocument();
final Document document2 = myEditor2.getDocument();
DiffUtil.applyModification(sourceSide.other().selectN(document1, document2),
DiffUtil.applyModification(sourceSide.other().selectNotNull(document1, document2),
getEndLine(sourceSide.other()), getEndLine(sourceSide.other()),
sourceSide.selectN(document1, document2),
sourceSide.selectNotNull(document1, document2),
getStartLine(sourceSide), getEndLine(sourceSide));
destroyHighlighter();
@@ -261,7 +262,7 @@ public class SimpleDiffChange {
private MyGutterOperation createOperation(@NotNull Side side) {
assert myEditor1 != null && myEditor2 != null;
int offset = side.getStartOffset(myFragment);
EditorEx editor = side.selectN(myEditor1, myEditor2);
EditorEx editor = side.selectNotNull(myEditor1, myEditor2);
RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(offset, offset,
HighlighterLayer.ADDITIONAL_SYNTAX,
null,
@@ -302,8 +303,8 @@ public class SimpleDiffChange {
myCtrlPressed = myViewer.getModifierProvider().isCtrlPressed();
myShiftPressed = myViewer.getModifierProvider().isShiftPressed();
boolean isEditable = DiffUtil.isEditable(mySide.selectN(myEditor1, myEditor2));
boolean isOtherEditable = DiffUtil.isEditable(mySide.other().selectN(myEditor1, myEditor2));
boolean isEditable = DiffUtil.isEditable(mySide.selectNotNull(myEditor1, myEditor2));
boolean isOtherEditable = DiffUtil.isEditable(mySide.other().selectNotNull(myEditor1, myEditor2));
if (myCtrlPressed && myShiftPressed) return null;
if ((myShiftPressed || !isOtherEditable) && isEditable) {
@@ -318,7 +319,7 @@ public class SimpleDiffChange {
@Nullable
private GutterIconRenderer createApplyRenderer(@NotNull final Side side) {
return createIconRenderer(side, DiffIcons.getReplaceIcon(Side.RIGHT), new Runnable() {
return createIconRenderer(side, AllIcons.Diff.Arrow, new Runnable() {
@Override
public void run() {
replaceChange(side);
@@ -328,7 +329,7 @@ public class SimpleDiffChange {
@Nullable
private GutterIconRenderer createAppendRenderer(@NotNull final Side side) {
return createIconRenderer(side, DiffIcons.getAppendIcon(Side.RIGHT), new Runnable() {
return createIconRenderer(side, AllIcons.Diff.ArrowLeftDown, new Runnable() {
@Override
public void run() {
appendChange(side);
@@ -338,7 +339,7 @@ public class SimpleDiffChange {
@Nullable
private GutterIconRenderer createRevertRenderer(@NotNull final Side side) {
return createIconRenderer(side.other(), DiffIcons.getRevertIcon(Side.RIGHT), new Runnable() {
return createIconRenderer(side.other(), AllIcons.Diff.Remove, new Runnable() {
@Override
public void run() {
replaceChange(side.other());
@@ -349,7 +350,7 @@ public class SimpleDiffChange {
@Nullable
private GutterIconRenderer createIconRenderer(@NotNull final Side sourceSide, @NotNull final Icon icon, @NotNull final Runnable perform) {
assert myEditor1 != null && myEditor2 != null;
if (!DiffUtil.isEditable(sourceSide.other().selectN(myEditor1, myEditor2))) return null;
if (!DiffUtil.isEditable(sourceSide.other().selectNotNull(myEditor1, myEditor2))) return null;
return new GutterIconRenderer() {
@NotNull
@Override
@@ -357,6 +358,8 @@ public class SimpleDiffChange {
return icon;
}
public boolean isNavigateAction() { return true; }
@Nullable
@Override
public AnAction getClickAction() {
@@ -369,7 +372,7 @@ public class SimpleDiffChange {
if (!myIsValid) return;
DiffUtil.executeWriteCommand(sourceSide.other().selectN(document1, document2), project, "Replace change", new Runnable() {
DiffUtil.executeWriteCommand(sourceSide.other().selectNotNull(document1, document2), project, "Replace change", new Runnable() {
@Override
public void run() {
perform.run();
@@ -32,11 +32,11 @@ import com.intellij.diff.tools.util.FoldingModelSupport.SimpleFoldingModel;
import com.intellij.diff.tools.util.base.HighlightPolicy;
import com.intellij.diff.tools.util.twoside.TwosideTextDiffViewer;
import com.intellij.diff.util.DiffDividerDrawUtil;
import com.intellij.diff.util.DiffIcons;
import com.intellij.diff.util.DiffUserDataKeysEx.ScrollToPolicy;
import com.intellij.diff.util.DiffUtil;
import com.intellij.diff.util.DiffUtil.DocumentData;
import com.intellij.diff.util.Side;
import com.intellij.icons.AllIcons;
import com.intellij.ide.IdeEventQueue;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
@@ -608,7 +608,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
return;
}
Editor modifiedEditor = side.other(myModifyOpposite).selectN(myEditor1, myEditor2);
Editor modifiedEditor = side.other(myModifyOpposite).selectNotNull(myEditor1, myEditor2);
if (!DiffUtil.isEditable(modifiedEditor)) {
e.getPresentation().setEnabledAndVisible(false);
return;
@@ -626,7 +626,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
final Side side = Side.fromLeft(editor == myEditor1);
final List<SimpleDiffChange> selectedChanges = getSelectedChanges(side);
Editor modifiedEditor = side.other(myModifyOpposite).selectN(myEditor1, myEditor2);
Editor modifiedEditor = side.other(myModifyOpposite).selectNotNull(myEditor1, myEditor2);
String title = e.getPresentation().getText() + " selected changes";
DiffUtil.executeWriteCommand(modifiedEditor.getDocument(), e.getProject(), title, new Runnable() {
@Override
@@ -663,13 +663,13 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
private class ReplaceSelectedChangesAction extends ApplySelectedChangesActionBase {
public ReplaceSelectedChangesAction() {
super("Replace", null, DiffIcons.getReplaceIcon(null), true);
super("Replace", null, AllIcons.Diff.Arrow, true);
}
@NotNull
@Override
protected Icon getIcon(@NotNull Side side) {
return DiffIcons.getReplaceIcon(side);
return side.isLeft() ? AllIcons.Diff.Arrow : AllIcons.Diff.ArrowRight;
}
@Override
@@ -682,13 +682,13 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
private class AppendSelectedChangesAction extends ApplySelectedChangesActionBase {
public AppendSelectedChangesAction() {
super("Insert", null, DiffIcons.getAppendIcon(null), true);
super("Insert", null, AllIcons.Diff.ArrowLeftDown, true);
}
@NotNull
@Override
protected Icon getIcon(@NotNull Side side) {
return DiffIcons.getAppendIcon(side);
return side.isLeft() ? AllIcons.Diff.ArrowLeftDown : AllIcons.Diff.ArrowRightDown;
}
@Override
@@ -701,13 +701,13 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
private class RevertSelectedChangesAction extends ApplySelectedChangesActionBase {
public RevertSelectedChangesAction() {
super("Revert", null, DiffIcons.getRevertIcon(null), false);
super("Revert", null, AllIcons.Diff.Remove, false);
}
@NotNull
@Override
protected Icon getIcon(@NotNull Side side) {
return DiffIcons.getRevertIcon(side);
return AllIcons.Diff.Remove;
}
@Override
@@ -81,7 +81,7 @@ public class SimpleThreesideDiffChange {
//
private void createHighlighter(@NotNull ThreeSide side) {
Editor editor = side.selectN(myEditors);
Editor editor = side.selectNotNull(myEditors);
Document document = editor.getDocument();
TextDiffType type = getDiffType();
@@ -208,7 +208,7 @@ public class SimpleThreesideDiffChange {
private static CharSequence getRangeContent(@NotNull MergeLineFragment fragment,
@NotNull List<EditorEx> editors,
@NotNull ThreeSide side) {
DocumentEx document = side.selectN(editors).getDocument();
DocumentEx document = side.selectNotNull(editors).getDocument();
int line1 = fragment.getStartLine(side);
int line2 = fragment.getEndLine(side);
return DiffUtil.getLinesContent(document, line1, line2);
@@ -391,7 +391,7 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewer {
@NotNull
@Override
protected SyncScrollSupport.SyncScrollable getSyncScrollable(@NotNull Side side) {
return side.selectN(mySyncScrollable1, mySyncScrollable2);
return side.selectNotNull(mySyncScrollable1, mySyncScrollable2);
}
@NotNull
@@ -548,15 +548,15 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewer {
@Override
protected void processHelper(@NotNull ScrollHelper helper) {
ThreeSide left = mySide.selectN(ThreeSide.LEFT, ThreeSide.BASE);
ThreeSide right = mySide.selectN(ThreeSide.BASE, ThreeSide.RIGHT);
ThreeSide left = mySide.selectNotNull(ThreeSide.LEFT, ThreeSide.BASE);
ThreeSide right = mySide.selectNotNull(ThreeSide.BASE, ThreeSide.RIGHT);
if (!helper.process(0, 0)) return;
for (SimpleThreesideDiffChange diffChange : myDiffChanges) {
if (!helper.process(diffChange.getStartLine(left), diffChange.getStartLine(right))) return;
if (!helper.process(diffChange.getEndLine(left), diffChange.getEndLine(right))) return;
}
helper.process(left.selectN(myEditors).getDocument().getLineCount(), right.selectN(myEditors).getDocument().getLineCount());
helper.process(left.selectNotNull(myEditors).getDocument().getLineCount(), right.selectNotNull(myEditors).getDocument().getLineCount());
}
}
@@ -569,8 +569,8 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewer {
@Override
public void process(@NotNull Handler handler) {
ThreeSide left = mySide.selectN(ThreeSide.LEFT, ThreeSide.BASE);
ThreeSide right = mySide.selectN(ThreeSide.BASE, ThreeSide.RIGHT);
ThreeSide left = mySide.selectNotNull(ThreeSide.LEFT, ThreeSide.BASE);
ThreeSide right = mySide.selectNotNull(ThreeSide.BASE, ThreeSide.RIGHT);
for (SimpleThreesideDiffChange diffChange : myDiffChanges) {
if (!diffChange.getType().isChange(mySide)) continue;
@@ -596,8 +596,8 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewer {
public void paint(@NotNull Graphics g, @NotNull Component divider) {
Graphics2D gg = getDividerGraphics(g, divider);
Editor editor1 = mySide.selectN(myEditors.get(0), myEditors.get(1));
Editor editor2 = mySide.selectN(myEditors.get(1), myEditors.get(2));
Editor editor1 = mySide.selectNotNull(myEditors.get(0), myEditors.get(1));
Editor editor2 = mySide.selectNotNull(myEditors.get(1), myEditors.get(2));
//DividerPolygonUtil.paintSimplePolygons(gg, divider.getWidth(), editor1, editor2, myPaintable);
DiffDividerDrawUtil.paintPolygons(gg, divider.getWidth(), editor1, editor2, myPaintable);
@@ -264,7 +264,7 @@ public class FoldingModelSupport {
}
public void paintOnDivider(@NotNull Graphics2D gg, @NotNull Component divider, @NotNull Side side) {
MyPaintable paintable = side.selectN(myPaintable1, myPaintable2);
MyPaintable paintable = side.selectNotNull(myPaintable1, myPaintable2);
paintable.paintOnDivider(gg, divider);
}
@@ -254,7 +254,7 @@ public abstract class ThreesideTextDiffViewer extends TextDiffViewerBase {
@NotNull
public EditorEx getCurrentEditor() {
return myCurrentSide.selectN(myEditors);
return myCurrentSide.selectNotNull(myEditors);
}
@NotNull
@@ -274,7 +274,7 @@ public abstract class ThreesideTextDiffViewer extends TextDiffViewerBase {
@CalledInAwt
protected void scrollToLine(@NotNull ThreeSide side, int line) {
Editor editor = side.selectN(myEditors);
Editor editor = side.selectNotNull(myEditors);
DiffUtil.scrollEditor(editor, line);
myCurrentSide = side;
}
@@ -301,7 +301,7 @@ public abstract class ThreesideTextDiffViewer extends TextDiffViewerBase {
protected OpenFileDescriptor getOpenFileDescriptor() {
EditorEx editor = getCurrentEditor();
DocumentContent content = getCurrentSide().selectN(myActualContents);
DocumentContent content = getCurrentSide().selectNotNull(myActualContents);
int offset = editor.getCaretModel().getOffset();
return content.getOpenFileDescriptor(offset);
@@ -363,8 +363,8 @@ public abstract class ThreesideTextDiffViewer extends TextDiffViewerBase {
DiffContent[] contents = myRequest.getContents();
String[] titles = myRequest.getContentTitles();
DiffRequest request = new SimpleDiffRequest(myRequest.getTitle(), mySide1.selectN(contents), mySide2.selectN(contents),
mySide1.selectN(titles), mySide1.selectN(titles));
DiffRequest request = new SimpleDiffRequest(myRequest.getTitle(), mySide1.selectNotNull(contents), mySide2.selectNotNull(contents),
mySide1.selectNotNull(titles), mySide1.selectNotNull(titles));
DiffManager.getInstance().showDiff(myProject, request, new DiffDialogHints(null, myPanel));
}
}
@@ -1,53 +0,0 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.diff.util;
import com.intellij.icons.AllIcons;
import com.intellij.util.IconUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
public class DiffIcons {
public final static Icon REPLACE_LEFT = IconUtil.flip(AllIcons.Diff.Arrow, true);
public final static Icon REPLACE_RIGHT = AllIcons.Diff.Arrow;
// TODO: different icon
public final static Icon APPEND_LEFT = IconUtil.flip(AllIcons.Diff.Arrow, true);
public final static Icon APPEND_RIGHT = AllIcons.Diff.Arrow;
public final static Icon REVERT_LEFT = AllIcons.Diff.Remove;
public final static Icon REVERT_RIGHT = AllIcons.Diff.Remove;
@NotNull
public static Icon getReplaceIcon(@Nullable Side side) {
if (side == null) side = Side.LEFT;
return side.selectN(REPLACE_LEFT, REPLACE_RIGHT);
}
@NotNull
public static Icon getAppendIcon(@Nullable Side side) {
if (side == null) side = Side.LEFT;
return side.selectN(APPEND_LEFT, APPEND_RIGHT);
}
@NotNull
public static Icon getRevertIcon(@Nullable Side side) {
if (side == null) side = Side.LEFT;
return side.selectN(REVERT_LEFT, REVERT_RIGHT);
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 B

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Some files were not shown because too many files have changed in this diff Show More